Go Down

Topic: Potentiometer with Seven Segment Problems (Read 532 times) previous topic - next topic

Mahmoud899

Hello, I have been experimenting with the Analog Pins on the Arduino Uno. I connected a potentiometer and a seven segment. What I want to do is when I rotate the potentiometer the numbers on the seven segment increases. I have attached the code that I have typed. I was just testing with the numbers ONE and TWO on the seven segment and nothing happened when I compiled and uploaded the code. I need help.

Thank You

RPCoyle

The logic was  a little off, but it looks like it should work.  Put a longer delay between the states so you can see what is going on,


Code: [Select]

void loop()
{
buttonValue = analogRead(pot);
// the way you had it the code would always display "one"
if ( (buttonValue >= 0) && (buttonValue <= 127) )
{
                Serial.println("one");
one();
delay(300);
off();
delay(300);
}

else if ( (buttonValue >= 128) && (buttonValue <= 255) )
{
                Serial.println("two");
two();
delay(300);
off();
delay(300);


Serial.println(buttonValue);
}


Go Up