/***************************** * Getting max analog values * * @author Florent Lemaire * *****************************/ // define the analog sensor interface int xPin = A3; int yPin = A4; int button = 3; FILE serial_stdout; //for quicker stdout instead of many serial.print and println // Function that printf and related will use to print int serial_putchar(char c, FILE* f) { if (c == '\n') serial_putchar('\r', f); return Serial.write(c) == 1? 0 : 1; } void setup () { Serial.begin(9600); // initialize serial communication at 9600 bits per second: // define inputs pinMode (xPin, INPUT); pinMode (yPin, INPUT); pinMode (button, INPUT); // Set up stdout fdev_setup_stream(&serial_stdout, serial_putchar, NULL, _FDEV_SETUP_WRITE); stdout = &serial_stdout; } void loop () { delay(20); printf("X: %d, Y: %d, Button pressed: %s\n", analogRead(xPin), analogRead(yPin), digitalRead(button)? "YES" : "NO"); }