/* Hack modified from arduino analog input example. Reads analog input on input A0, prints value to serial port and turns LED on and off based on value. */ int sensorPin=A0; int sensorValue=0; int ledPin=13; // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); pinMode(ledPin, OUTPUT); } // the loop routine runs over and over again forever: void loop() { // read the input pin: sensorValue = analogRead(sensorPin); // print out the state of the input: Serial.println(sensorValue); if (sensorValue > 500) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } delay(1); // delay in between reads for stability }