//This is a sketch to turn on an led attached to in 13
//once a potentiometer gets to a certain level
const byte ledPin = 13; //led attached to pin 13
const byte potPin = A0; //potentiometer attached to pin A0
void setup()
{
pinMode(ledPin,OUTPUT); //led is an output
Serial.begin(9600); // initialise serial port
}
void loop()
{
int potRead = analogRead(potPin); //read input from potentiometer
int potValue = potRead / 4; //convert input from potentiometer value between 0 and 255
digitalWrite(ledPin, potValue >= 125 ? HIGH : LOW);
Serial.println(potValue); //print the value of the potentiometer on a new line
}
I have not compiled nor run this code.