//read an analog input and send the results out the serial port int led = 13;//create a variable to hold the pin the LED is connected to int pot = 0;//create a variable to hold the pin the potentiometer/sensor is connected to int analogVal = 0;//create a variable to hold the analog value read from the potentiometer/sensor int oldVal = 0;//create a variable to keep track of the last value read from the potentiometer/sensor void setup(){ pinMode(pot, INPUT);//set the pin the potentiometer/sensor is connected to Serial.begin(9600);//start serial communication at 9600baud startBlink();//call the startBlink function to blink an LED at the begining of the program } void loop(){ analogVal = analogRead(pot);//read the analog pin that the potentiometer/sensor is connected to and store the value in the analogValue variable analogVal /= 2; //divide the analogValue by 2 to get rid of any flutter on the last bit of the analogValue, this reduces the resolution, but creates a more steady reading if(analogVal != oldVal){//compare the current analodValue to the old analog value, if they are not equal(!=) then... Serial.println(analogVal);//send the analogValue out the serial port oldVal = analogVal;//set the old analog value equal to the current analog value } delay(10);//wait 10ms } void startBlink(){ pinMode(led, OUTPUT); for(int i = 0; i < 4; i++){ digitalWrite(led, HIGH); delay(250); digitalWrite(led, LOW); delay(250); } }