How to work with BCD(binary-coded decimal) switch?: Unterschied zwischen den Versionen
Zeile 97: | Zeile 97: | ||
== How to read the BCD switch with an Arduino and a shift register? == | == How to read the BCD switch with an Arduino and a shift register? == | ||
[[Datei:BCD_One_Switch.png|200px|thumb|left|one row of switches resambles one BCD Switch]] | |||
== How to connect multiple BCD switches? == | == How to connect multiple BCD switches? == | ||
[[Datei:BCD_2_switches.png|200px|thumb|left|two switches]] | [[Datei:BCD_2_switches.png|200px|thumb|left|two switches]] | ||
[[Datei:BCD_4_switches.png|200px|thumb|right|four switches with two registers]] | [[Datei:BCD_4_switches.png|200px|thumb|right|four switches with two registers]] |
Version vom 6. März 2021, 22:45 Uhr
--entry is still in work--
How does it work?
A BCD-Switch is actually not one switch, it contains basically four switching circuit at once. There is a wheel which closes depending on the number the switch shows in the front. The picture on the right are 5 BCD switches stacked sideways together. The four switches translating the number into its binary form. So if you see a 5 in the front the second and the fourth switch are on and resembling the one the others are off and resembling the zero. Because 5 in binary is 0101. The tricky part is that you read binary from left to right in computing because you have the most significant bit always on the left side. So the rightest bit stands for 2 to the power of zero which is 1 if it is 1 if it is zero its value will not be counted so it is zero. So the fourth switch determines the least significant bit. So I will now give you a table so you don't have to remember and calculate.
BCD Switch | |||||
---|---|---|---|---|---|
Number in Front | BitArray | Switch 1 | Switch 2 | Switch 3 | Switch 4 |
1 | 0001 | off | off | off | on |
2 | 0010 | off | off | on | off |
3 | 0011 | off | off | on | on |
4 | 0100 | off | on | off | off |
5 | 0101 | off | on | off | on |
6 | 0110 | off | on | on | off |
7 | 0111 | off | on | on | on |
8 | 1000 | on | off | off | off |
9 | 1001 | on | off | off | on |
0 | 0000 | off | off | off | off |
What will you need?
- an Arduino (every typ will do)
- a BCD-Switch
- a shift register (CD4021)
- jumperwires
- a breadboard
How to connect a shift register with an Arduino?
Shift registers are a common piece of electronic and it combines transistors in that way that you could survey eight input pins in that way that one shift register sends a so called bit array of eight bits called a byte. So if you receive a bit array looking like this [0,0,1,0,1,0,0,0] it means you have an input voltage on pin 4 and pin 6. So switch 4 and 6 are on and all others are off. One BCD switch contains 4 switches so one shift register could match two switches. Luckily the BCD switch transforms the numbers as described earlier in four binary bits.