1
2int a = 5;
3int b = 4;
4int c = 3;
5int d = 2;
6
7int a1 = 6;
8int b1 = 7;
9int c1 = 8;
10int d1 = 9;
11
12int LED = 13;
13int Reset=10;
14int Pause=11;
15int startled=12;
16int analogPin = 1;
17void setup() {
18 pinMode(a, OUTPUT);
19 pinMode(b, OUTPUT);
20 pinMode(c, OUTPUT);
21 pinMode(d, OUTPUT);
22
23 pinMode(a1, OUTPUT);
24 pinMode(b1, OUTPUT);
25 pinMode(c1, OUTPUT);
26 pinMode(d1, OUTPUT);
27
28 pinMode(LED, OUTPUT);
29 pinMode(Reset, INPUT);
30 pinMode(Pause, INPUT);
31 pinMode(startled, INPUT);
32 Serial.begin(9600);
33
34 digitalWrite(startled,LOW);
35}
36int conpin[]={a,b,c,d};
37int conpin1[]={a1,b1,c1,d1};
38byte digitnum[]={B0000,B0001,B0010,B0011,B0100,B0101,B0110,B0111,B1000,B1001};
39int firstdigit=0;
40int seconddigit=0;
41
42float NewValue=5,OldValue=0,OldMin=01,NewMax=99,NewMin=01,OldMax=1015;
43
44void loop() {
45int val = analogRead(analogPin);
46
47OldValue=val;
48
49NewValue = round(((OldValue) /1014) * 99);
50if(NewValue>99)
51{
52 NewValue=99;
53 }
54int nval=NewValue;
55Serial.println(nval);
56
57seconddigit=nval%10;
58firstdigit=nval/10;
59digitalWrite(startled,LOW);
60
61
62Serial.println("Start Button");
63Serial.println(digitalRead(startled));
64
65 for (int j = 0; j <4; j++)
66 {
67 digitalWrite(conpin[j],bitRead(digitnum[firstdigit],j));
68 digitalWrite(conpin1[j],bitRead(digitnum[seconddigit],j));
69 }
70digitalWrite(LED,LOW);
71digitalWrite(Reset,HIGH);
72if(digitalRead(startled)==0)
73{
74digitalWrite(LED,HIGH);
75digitalWrite(Reset,LOW);
76for(int i=nval;i>=0;i--)
77{
78
79 digitalWrite(LED,HIGH);
80 seconddigit=i%10;
81 firstdigit=i/10;
82 Serial.println("Counter Value:=");
83 Serial.println(i);
84
85 Serial.println(firstdigit);
86 Serial.println("seconddigit:=");
87 Serial.println(seconddigit);
88 for (int j = 0; j <4; j++)
89 {
90 digitalWrite(conpin[j],bitRead(digitnum[firstdigit],j));
91 digitalWrite(conpin1[j],bitRead(digitnum[seconddigit],j));
92 }
93if(digitalRead(Pause)==0)
94{
95 digitalWrite(LED,LOW);
96 delay(15000);
97}
98if(digitalRead(Reset)==0)
99{
100 break;
101 }
102 delay(1000);
103 }
104}
105 delay(1000);
106}