alarm clock

Sparkfun Alarm Clock

Posted by admin on July 17, 2009
Arduino, Components & Materials / Comments Off

Sparkun are selling the following simple clock on their site: Link

ClockIT from Sparkfun

ClockIT from Sparkfun

This is a minimalistic clock that includes all the essential functions and is very similar to a product offered at Maplins in the UK that I have used before: Maplin link | My project which includes this module

There are two differences between the two clocks from Sparkfun and the Maplin. The first one is that the Sparkfun clock runs at 5V; the Maplin clock needs 9-18V (which then regulates down to 5 and generates quite a bit of useless heat in the process…). This for me, is a major design flaw! When I used it for this project, I had to power it from a USB port, which basically meant that I removed the voltage regulator and changed the wiring a bit to accommodate for the lower voltage.

The second difference is that the Sparkfun clock is based around the ATmega168 chip (i.e. the old Arduino chip). It would be nice if the code (provided by Sparkfun on their website) was in the Processing/Arduino language.

These are great modules to use for custom applications. Of course you can go down the I2C real clock module path and use something like this. The problem is that you add a whole new layer of complexity to your module. You need a way to display the time, controls to adjust the time, etc, etc… If you just need a basic alarm clock to flip a switch at a specific pre-defined time, just get one of these modules, replace the speaker with a transistor and you are sorted…

Anyway, enough about alarms :)

Tags: , , ,

My arduino clock…

Posted by admin on June 06, 2009
Arduino, examples / 3 Comments

I love automation in the office, as it elliminates the chance of human error and it gives us time to actually do other things, while giving the boring stuff to our faithful servants, the computers.

We used to have a very time-consuming task that had to be done every morning. It involved downloading a number of reports from various websites, converting them to pdf and merging the pdfs to two different pdf files. The whole process, when it was done manually, used to take approx 40 mins and we had to get it done first thing in the morning.

Using AutoHotKey, I wrote a script that downloads the reports for us every day. It takes the program approx 25 mins to run all the reports. We use one of our spare desktops to run the script, so that we can do other stuff while the autohotkey is working hard for us. For those not familiar with AutoHotKey: the best way to describe it is as a macro language for Windows.

That was a great improvement compared to the manual process, but I thought I could do better than this. This was when I started learning about the arduino board. My idea was as follows: what if I could create a little device with an alarm clock set at 8am every morning, that logs in to the computer and activates the autohotkey script?

I got an alarm clock kit from Maplins, a custom keyboard on a pcb from X-Keys and an arduino mini and I wired them in such a way that, at 8am the alarm clock goes, activates the arduino, the arduino shuts down the alarm clock and activates the custom keyboard; the custom keyboard then types the login and password to the desktop that’s attached to and activates the autohotkey script. By the time we get to the office, the reports are already downloaded and ready for us. Simple really!

Here is an image of the device. I mounted it on an acrylic photoframe from Muji.

My arduino clock

Some of you will say that I’m using a hammer to break an egg. Possibly… But please note that, for security reasons I was not allowed to leave the computer on and unlocked during the night and that the autohotkey actually needs the PC to be on and a user to be logged it (so I couldn’t run it as a service). Also, I know that some of you may be able to wire something like this up without the need of an arduino, but, I admit it, I don’t have a degree in electronic engineering and I am not planning on getting one in the near future! :) I was able to build and get this little device up and running within a few hours.

arduino_clock_2

In this example, my device only “wakes up” my machine, but, with very small modifications it could even start the PC (i.e. I could have wired it up in such a way that it actually shorts the pins that connect to the power button).

The most expensive part of this device was the custom keyboard, which (including delivery and import tax) cost me about £85.

One of the things I did manage to do was to remove the transistor from the alarm clock that was converting the voltage from the 9-18V to 4-6V. Then I was able to run it from the power provided by my usb port!

The arduino code was not really hard, just a modified version of the blink example!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
int alarmIn = 2;     // select the input pin for the alarm
int alarmOut = 9;    // select the output pin for the alarm
int keyboardOut = 8; // select the output pin for the keyboard
int greenLed = 13;   // Green LED connected to digital pin 13
int blueLed = 7;     // Green LED connected to digital pin 13
int val = 0; 
 
void setup()                    // run once, when the sketch starts
{
  pinMode(alarmIn, INPUT);     
  pinMode(greenLed, OUTPUT);      // sets the digital pin as output
  pinMode(blueLed, OUTPUT);      // sets the digital pin as output
  pinMode(alarmOut, OUTPUT);      // sets the digital pin as output
  pinMode(keyboardOut, OUTPUT);      // sets the digital pin as output
 
  Serial.begin(9600);      // open the serial port at 9600 bps:  
}
 
void loop()                     // run over and over again
{
 val = analogRead(alarmIn);    // read the value from the alarm
 
  if (val>200){
  delay(1000);                    // waits for a bit
  digitalWrite(greenLed, HIGH);   // sets the LED on
  delay(500);                     // waits for a bit
  digitalWrite(greenLed, LOW);    // sets the LED off
  }
 
  if (val<200){
     digitalWrite(blueLed, HIGH);       
     digitalWrite(alarmOut, HIGH); 
     delay(2000);                  // waits for a bit    
     digitalWrite(blueLed, LOW);  
     digitalWrite(alarmOut, LOW); 
     delay(500);                  // waits for a bit      
     digitalWrite(keyboardOut, HIGH); 
     delay(500);                  // waits for a bit    
     digitalWrite(keyboardOut, LOW);  
     delay(1000);                  // waits for a bit more     
 
  }
 
// for Debuging purposes... 
 Serial.print("Value on Pin2: ");  
 Serial.println(val);  
 
}

Needless to say that I had not added the buzzer on the alarm clock pcb. As you can see on the code, I was using analog in from the buzzer to Pin 2.

This device is, I think, a perfect example of what Arduino is meant to be used for, i.e. helping people creating simple solutions to everyday problems. The program on the Arduino is very straight forward and underlines the fact that sometimes solutions can be easier than previously thought…

Tags: ,