Go Down

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

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
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy