I am working with Arduino for the first time, more exactly Arduino Uno. My teammate wrote the beginning of the program. When he uploads it on his pybadge, it first shows "Press A to start", then after he presses the button, the game starts. However, I uploaded the same code on my pybadge and after it uploads successfully, the first image with "Press A to start" shows up, but after I press the button, nothing happens.
This is the loop function:
#include "Adafruit_Arcada.h"
#include <Adafruit_NeoPixel.h>
Adafruit_Arcada arcada;
#define LED_PIN 9 // any PWM capable pin
#define NUM_LEDS 57
#define PIN 8
#define NUMPIXELS 5
#define DELAYVAL 1000
Adafruit_NeoPixel strip(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int spaceschiffx = 10;
const unsigned short spaceschiff[384] PROGMEM={
0x0000, 0x0821, 0x0001, 0x0000, 0x0001, 0x0021, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0800, 0x6728, 0x7EAB, // 0x0010 (16) pixels
0x76EA, 0x7EEB, 0x7EAA, 0x7ECB, 0x0000, 0x0040, 0x0000, 0x0000, 0x0000, 0x0000, 0x76E9, 0x979F, 0x0000, 0x0020, 0x0000, 0x0800, // 0x0020 (32) pixels
0x0000, 0x0000, 0x0001, 0x0800, 0x0000, 0x770B, 0x0000, 0x0800, 0x01F5, 0x0235, 0x7EAA, 0x6EC8, 0x0021, 0x0001, 0x0000, 0x0000, // 0x0030 (48) pixels
0x0000, 0x0001, 0x6EEA, 0x877D, 0x879F, 0x0020, 0x0001, 0x0020, 0x0800, 0x0022, 0x6EC9, 0x76C8, 0x76EA, 0x0000, 0x0001, 0x0800, // 0x0040 (64) pixels
0x0000, 0x76A9, 0x7F0A, 0x0800, 0x0001, 0x0800, 0x0000, 0x0021, 0x0000, 0x0040, 0x86EA, 0x0237, 0x8F7F, 0x875F, 0x0800, 0x0000, // 0x0050 (80) pixels
0x0020, 0x0800, 0x0216, 0x01F3, 0x0216, 0x01F5, 0x7FFF, 0x87BF, 0x877F, 0x8FBF, 0x0000, 0x0000, 0x0000, 0x0040, 0x0000, 0x0020, // 0x0060 (96) pixels
0x0800, 0x0800, 0x66C7, 0x09F5, 0x0235, 0x87FF, 0x0800, 0x0000, 0x0236, 0x01D5, 0x09F6, 0x01D5, 0x09D6, 0x0214, 0x01D6, 0x01D6, // 0x0070 (112) pixels
0x87BF, 0x879E, 0xA434, 0x8FBF, 0x0001, 0x0000, 0x0800, 0x0020, 0x0001, 0x0020, 0x522D, 0x7EAA, 0x01F7, 0x01F6, 0x0215, 0x0214, // 0x0080 (128) pixels
0x09F5, 0x0216, 0x01F5, 0x0215, 0x01F2, 0x01F6, 0x0236, 0x01F3, 0x09F5, 0x9C32, 0x7F9F, 0x7FBF, 0x7F9F, 0x0000, 0x0000, 0x0020, // 0x0090 (144) pixels
0x0800, 0x5A0B, 0x01F6, 0x1236, 0x0000, 0x01B5, 0x0A16, 0x01F6, 0x0215, 0xF7FF, 0x01F6, 0x0236, 0x0215, 0x01D7, 0x9C11, 0xFFFF, // 0x00A0 (160) pixels
0xFFDF, 0xFFDF, 0x8F7F, 0x8F7F, 0xAC74, 0x01B5, 0x0000, 0x0001, 0x6EEA, 0x0234, 0x09D8, 0x0000, 0x0001, 0x0020, 0x0020, 0x0000, // 0x00B0 (176) pixels
0x0000, 0x0002, 0x0A56, 0x01D4, 0x0214, 0x0216, 0x879F, 0x879F, 0xFFFF, 0xF7FC, 0xFFFF, 0xA413, 0x01D4, 0x0235, 0x0255, 0x0000, // 0x00C0 (192) pixels
0x86EB, 0x6EC9, 0x7F08, 0x6EEA, 0x6EA8, 0x0041, 0x0000, 0x01F5, 0x01F6, 0x0216, 0x0800, 0x0215, 0x01F5, 0x0213, 0x0215, 0x01F6, // 0x00D0 (208) pixels
0x01F6, 0x0235, 0x01F5, 0x01F5, 0x01F5, 0x0215, 0x01F6, 0x7EE9, 0x0000, 0x1000, 0x0800, 0x0020, 0x1003, 0x7EAA, 0x01F4, 0x01F6, // 0x00E0 (224) pixels
0x0234, 0x0215, 0x7F9F, 0x879F, 0x09F5, 0x01F6, 0x0216, 0x01F4, 0x0234, 0x01B5, 0x11F6, 0x0235, 0x0255, 0x01F5, 0x7ECA, 0x0020, // 0x00F0 (240) pixels
0x0020, 0x0020, 0x0000, 0x0040, 0x7F0A, 0x01D5, 0x01F4, 0x09D7, 0x09F5, 0x877F, 0x8F9F, 0x868A, 0x0020, 0x01D7, 0x0216, 0x01F6, // 0x0100 (256) pixels
0x01F4, 0x01F5, 0x01F6, 0x09B6, 0x76E8, 0x7EAA, 0x0002, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x11D5, 0x0215, 0x0236, 0x0234, // 0x0110 (272) pixels
0x8F5F, 0x877F, 0x7EEA, 0x7749, 0x66AA, 0x8EE9, 0x7ECA, 0x7EEB, 0x7EEA, 0x7F0A, 0x6707, 0x76E9, 0x0020, 0x0800, 0x0000, 0x0020, // 0x0120 (288) pixels
0x0020, 0x0000, 0x0021, 0x0800, 0x01F6, 0x0215, 0x01D7, 0x09D5, 0x0020, 0x76EA, 0x76A9, 0x6F28, 0x0001, 0x0216, 0x76E8, 0x0020, // 0x0130 (304) pixels
0x0000, 0x0020, 0x0804, 0x0800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6F0A, 0x7EEA, 0x7EE9, 0x770A, 0x76E9, // 0x0140 (320) pixels
0x76C8, 0x7EEB, 0x7EC9, 0x01F6, 0x0020, 0x0000, 0x86CA, 0x0001, 0x0021, 0x0000, 0x0020, 0x0020, 0x0000, 0x0020, 0x0800, 0x0000, // 0x0150 (336) pixels
0x0001, 0x0000, 0x0020, 0x0000, 0x0001, 0x0020, 0x0021, 0x76CA, 0x7EEA, 0x770B, 0x868A, 0x0216, 0x0020, 0x7EC9, 0x0000, 0x0040, // 0x0160 (352) pixels
0x0000, 0x0020, 0x0000, 0x0000, 0x0020, 0x0000, 0x0021, 0x0000, 0x0000, 0x0020, 0x0801, 0x0000, 0x0000, 0x0800, 0x0800, 0x0000, // 0x0170 (368) pixels
0x7EA9, 0x76EA, 0x7EC9, 0x76EA, 0x76EA, 0x0002, 0x0800, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0002, 0x0020, 0x0000, 0x0000, // 0x0180 (384) pixels
};
const unsigned short boggy[400] PROGMEM={
0x0000, 0x0001, 0x0800, 0x0800, 0x0000, 0x0020, 0x0020, 0x0000, 0x0000, 0x0000, 0x0020, 0x0800, 0x0021, 0x0800, 0x0000, 0x0000, // 0x0010 (16) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0001, 0x0800, 0x0020, 0x0000, 0x0000, 0x0802, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0020 (32) pixels
0x0000, 0x0020, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0020, 0x0020, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, // 0x0030 (48) pixels
0x0020, 0x0000, 0x0000, 0x0000, 0x0020, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000, // 0x0040 (64) pixels
0x0000, 0x0021, 0x0020, 0x0020, 0x0800, 0x0000, 0x0020, 0x0800, 0x0000, 0x0000, 0x0020, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0050 (80) pixels
0x0000, 0x0001, 0x0021, 0x0800, 0x0800, 0x0000, 0x0040, 0x0800, 0x0020, 0x0000, 0x0000, 0x0800, 0x0020, 0x0000, 0x0000, 0x0000, // 0x0060 (96) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0000, 0x0020, 0x8A69, 0x9207, 0x8A08, 0x0000, 0x0040, 0x0000, 0x0000, 0x0000, // 0x0070 (112) pixels
0x0040, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0041, 0x0000, 0x99C6, 0x8267, 0x9228, 0x8A66, 0x9A27, // 0x0080 (128) pixels
0x0800, 0x0000, 0x0000, 0x0000, 0x1000, 0x0020, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x9249, 0x9224, // 0x0090 (144) pixels
0x8A29, 0x9206, 0xFC09, 0x8A06, 0x9209, 0x0020, 0x0020, 0x0000, 0x8A0A, 0x0020, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00A0 (160) pixels
0x0820, 0x0000, 0x59ED, 0x8A47, 0x91C8, 0x8A88, 0x9247, 0xFBE8, 0x9247, 0x89E8, 0x0020, 0x0000, 0x8A27, 0xFBC5, 0x0041, 0x0000, // 0x00B0 (176) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x5A2E, 0x8248, 0x9265, 0x99E7, 0x89C6, 0x8266, 0xF3E7, 0x9A47, 0x9249, 0x61CD, // 0x00C0 (192) pixels
0x9246, 0x9248, 0x0000, 0x0041, 0x0000, 0x0000, 0x0000, 0x0000, 0x0800, 0x0020, 0x61AC, 0x8A66, 0x9207, 0x8A49, 0x9227, 0x9246, // 0x00D0 (208) pixels
0x9A06, 0x8A29, 0x5A2D, 0x59AC, 0x8229, 0x9248, 0x0040, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0800, 0x620F, 0x8A46, // 0x00E0 (224) pixels
0x9226, 0x91E6, 0x8A28, 0x9207, 0x8A46, 0x8A47, 0x0000, 0x0020, 0x9A68, 0x89E7, 0x0800, 0x0002, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00F0 (240) pixels
0x0040, 0x0001, 0x51CC, 0x622D, 0x8A08, 0x8A28, 0x9A49, 0x8A07, 0x8267, 0x0800, 0x0000, 0x0000, 0x8A26, 0x0020, 0x0000, 0x0000, // 0x0100 (256) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x5A0D, 0x59ED, 0x9229, 0x9205, 0x8A67, 0x0000, 0x0002, 0x0001, 0x0001, // 0x0110 (272) pixels
0x0000, 0x0000, 0x0001, 0x0020, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0800, 0x0020, 0x620C, 0x9207, 0x8A46, 0x0000, // 0x0120 (288) pixels
0x0001, 0x0800, 0x0800, 0x0021, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, // 0x0130 (304) pixels
0x0000, 0x0802, 0x0000, 0x0000, 0x0020, 0x0020, 0x0000, 0x0020, 0x0002, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0140 (320) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0150 (336) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0160 (352) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0170 (368) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0180 (384) pixels
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0190 (400) pixels
};
void setup() {
Serial.begin(9600);
Serial.print("Hello! Arcada TFT Test");
// Start TFT and fill black
if (!arcada.arcadaBegin()) {
Serial.print("Failed to begin");
while (1) delay(10);
}
arcada.displayBegin();
// Turn on backlight
arcada.setBacklight(255);
strip.begin();
strip.show();
arcada.display->fillScreen(ARCADA_WHITE);
Game_Init();
}
void loop() {
strip.clear();
uint8_t buttons = arcada.readButtons();
switch(buttons)
{
case ARCADA_BUTTONMASK_A: GameStart(); break;
case ARCADA_BUTTONMASK_B: Game_Init(); break;
case ARCADA_BUTTONMASK_UP: arcada.display->fillRoundRect(0, spaceschiffx, 30, 21, 30, ARCADA_BLACK);spaceschiffx -= 24; arcada.display->drawRGBBitmap(3, spaceschiffx, spaceschiff, 24, 16); break;
case ARCADA_BUTTONMASK_DOWN : arcada.display->fillRoundRect(0, spaceschiffx, 30, 21, 30, ARCADA_BLACK);spaceschiffx += 24 ; arcada.display->drawRGBBitmap(3, spaceschiffx, spaceschiff, 24, 16); break;
}
delay(200);
}
void Game_Init(){
turnOffPixels();
// Display Init
arcada.display->setTextColor(ARCADA_BLACK);
arcada.display->setTextWrap(false);
arcada.display->fillScreen(ARCADA_WHITE);
arcada.display->setTextColor(ARCADA_RED);
arcada.display->setCursor(10, 20);
arcada.display->setTextSize(3);
arcada.display->println("To Start");
arcada.display->setCursor(10, 50);
arcada.display->println("The Game");
arcada.display->setTextColor(ARCADA_BLACK);
arcada.display->setCursor(15, 80);
arcada.display->println("Press A");
}
void GameStart(){
OLED_init();
arcada.display->fillScreen(ARCADA_BLACK);
arcada.display->setTextColor(ARCADA_RED);
arcada.display->setTextSize(0);
arcada.display->setCursor(70, 0);
arcada.display->println("TO EXIT Press B");
arcada.display->drawRGBBitmap(3, spaceschiffx, spaceschiff, 24, 16);
arcada.display->drawRGBBitmap(100, 60, boggy, 20, 20);
}
void OLED_init(){
turnOffPixels();
for (byte i = 0; i < NUM_LEDS; i++) {
if ((i) % 2 == 0) {
strip.setPixelColor(i, strip.Color(50, 40, 0));
} else {
strip.setPixelColor(i, strip.Color(50, 0, 0));
}
strip.show();
}
}
void turnOffPixels()
{
for (byte i = 0; i < NUM_LEDS; i++) {
strip.setPixelColor(i, strip.Color(0, 0, 0));
}
strip.show();
}