From the previous project we have seen how to blink LED (white colour). This project post will demonstrate how to flash the on board LED colour combinations without much math.
So the LED is connected as follows.
- RED → PF1
- BLUE → PF2
- GREEN → PF3
Therefore to display red we need to output 0x02, here '2' because PF0 is not being used. Similarly to display purple/violet → 0x06, blue → 0x04, aqua blue/ greenish blue → 0x0c, green → 0x08, yellow → 0x09, white → 0x0e and none → 0.
Now lets focus on the sequence: 0, R, RG, G, GB, B, RB, RGB.
For the above mentioned sequence the system states are as follows: Here the states are addressed as D2D1D0 and the next state as O2O1O0
Present State Next State Output
000 001 000
001 101 001
101 100 101
100 110 100
110 010 110
010 011 010
011 111 011
111 000 111
Lets find the combination for output bit O0 in terms of D2D1D0, for the above drawn table lets make the KMap (3-variable). After Drawing the chart we get,
O0=~D2
Similarly repeat the above steps for O1 and O2. We get,
O1=~D2D1+D2~D0
O2=~D2D0+D2~D1
Now to implement this algorithm in program we need a include file or header file which extracts bits, as it is tedious to repeat the masking procedure multiple times. Click here to view the file.
Can you explain the K-map of this process? I cannot seem to understand the logic behind it.
ReplyDeleteI keep getting: O1 = ~D0.~D1 + D1.D2 O2 = ~D1.~D2 + D0.D2