/////////////////////// Dual Analogue Sensors Part 2 #define sensor A1 #define sensor2 A0 //These will be used to command our helicopter programs. String xAxis, yAxis; //These will be stored sensor values for us to work with // to set those xAxis, yAxis messages up above. int s1, s2; void setup() { // put your setup code here, to run once: Serial.begin(9600); Serial.println("Begins"); //Default values for the direction string we are going to send to Processing xAxis = ""; yAxis = ""; //Default stored values, just in case a sensor isn't working, or something takes too long // and we need a value but don't have one. s1 = 0; s2 = 0; } void loop() { //Lets store the X direction values from the joystick. s1 = analogueGetValue(sensor); //We will add the yAxis control later. if(s1 < 400) xAxis = "LEFT"; else if(s1 > 700) xAxis = "RIGHT"; else xAxis = "CENTER"; //Send the command off to Processing for fun times! Serial.println(xAxis + yAxis); if(port == A4) //We can adjust this delay time to make our system more / less responsive delay(1000); } int analogueGetValue(int port){ int inputValue; pinMode(port, INPUT); inputValue = analogRead(port); pinMode(port, OUTPUT); return inputValue; }