// Master Test-Bench Code for Phase 1 Setup
void setup() {
// 1. Initialize the high-speed Serial text connection to the screen
Serial.begin(115200);
// 2. Configure our 4 action buttons using the internal software pull-up resistors
pinMode(10, INPUT_PULLUP); // Button 1 (Jump)
pinMode(11, INPUT_PULLUP); // Button 2 (Crouch)
pinMode(12, INPUT_PULLUP); // Button 3 (Ability)
pinMode(13, INPUT_PULLUP); // Button 4 (Reload)
// 3. Configure the Left Joystick Click (Sprint) on PC13
pinMode(PC13, INPUT_PULLUP);
Serial.println("--- STM32 CONTROLLER TEST BENCH LIVE ---");
}
void loop() {
// Read Analog Channels (Returns 0 to 1023 or 4095 depending on virtual core)
int joy1_x = analogRead(A0);
int joy1_y = analogRead(A1);
int joy2_x = analogRead(A2);
int joy2_y = analogRead(A3);
// Read Digital Buttons (Returns 0 when pressed because of the Pull-Up logic!)
int btn_jump = digitalRead(10);
int btn_crouch = digitalRead(11);
int btn_ability = digitalRead(12);
int btn_reload = digitalRead(13);
int btn_sprint = digitalRead(PC13);
// Print everything cleanly to the black Serial Monitor box on the right
Serial.print("JOY1 [X: "); Serial.print(joy1_x);
Serial.print(" | Y: "); Serial.print(joy1_y);
Serial.print("] | JOY2 [X: "); Serial.print(joy2_x);
Serial.print(" | Y: "); Serial.print(joy2_y);
Serial.print("] | BUTTONS: ");
if (btn_jump == 0) Serial.print("[JUMP] ");
if (btn_crouch == 0) Serial.print("[CROUCH] ");
if (btn_ability == 0) Serial.print("[ABILITY] ");
if (btn_reload == 0) Serial.print("[RELOAD] ");
if (btn_sprint == 0) Serial.print("[SPRINT] ");
Serial.println(); // Move to a fresh line for the next sample
delay(1000); // Wait 100ms so the screen doesn't scroll faster than your eyes can read
}