Pinouts

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!

Microcontroller and Flash

  • 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.

Power

  • 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 PyBadge. 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.

Display

  • 1.8" TFT display - The front features a 160x128 pixel color display.
  • 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) or A7 (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) or 8 (Arduino)
  • Accelerometer - There is an accelerometer located near the middle, above the I2C connector. It is an LIS3DH.
  • Light sensor (A7)  - There is also 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) or A7 (Arduino) you can read it as any analog value ranging from 0 (dark) to 1023 (in Arduino) or 65535 (CircuitPython) when bright.
  • 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.

For gaming interface, there are 4 buttons and an analog thumbstick

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.

Download: file
#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 GamePadShift library to read the button presses for you:

Download: file
pad = GamePadShift(digitalio.DigitalInOut(board.BUTTON_CLOCK),
                   digitalio.DigitalInOut(board.BUTTON_OUT),
				   digitalio.DigitalInOut(board.BUTTON_LATCH))
pressed = pad.get_pressed()
  • There is a 4-pin JST I2C connector in the center on the bottom, that is STEMMA and Grove compatible. You can access VCC power and ground as well as a level-shifted SDA & SCL connection. 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 and D3. These are 3-pin JST digital or analog connectors for sensors or NeoPixels. These pins can be analog inputs or digital I/O. D2 is also known as A8, D3 is also known as A9 for analog reads.
  • You can easily attach FeatherWings to the back of your PyBadge 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 PyBadge! The GPIO is all 3.3V logic.
  • On the back, there is a micro SD card slot. Insert a micro SD card for even more storage for more games, images, sounds, etc.
This guide was first published on May 25, 2019. It was last updated on May 25, 2019. This page (Pinouts) was last updated on Nov 14, 2019.