Pages: [1]   Go Down
Author Topic: Potentiometer with Seven Segment Problems  (Read 505 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

* pot1.txt (1.36 KB - downloaded 16 times.)
Logged

Santa Fe
Offline Offline
Full Member
***
Karma: 1
Posts: 201
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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);
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thank you
Logged

Pages: [1]   Go Up
Jump to: