Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

PIC014_source_file.

c 19/01/2018 17:52:35

1:
2: void nibbleDown(char number);
3: void nibbleUp(char number);
4:
5: char counter1 = 0, counter2 = 0;
6:
7: void main()
8: {
9: CMCON = 0x07;
10: TRISA = 0x00;
11: TRISB = 0x00;
12: PORTA = 0x00;
13: PORTB = 0x00;
14:
15: while(1)
16: {
17: counter1++;
18:
19:
20: nibbleDown(counter1);
21: nibbleUp(counter2);
22:
23: if(counter1 == 10)
24: {
25: counter2++;
26: counter1 = 0;
27: nibbleDown(counter1);
28: nibbleUp(counter2);
29: if(counter2 == 10)
30: {
31: counter2 = 0;
32: nibbleUp(counter2);
33: }
34: }
35:
36: delay_ms(300);
37:
38: }
39:
40: }
41:
42: void nibbleDown(char number)
43: {
44: switch(number)
45: {
46: case 0:
47: RB0_bit = 0x00;
48: RB1_bit = 0x00;
49: RB2_bit = 0x00;
50: RB3_bit = 0x00;
51: break;
52: case 1:
53: RB0_bit = 0x01;
54: RB1_bit = 0x00;
55: RB2_bit = 0x00;
56: RB3_bit = 0x00;
57: break;

1/4 mikroC PRO for PIC by mikroElektronika


PIC014_source_file.c 19/01/2018 17:52:35

58: case 2:
59: RB0_bit = 0x00;
60: RB1_bit = 0x01;
61: RB2_bit = 0x00;
62: RB3_bit = 0x00;
63: break;
64: case 3:
65: RB0_bit = 0x01;
66: RB1_bit = 0x01;
67: RB2_bit = 0x00;
68: RB3_bit = 0x00;
69: break;
70: case 4:
71: RB0_bit = 0x00;
72: RB1_bit = 0x00;
73: RB2_bit = 0x01;
74: RB3_bit = 0x00;
75: break;
76: case 5:
77: RB0_bit = 0x01;
78: RB1_bit = 0x00;
79: RB2_bit = 0x01;
80: RB3_bit = 0x00;
81: break;
82: case 6:
83: RB0_bit = 0x00;
84: RB1_bit = 0x01;
85: RB2_bit = 0x01;
86: RB3_bit = 0x00;
87: break;
88: case 7:
89: RB0_bit = 0x01;
90: RB1_bit = 0x01;
91: RB2_bit = 0x01;
92: RB3_bit = 0x00;
93: break;
94: case 8:
95: RB0_bit = 0x00;
96: RB1_bit = 0x00;
97: RB2_bit = 0x00;
98: RB3_bit = 0x01;
99: break;
100: case 9:
101: RB0_bit = 0x01;
102: RB1_bit = 0x00;
103: RB2_bit = 0x00;
104: RB3_bit = 0x01;
105: break;
106: } //end switch
107:
108: }
109:
110:
111: void nibbleUp(char number)
112: {
113: switch(number)
114: {

2/4 mikroC PRO for PIC by mikroElektronika


PIC014_source_file.c 19/01/2018 17:52:35

115: case 0:
116: RB4_bit = 0x00;
117: RB5_bit = 0x00;
118: RB6_bit = 0x00;
119: RB7_bit = 0x00;
120: break;
121: case 1:
122: RB4_bit = 0x01;
123: RB5_bit = 0x00;
124: RB6_bit = 0x00;
125: RB7_bit = 0x00;
126: break;
127: case 2:
128: RB4_bit = 0x00;
129: RB5_bit = 0x01;
130: RB6_bit = 0x00;
131: RB7_bit = 0x00;
132: break;
133: case 3:
134: RB4_bit = 0x01;
135: RB5_bit = 0x01;
136: RB6_bit = 0x00;
137: RB7_bit = 0x00;
138: break;
139: case 4:
140: RB4_bit = 0x00;
141: RB5_bit = 0x00;
142: RB6_bit = 0x01;
143: RB7_bit = 0x00;
144: break;
145: case 5:
146: RB4_bit = 0x01;
147: RB5_bit = 0x00;
148: RB6_bit = 0x01;
149: RB7_bit = 0x00;
150: break;
151: case 6:
152: RB4_bit = 0x00;
153: RB5_bit = 0x01;
154: RB6_bit = 0x01;
155: RB7_bit = 0x00;
156: break;
157: case 7:
158: RB4_bit = 0x01;
159: RB5_bit = 0x01;
160: RB6_bit = 0x01;
161: RB7_bit = 0x00;
162: break;
163: case 8:
164: RB4_bit = 0x00;
165: RB5_bit = 0x00;
166: RB6_bit = 0x00;
167: RB7_bit = 0x01;
168: break;
169: case 9:
170: RB4_bit = 0x01;
171: RB5_bit = 0x00;

3/4 mikroC PRO for PIC by mikroElektronika


PIC014_source_file.c 19/01/2018 17:52:35

172: RB6_bit = 0x00;


173: RB7_bit = 0x01;
174: break;
175: } //end switch
176:
177: }

4/4 mikroC PRO for PIC by mikroElektronika

You might also like