Handheld gaming machine, based on the Arduino Leonardo, equipped with joystick, SD card and more.
Adafruit_ST7735 tft = Adafruit_ST7735(SS, 9, 8);JoyGamer jg = JoyGamer(&tft);This allows us to directly access all of the functionality of the Adafruit graphics library for the ST7735 screen directly by calling functions on our tft variable. However, we also pass a pointer to this variable to the JoyGamer. Don't worry if you don't know what pointers are, but thats what we get when we put the ampersand before a variable. Since the JoyGamer knows about the tft LCD screen our library can also create graphics. So when you are writing code for the joy gamer you can use functions from the JoyGamer library and/or from the Adafruit graphics library. This is why we have to include all those libraries at the top of this file.
/* LucidTronix Joy Gamer * For instructions, details and schematic, See: * http://www.lucidtronix.com/tutorials/48 */#include#include // Core graphics library#include // Hardware-specific library#include #include #include #include #include Adafruit_ST7735 tft = Adafruit_ST7735(SS, 9, 8);JoyGamer jg = JoyGamer(&tft);void setup(){ jg.initialize(); jg.start_sd_card();}void loop(){ jg.show_accelerometer(10, 40); tft.fillRect(49, 75, 40, 22, jg.background.color_16()); jg.draw_string(10, 75, "Joy X:", jg.stroke.color_16(), 1); jg.print_integer(50, 75, analogRead(0), 1); jg.draw_string(10, 85, "Joy Y:", jg.stroke.color_16(), 1); jg.print_integer(50, 85, analogRead(1), 1);}
jg.bmp_load_and_draw_image("sample.bmp");
Make sure you have the SD card inserted properly, and loaded with the bitmap file "sample.bmp". You can of course load whatever images you want. The images do have to be in bitmap format and at largest 128 by 160 pixels. We wrote a little program to convert images into the bmp format, you can download it below.
/* LucidTronix Joy Gamer * For instructions, details and schematic, See: * http://www.lucidtronix.com/tutorials/48 */#include#include // Core graphics library#include // Hardware-specific library#include #include #include #include #include Adafruit_ST7735 tft = Adafruit_ST7735(SS, 9, 8);JoyGamer jg = JoyGamer(&tft);void setup(){ jg.initialize(); jg.start_sd_card(); jg.bmp_load_and_draw_image("sample.bmp");}void loop() {}
| Title | Description | # | Cost | Link | Picture |
| PCB LEO Gamer | Circuit board for the LEO Gamer. Joystick, accelerometer and TFT LCD Screen. | 1 | $10.0 | Link |
|
| TFT LCD Screen | 1.8 inch 160 x 128 pixels LCD screen. ST7735R driver. JDT-1800. | 1 | $9.95 | Link |
|
| ATMEGA32U4-MU | Integrated Circuits MCU AVR 32K FLASH 16MHZ 44-QFNValue:2.7 V ~ 5.5 V 16MHz | 1 | $6.04 | Link |
|
| microSD Card Connector | Secure Digital - microSD™ Push In, Push OutValue: microSD | 1 | $3.44 | Link |
|
| Joystick Potentiometer | POT JOYSTICK 10K OHM W/SWITCHValue:Variable Resistors 10K | 1 | $2.86 | Link |
|
| Accelerometers MMA8453QR1 | Tripla axis: X, Y, Z ±2g, 4g, 8g 16-VFDFN I²C 16-QFN (3x3)Value:I²C | 1 | $1.43 | Link |
|
| USB Micro B Female Connector | Micro USB Surface Mount, Right Angle, Horizontal | 1 | $0.72 | Link |
|
| Crystal | CRYSTAL 16.00000 MHZ 20PF SMDValue:16MHz | 1 | $0.53 | Link |
|
| Button | Tactile switch SMD SPST 0.05A 12VValue:SPST | 1 | $0.2 | Link |
|
| LED SMD | LED 3X1.5MM 568NM Green Clear SMDValue:2.2V Green | 1 | $0.18 | Link |
|
| Capacitor | CAP CER 0.1UF 50V Y5V 0805Value:0.1µF | 1 | $0.1 | Link |
|
| Resistor | Chip Resistor - Surface Mount RES 10K OHM 1/8W 5% 0805 SMDValue: 10k | 1 | $0.1 | Link |
|
Comments: