Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ulrichzwingli/6760d2b63ac5467393e1e726a53aec1f to your computer and use it in GitHub Desktop.
Save ulrichzwingli/6760d2b63ac5467393e1e726a53aec1f to your computer and use it in GitHub Desktop.
Potentiometer variable resistance lighting up LEDs
int analog_range;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
analog_range = analogRead(A0);
Serial.println(analog_range);
if (analog_range<=512) {
digitalWrite(8, HIGH);
digitalWrite(13, LOW);
}
else
{
digitalWrite(8, LOW);
digitalWrite(13, HIGH);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment