// Controller Arduino
// Reads two joysticks and sends throttle + steering data to car Arduino via Serial
const int throttlePin = A0; // Joystick 1 vertical (Throttle)
const int steeringPin = A1; // Joystick 2 horizontal (Steering)
void setup() {
Serial.begin(9600);
}
void loop() {
int throttleRaw = analogRead(throttlePin); // 0 to 1023
int steeringRaw = analogRead(steeringPin); // 0 to 1023
// Map to -100 to 100 (center ~512)
int throttleVal = map(throttleRaw, 0, 1023, -100, 100);
int steeringVal = map(steeringRaw, 0, 1023, -100, 100);
// Send formatted string
Serial.print("T:");
Serial.print(throttleVal);
Serial.print(";S:");
Serial.print(steeringVal);
Serial.println();
delay(100); // Send every 100 ms
}