/*
Wokwi | questions
Button components floating.
HexedRevii - Friday, March 27, 2026 6:04 PM
My two button components are stuck floating,
even though they should be wired correctly according to Arduino.
*/
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Wire.h>
#include <SPI.h>
#include "Screen_Definitions.h"
#include "Button.h"
#include "Joystick.h"
#include "Vector2.h"
// Globals (I do not know how to avoid these in C)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Joystick* joystick = NULL;
int btna = 12;
int btnb = 11;
int btnj = 5;
void setup() {
Serial.begin(9600);
//Wire.begin();
pinMode(btna, INPUT_PULLUP);
pinMode(btnb, INPUT_PULLUP);
pinMode(btnj, INPUT_PULLUP);
// Create the movement joystick
joystick = joystick_init(A1, A0);
// Setup display
display.setRotation(2);
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDR)) {
Serial.println("Failed to initialise display.");
for (;;) {}
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
display.setCursor(0, 20);
display.print("Hello, guys");
display.display();
Serial.println("Ready!");
}
void loop() {
if (digitalRead(btna) == LOW) {
Serial.println("A");
}
if (digitalRead(btnb) == LOW) {
Serial.println("B");
}
if (digitalRead(btnj) == LOW) {
Serial.println("Joy");
}
}
void ledButtonCallback() {
}