The PyGamer is a DIY handheld gaming development platform, and it's loaded with all sorts of goodies. The front features a display, buttons, a joystick, RGB LEDs, and a light sensor.
The back features a speaker connector, headphone jack, SD card slot, battery connector, peripheral connectors, an accelerometer and more. Let's take a look!
- The main processor chip is the ATSAMD51J19 Cortex M4 running at 120MHz with 3.3v logic/power. It has 512KB of Flash and 192KB of RAM.
- We also include 8 MB of QSPI Flash for storing images, sounds, animations, whatever.
- The On/Off switch is located on the top.
- There is one USB port on the board. On the left side, towards the bottom, is a USB Micro port, which is used for powering and programming the board.
-
There's two ways to power your PyGamer. The best way is to plug in a 3.7/4.2V Lipoly battery into the JST 2-PH port. You can then recharge the battery over the Micro USB jack. You can also just run the board directly from Micro USB, it will automatically 'switch over' to USB power when that's plugged in.
-
Pin A6 is connected to a voltage divider which gives half the current battery voltage. You can read the battery voltage by using the Arcada library function readBatterySensor() (it multiplies by two to give the actual voltage), by using analogRead(A6) in Arduino, or by using analogio.AnalogIn(board.A6) in CircuitPython.
- On/Off switch - Powers off the board. Even if plugged in, the board won't work if switched to off. You can charge the battery when the board is off, but the USB device will not be active or any other electronics
- The reset button is located on the top to the right of center. Click it once to re-start your firmware. Click twice to enter bootloader mode.
-
Light sensor (A7) - There is an ambient light sensor on the top, which points through to the front. The light sensor is an analog input, connected to
board.LIGHT
(CircuitPython) orA7
(Arduino) you can read it as any analog value ranging from 0 (dark) to 1023 (in Arduino) or 65535 (CircuitPython) when bright. -
NeoPixels (D8) - There are also 5 individually addressable RGB NeoPixel LEDs located on the front of the board along the bottom middle. The are connected to
board.NEOPIXEL
(CircuitPython) or8
(Arduino)
- Accelerometer - There is an accelerometer located near the middle, above the I2C connector. It is an LIS3DH.
- There is a speaker connector on the left side of the back, which is a Molex PicoBlade. You can attach one of the speakers available in the Adafruit shop.
- There is also a stereo headphone jack on the left top.
There is a thumb joystick on the left side of the board. The thumb joystick is a dual potentiometer, one pot for X axis and one for Y axis. You can read the two analog values to determine the position of the joystick. For example, the reading will be at 0V (ground) when the X axis is all the way to the left and 3.3V (analog-max) when the stick is all the way to the right. Arduino A11
is joystick X, and Y is A10
.
uint16_t joyy = analogRead(A10);
uint16_t joyx = analogRead(A11);
In CircuitPython they are just named JOYSTICK_X
and JOYSTICK_Y
joystick_x = analogio.AnalogIn(board.JOYSTICK_X)
joystick_y = analogio.AnalogIn(board.JOYSTICK_Y)
For information on reading the values, check out the Reading Analog Pin Values section of the CircuitPython Essentials Analog In page.
There are four buttons: A, B, select and start. These four pads are not connected to GPIO pins. Instead, they are connected to a latch via 3 digital pins that will read up to 8 inputs and send the data over one bit at a time. If using Arduino, this psuedo-code snippet will read the 8 bits for you. A 0 bit indicates no press. A 1 bit indicates a press.
#define BUTTON_CLOCK 48 #define BUTTON_DATA 49 #define BUTTON_LATCH 50 uint8_t read_buttons() { uint8_t result = 0; pinMode(BUTTON_CLOCK, OUTPUT); digitalWrite(BUTTON_CLOCK, HIGH); pinMode(BUTTON_LATCH, OUTPUT); digitalWrite(BUTTON_LATCH, HIGH); pinMode(BUTTON_DATA, INPUT); digitalWrite(BUTTON_LATCH, LOW); digitalWrite(BUTTON_LATCH, HIGH); for(int i = 0; i < 8; i++) { result <<= 1; //Serial.print(digitalRead(BUTTON_DATA)); Serial.print(", "); result |= digitalRead(BUTTON_DATA); digitalWrite(BUTTON_CLOCK, HIGH); digitalWrite(BUTTON_CLOCK, LOW); } Serial.println(); return result; }
But we would recommend using Arcada instead, where a lot of this abstraction is handled for you
In CircuitPython, use the keypad.ShiftRegisterKeys library to read the button presses for you:
k = keypad.ShiftRegisterKeys( clock=board.BUTTON_CLOCK, data=board.BUTTON_OUT, latch=board.BUTTON_LATCH, key_count=8, value_when_pressed=True, ) while True: event = k.events.get() if event: print(event)
- There is a 4-pin JST PH 2.0mm I2C connector in the center on the bottom, that is STEMMA and Grove compatible as well as Stemma QT with an adapter cable. You can access VCC power and ground as well as a level-shifted
SDA
&SCL
connection. In CircuitPython, you can use the STEMMA connector withboard.SCL
andboard.SDA
, orboard.STEMMA_I2C()
. You can change VCC from 5V (default) to 3V by cutting/soldering the solder jumper to the right of the D3 connector. - On the bottom are two connectors labeled
D2
andD3
. These are 3-pin JST PH 2.0mm digital or analog connectors for sensors or NeoPixels. These pins can be analog inputs or digital I/O. D2 is also known asA8
, D3 is also known asA9
for analog reads.
- You can easily attach FeatherWings to the back of your PyGamer using the convenient "Feather Headers" on the back. Located in the middle, they break out all the same pins you have access to on a Feather board, allowing use of any of our wide range of FeatherWings. Easily add all kinds of functionality to your PyGamer! The GPIO is all 3.3V logic.
Text editor powered by tinymce.