![design](https://cnrdavenport.wordpress.com/wp-content/uploads/2017/05/design.png?w=656)
One major change to the circuit I made was the layout of the “minute” LED’s (D1-D6). The first prototype was designed so that the LED driven by P1.0 was the right-most LED of the “minute” array. This choice was made so that when the minutes are pushed onto Port 1, the least significant bit (P1.0) would drive the least significant LED. This resulted in a rat’s nest of wires on the board (the green wires below).
On the final design I chose not to have a mess of traces so now P1.0 will be driving the left-most LED. In order for the watch to still be readable, the least significant bit will still need to be represented by the right-most LED, the current version of the code doesn’t facilitate this.
Below is the new code written for the final watch design.
void printTime(int h, int m) //h - hours m - minutes { /* minutes must be flipped around eg. 101110 becomes 011101 below code does this */ m = (m & 0x15) << 1 | (m & 0x2A) >> 1; m = (m & 0x03) << 4 | (m & 0x0C) >> 0 | (m & 0x30) >> 4;
These new lines in the printTime function reverse the order of the bits in int m (minutes) so now when the minutes are equal to 1 (0b000001 in binary), the bits are flipped and 0b100000 is pushed onto Port 1. P1.5 goes high and the least significant LED turns on.
These lines are explained below.
One thought on “Binary Watch: Important Code Updates”