-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCD4511.cpp
95 lines (84 loc) · 1.7 KB
/
CD4511.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*********************************************************************
This is an example sketch for a BCD driver.
The driver uses four pins to comunnicate with the Arduino.
Written by Amaf14.
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "CD4511.h"
CD4511::CD4511(int A, int B, int C, int D, int D1, int nr)
{
_A= A;
_B= B;
_C= C;
_D= D;
_D1= D1;//D1 is the first digit chatode
_nr= nr;//nr is the total number of digits
}
//for a single digit
/*CD4511::CD4511(int A, int B, int C, int D, int D1)
{
_A= A;
_B= B;
_C= C;
_D= D;
_D1= D1;
}*/
void CD4511::start()
{
pinMode(_A, OUTPUT);
pinMode(_B, OUTPUT);
pinMode(_C, OUTPUT);
pinMode(_D, OUTPUT);
j=0;
for(i=_D1;i<=_D1+_nr-1;i++)
{
g[j]=i;
pinMode(g[j], OUTPUT);
digitalWrite(g[j], HIGH);
j++;
}
}
void CD4511::cleardisplay()
{
for(i=_D1;i<=_D1+_nr-1;i++)
digitalWrite(g[j], HIGH);
}
void CD4511::display(long p, int poz)
{
digitalWrite(_A, p/1000%10);
digitalWrite(_B, p/100%10);
digitalWrite(_C, p/10%10);
digitalWrite(_D, p%10);
digitalWrite(g[poz], 0);
delay(3);
}
//not done yet
void CD4511::test()
{
delay(100);
}
//should be a binary converter
//not working yet for some reason
int CD4511::tobin(int i)
{
int j=1000;
long p=90000;
while(i!=0)
{
p+=x%2*j;
j/=10;
i/=2;
}
return p;
}
//not working again
void CD4511::binlist()
{
_v[]={90000, 91000, 90100, 91100, 90010, 91010, 90110, 91110, 90001, 91001};
}