I've been covering "block" ie "building blocks" for a while.
Now let's take a few Arduino building blocks and make a useful thing out of them. I want an alarm clock with all the features I like, and I can't buy it. All the clocks I've ever bought have shortcomings. The most irritating one is that they take a 9v battery for power failure backup, which should be able to run an RTC chip until the next ice age, but somehow they last about 2 months then die.
I would like it to be able to run during power failures (with the display off, or perhaps on demand), wake to alarm during those times. I also want an outdoor temperature sensor. Wireless would be super cool, if I can work out the power.
I also like the phone apps that start out the alarm quiet and it gets slowly louder. I'd like to incorporate that.
Recently I got some Arduino Uno clones for < $4 each. I also picked up some waterproof digital temperature sensors, and some little 4 digit displays that use the same driver chip as the 8 digit + switches display that we played with earlier.
The chip reads TM1637. The first Google result from that is on Arduino Playground and gives a library for driving it. Here's the Github link referenced in that article:
https://github.com/avishorp/TM1637
From that page, click "Download ZIP" and save the file. Start up Arduino and hit Sketch/Include Library/Add ZIP library. Now you can hit File/Examples/TM1637-master/TM1637Test.
If you look at the code, you'll see that it says that CLK should be wired to I/O pin 2 and DIO to pin 3. Gnd and VCC should be wired to gnd and +5V. Wire it up, upload the sketch and you should see the demo working:
Now, I have a little "real time clock" module. What that means is that I have a module that's essentially a watch with no display that can interface to the Arduino.
It says "Tiny RTC". A little googling reveals that it appears to use a DS1307 real time clock chip.
Turns out that there's a lib for the DS1307 already loaded in Arduino. Go to File/Examples and find and load the DS1307 sample code.
A quick Google indicates that SDA should go to pin 4 and SCL to pin 5.
To set the time, you would uncomment this line in Setup and fix the values to the current date/time:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
Compile and upload the code, and start the serial monitor at 57600 baud as indicated in the code.
You'll get output like this:
2015/10/2 22:39:11 since midnight 1/1/1970 = 1443825551s = 16710d now + 7d + 30s: 2015/10/9 22:39:41
Now we have a basic start on a clock.
By combining lines from the two example sketches, we can get a clock display that works.
// John Ridley Oct 2 2015// nifty bedside alarm clock// totally not a bomb.
//////////////////////////////////////////////////////////// stuff for RTC DS1307 chip#include
Now let's take a few Arduino building blocks and make a useful thing out of them. I want an alarm clock with all the features I like, and I can't buy it. All the clocks I've ever bought have shortcomings. The most irritating one is that they take a 9v battery for power failure backup, which should be able to run an RTC chip until the next ice age, but somehow they last about 2 months then die.
I would like it to be able to run during power failures (with the display off, or perhaps on demand), wake to alarm during those times. I also want an outdoor temperature sensor. Wireless would be super cool, if I can work out the power.
I also like the phone apps that start out the alarm quiet and it gets slowly louder. I'd like to incorporate that.
Recently I got some Arduino Uno clones for < $4 each. I also picked up some waterproof digital temperature sensors, and some little 4 digit displays that use the same driver chip as the 8 digit + switches display that we played with earlier.
The chip reads TM1637. The first Google result from that is on Arduino Playground and gives a library for driving it. Here's the Github link referenced in that article:
https://github.com/avishorp/TM1637
From that page, click "Download ZIP" and save the file. Start up Arduino and hit Sketch/Include Library/Add ZIP library. Now you can hit File/Examples/TM1637-master/TM1637Test.
If you look at the code, you'll see that it says that CLK should be wired to I/O pin 2 and DIO to pin 3. Gnd and VCC should be wired to gnd and +5V. Wire it up, upload the sketch and you should see the demo working:
Now, I have a little "real time clock" module. What that means is that I have a module that's essentially a watch with no display that can interface to the Arduino.
It says "Tiny RTC". A little googling reveals that it appears to use a DS1307 real time clock chip.
Turns out that there's a lib for the DS1307 already loaded in Arduino. Go to File/Examples and find and load the DS1307 sample code.
A quick Google indicates that SDA should go to pin 4 and SCL to pin 5.
To set the time, you would uncomment this line in Setup and fix the values to the current date/time:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
Compile and upload the code, and start the serial monitor at 57600 baud as indicated in the code.
You'll get output like this:
2015/10/2 22:39:11 since midnight 1/1/1970 = 1443825551s = 16710d now + 7d + 30s: 2015/10/9 22:39:41
Now we have a basic start on a clock.
By combining lines from the two example sketches, we can get a clock display that works.
// John Ridley Oct 2 2015// nifty bedside alarm clock// totally not a bomb.
//////////////////////////////////////////////////////////// stuff for RTC DS1307 chip#include