It is pretty natural to start playing with interrupts as we write program for the clock. There are 3 (in UNO, other boards have different number) internal timer based interrupts. Timer0 and Timer2 are based on 8 bits counters, so I decided to use Timer1 here with 16 bits. The prescaler set to 64 and match register to 2499 did the trick (one could use as well 256;624 or 8;19999 pairs for Timer1 looking for 100Hz refresh).
The next step after testing if it works at all was to display ful time, and especially seconds. So 4 digits offered by TM1637 based module (let’s call it part I) was not enough. I used 8 digits 7 segment display based on MAX7219.
For the code, apart from DS3231 library mentioned in previous post, I used also Eberhard Fahle LedControl library.
A display and buttons shield (but BTW: have you checked other Displays on this site?) well suited as the human interface for a number of “compact design standalone” projects.
Similar to already described 16×2 LCD module (using the same display), but with 6 built into the shield buttons (RESET, SELECT; and 4 directions: LEFT, UP, DOWN, RIGHT).
The shield leaves a lot of pins at your disposal. Used pins are only:
|Analog 0||Button (select, up, right, down and left – see the code comments)|
|Digital 4 – 7||DB4 – DB7|
|Digital 8||RS (Data or Signal Display Selection)|
|Digital 10||Backlit Control|
So the user has free access to Analog 1-5, and Digital 0-3 and 11-13. Out of these, the most important are 0 and 1, which can be used as RX and TX, 3 and 11 with are PWM capable, as well as standard LED 🙂 output on digital pin 13.
Also whole ISCP connector, which is normally blocked by the shield body is repeated on the side.
13.56MHz RFID reader RC522 with optional LCD 16×02 (1602) module and dual color diode connected.
Basic setup with just UNO and reader connected – see below. The code for such case with reading tags and using Serial output could be located in AddicoreRFID library.
Basic setup to test HMC5883 on GY-273
Just connect: GND, VCC (5V), SCL and SDA (I2C standard signals) to your Arduino. Older versions could use A4 for SDA and A5 for SCL, but with most up-to-date boards appropriate dedicated pins (see green and purple connection lines) could be used,
And another image with shorter connectors: Continue reading HMC5883 GY-273 test