I am using this method
I am able to display any 2 digit numbers..
But unable to make a count down or a count up..
Please help me with the code
Here is my code that I have written
int no[]={ B10000000, //0
B11110010, //1
B01001000, //2
B01100000, //3
B00110010, //4
B00100100, //5
B00000100, //6
B11110000, //7
B00000000, //8
B00100000,};//9
int Display = 29;
void setup(){
DDRD=0xFF;
DDRB=0xFF;
}
void loop(){
int digit_1 = Display/10;
int digit_2 = Display%10;
PORTD=no[digit_1];
PORTB=B000010;//left digit
delay(1);
PORTD=no[digit_2];
PORTB=B000001;//right digit
delay(1);
}
Arrch
August 7, 2013, 3:48pm
2
Joy:
Here is my code that I have written
http://img508.imageshack.us/img508/2029/7seg.jpg
That doesn't look like very complete code...
system
August 7, 2013, 3:59pm
3
If you can show any 2 digit number, I don't see what the problem is. If you want it to count up or down, you just have to add more code/logic for that.
Arrch
August 7, 2013, 4:02pm
4
Joy:
But unable to make a count down or a count up..
Because you are not changing the value in variable Display. That value needs to be incremented or decremented based on some conditions in order for it to count up or down.
I tried a for loop for increment of i and showed Display = i
this is not working..
because I am unable to set the rate at which the increments will occur..
Please help me..
system
August 7, 2013, 4:12pm
6
See the following example on how to delay (without using the delay() function), this will help you set the rate at which they change.
Arrch
August 7, 2013, 4:21pm
7
Joy:
I tried a for loop for increment of i and showed Display = i
this is not working..
That's not what your code indicates. If you have code that isn't working, show that code, so we can correct the mistakes.
because I am unable to set the rate at which the increments will occur..
So add a delay() call within your for loop.