void setup() {
// put your setup code here, to run once:
volatile char *dir;
dir=0x30;
*dir=0xff;
dir=0x107;
*dir=0xff;
}
void loop() {
// put your main code here, to run repeatedly:
volatile char *out,*seg;
out=0x31; seg=0x108;
//(1st digit, 10's place)
*seg=0xff;
*out=0x76;
*seg=0x0e;
for(volatile long i=0;i<1000;i++);
//(2nd digit, 1's place)
*seg=0xff;
*out=0x06;
*seg=0x0d;
for(volatile long i=0;i<1000;i++);
}
// we are doing this because, we know that the LED blink at very fast rate
//that humans eye cant see their blinking. And, if we set the values as we used to do(i.e., without turning off the segment, continously changing values)
// Code:
//*seg=0x0e;
//*out=0x06;
//*seg=0x0d;
//*out=0x3f;--> In this code, what happens is that, the second value gets printed continously, because the LED blinks cant be seen by human and also, after making the
//output as 0x3f(which is "0"), we are again turning on the segment bit, but still as the output value is still in there, the value 0 is getting printed(I mean it not actually),
//but our human eyes thinks that it is printing the value 0.
//In order to avoid it, what we are doing is, we first turn off the segment and set the value, and then turn on the required segment, by doing this we have changed the value
//properly, and also before turning on the segment, we have set the necessary value. And as the microprocessor has very high speed, it looks like there was not any delay.