/* potentiometer - output to LEDs written 24 July 2024 by James Khan for fab academy assignment embedded programming This example code is in the public domain. https://fabacademy.org/2021/labs/vancouver/students/james-khan/assignments/week06/ */ // define constants to match the pin layout that you are attaching your potentiometer. const int potentin = A3; const int led1 = 26; const int led2 = 0; const int led3 = 1; // setup our pins as inputs or outputs void setup() { // initialize analog potentin pin as an input. pinMode(potentin, INPUT); // initialize digital led pins as output. pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); } // the loop function runs over and over again forever // analog input is from 0 to 1023. 1000 translates to 1 second delay. void loop() { // read potentiometer value int readvalue = analogRead(potentin); // reset all leds to off digitalWrite(led1, LOW); digitalWrite(led2, LOW); digitalWrite(led3, LOW); if (readvalue < 350) { delay((readvalue)); digitalWrite(led1, HIGH); delay((readvalue)); } if (readvalue >= 350) { digitalWrite(led1, HIGH); delay(readvalue); digitalWrite(led2, HIGH); delay(readvalue); } }