I want to make it so the Potentiometer controls the blink speed and not the Led level how do i do that?

*/

 int greenLed = 9; // set pin 9 to a variable 
 int yellowLed = 10; // set pin 10 to a variable 
 int redLed = 11; // set pin 11 to a variable 
 int buttonA = 4; // set pin 4 to a variable 
 int buttonB = 2; // set pin 2 to a variable
 int potPin = A0; // set pin A0 to a variable
 int potSensorValue = 0; // ADC Read Value
 int ledLevel = 255; // LED Brightnes 

 void setup ()
 {  
   pinMode (greenLed, OUTPUT); // set Green LED pin to output 
   pinMode (yellowLed, OUTPUT); // set yellow LED pin to output
   pinMode (redLed, OUTPUT); // set red LED pin to output
   pinMode (buttonA, INPUT_PULLUP); // set buttoA to pullup input 
   pinMode (buttonB, INPUT_PULLUP); // set buttonB to pullup input
   pinMode (potPin, INPUT); // set A0 to input 
}

void loop()
{
  
  
  potSensorValue = analogRead(potPin);
  ledLevel = map(potSensorValue, 0, 0123, 0, 255);

  
  analogWrite(greenLed, ledLevel); // Turn on Green LED Dim setting
  delay(1000); // wait for 1000 millisecond(s) 
  analogWrite(yellowLed, ledLevel); // Turn on Yellow LED Full brightnes setting
  delay(1000); // wait for 1000 millisecond(s)
  analogWrite(redLed, ledLevel); // Turn on Red LED Med setting
  delay(1000); // wait for 1000 millisecond(s)
  digitalWrite(greenLed, LOW); // Turn off Green LED
  delay(1000); // wait for 1000 millisecond(s)
  digitalWrite(yellowLed, LOW); // Turn off Yellow LED
  delay(1000); // wait for 1000 millisecond(s)
  digitalWrite(redLed, LOW); // Turn off Red LED
  delay(1000); // wait for 1000 millisecond(s)
}

Use map just like you did there to map the pot reading to your min and max intervals (except you probably meant 1023 not 0123).

To make it NOT control the LED level, change this line to:

  ledLevel = 255;

(Or whatever fixed value your want for your level.)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.