/* potentiometer - output to LEDs Written 1 February 2025 by James Khan for fab academy assignment embedded programming 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 led3 = 1; // setup our pins as inputs or outputs void setup() { // initialize analog potentin pin as an input. pinMode(potentin, INPUT); // setup serial monitor. Serial.begin(9600); // initialize digital led pins as output. pinMode(led1, 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); // send potentiometer reading to the serial monitor Serial.println(readvalue); // reset LEDs to off digitalWrite(led1, LOW); digitalWrite(led3, LOW); // leave the LEDs off using the readvalue as the delay delay((readvalue)); // turn on the LEDs then leave them on using the readvalue as the delay digitalWrite(led1, HIGH); digitalWrite(led3, HIGH); delay((readvalue)); }