Introduction: Arduino Alarm Clock Canvas-- How To

Materials you will need:

1. Canvas (any size)
2. Fabric (enough to cover the canvas)
3. Velcro
4. 8-10 LED Lights
5. Conductive thread
6. Thread
7. 1 Lilypad Simple Snap board (you could choose to use other Lilypad boards as well)
8. 1 Lilypad Speaker/Buzzer
9. 3-5 conductive materials to be used as sensors (I used 3 cookie cutters)
10. Any decorative materials (Extra)
11. Needles
12. Scissors
13. Fabric Glue
14. White colored pencil

Instructions on how to assemble your Arduino Alarm Clock

** When using conductive thread never cross lines of stitching. Always stitch small, close, and tight stitches. Loop around metal holes in the Lilypad Simple Snap, and other Lilypad Materials. Cut ends as close to the knot as possible to keep tails of the thread from touching other conductive tails.**

**Negative lines are ground, and can touch when all negatives are sewed to the sample hole. All positive lines cannot cross, or be connected to the same holes. Each positive line needs it own number hole on the Lilypad Simple Snap.**

1. Attach the Lilypad Simple Snap board to your fabric using fabric glue. Put one dot of glue in the middle back of your Lilypad and press onto fabric. I chose to attach mine in the middle of the fabric on the back side so it can’t be seen.

2. Position the Lilypad Speaker close to your Lilypad Simple Snap board. Then use the conductive thread to sew through the negative hole on the speaker. Loop around the negative hole multiple times to keep conductivity strong. Then use close and tight stitches to stitch down to the negative hole on the Lilypad Simple Snap. Sew through the Lilypad Simple Snap negative hole multiple times, then tie off the line, and cut the extra. I chose to attach mine close up above the lilypad on the backside of the fabric so it would not be seen.

3. With a new line of conductive thread stitch from the positive end of the speaker to the 5 hole on the Lilypad Simple Snap. Following the same conductive thread rules as the step before.

4. Mark with a white colored pencil where you want your LED lights to go. Position LEDs a couple inches apart. I did a row of 10 on the very top of the fabric.

5. Position the LED lights straight up and down with all the negative ends facing down, and all the positive ends facing up.

6. Take a new line of conductive thread and start sewing on the first LED light on the far left side. Start with the negatives, do a line connecting all the LED negative ends. After all the negative ends have been sewed onto the fabric stitch down to the Lilypad Simple Snap, and connect the negative LED light line to the negative hole on the board.

7. Now with a new line of conductive thread start from the far right side to attach all the positive ends of the LED lights. Start on the farthest right and stitch until they are all connected with conductive thread. Then stich down to the LilyPad Simple Snap and connect the positive line to hole 9 on the LilyPad Simple Snap.

8. Now test your lights and speaker to make sure they are working properly. If they are proceed onto attaching your sensors. If not problem solve to figure out the problem. You may need to re-sew.

9. Then choose random areas on the lower half of the canvas where you want your sensors to be placed. Mark with the white colored pencil.

10. Sew sensors onto the fabric using conductive thread, and connect them up to the Lilypad Simple Snap board. Each sensor should be attached to their own number hole on the board.

11. I used 10 for one sensor1, 11 for sensor2, and A2 for sensor3.

12. Now sew on the triple A battery holder in a convenient place using conductive thread. I chose above the Lilypad Simple Snap. Connect the 3 negative holes on the battery holder together, and sew down to the negative hole on the Lilypad Simple Snap Board.

13. Then connect the positive hole on the battery holder to the positive hole on the Lilypad Simple Snap using conductive thread. The triple A battery holder will make it so you can run your clock all day without being plugged into a computer. It will also allow the Lilypad Simple Snap to keep accurate time all day.

14. Program your Lilypad Simple Snap board to have your alarm clock go off at the desired times with the lights on, and speaker on. I programmed my Lilypad Simple Snap to turn off the lights and buzzer once all 3 sensors have been touched. This forces me to get out of bed and turn off the alarm clock, without snoozing.

15. Test your code.

16. Attach Velcro around canvas edges and fabric edges so you can pull your fabric alarm clock off and on the canvas to easily reprogram the computer.

17. Hang your alarm clock on the wall.

18. Enjoy!

Common problems you might face:

1. Keeping conductive lines tight, closely stitched, and not crossing lines. Always sew through number holes, and positive negative holes multiple times.
2. Verifying conductivity of sensors.
3. Always diagram your project, so you can have a drawing to follow. It makes it so much easier to craft, and make sure your lines don't cross!
4. Keeping negative and positive ends all facing the same way on like materials.
5. Normal thread does not interfere with conductive thread, so use normal thread if you need to sew on patches.
6. Cut all ends of threads as close as possible to the knot, so they do not cause short circuits.
7. Always double check your code, you might be missing something simple like a semicolon. Sometimes it helps having a fresh pair of eyes looking at your code to find the little mistake you are missing.
8. Use other tutorials, and people as resources!


First visit the Ardunio Playground to read over the Time Library. Download the Time zip from this website:

Then click the TimeAlarms link on the website above, read over that page, and download the Time Alarm zip:

This will have the code you need to set up the alarm. It just needs slight editing.

You will need to add your sensors, lights, speaker, and capacitative pin read information to get the alarm to work how we want it to. 

Here is my final code:


int speakerPin = 5;
int lights = 9;
int sensorPin1 = 10;
int sensorPin2 = 11;
int sensorPin3 = A2;
int sensorValue;
int sensorValue2;
int sensorValue3;

void setup()

  pinMode(sensorPin1, INPUT);
  pinMode(sensorPin2, INPUT);
  pinMode(sensorPin3, INPUT);
  pinMode(lights, OUTPUT);
  pinMode(speakerPin, OUTPUT);

setTime(15,35,0,4,23,13); // sets the time to Tuesday 3:35:00pm April 23 2013

  Alarm.alarmRepeat(7,30,0, MorningAlarm);  // 7:30am every day
  Alarm.alarmRepeat(15,36,0, TestAlarm);

  //Alarm.timerRepeat(15, Repeats);            // timer for every 15 seconds   
  //Alarm.timerOnce(10, OnceOnly);             // called once after 10 seconds

void  loop(){ 
  digitalClockDisplay(); // as long as the battery is one, it will keep time like a clock
  Alarm.delay(1000); // wait one second between clock display

// functions to be called when an alarm triggers:

void MorningAlarm(){
  boolean alarm_on=true; // Trigger alarm on
  boolean sensor1_touched=false;
  boolean sensor2_touched=false;
  boolean sensor3_touched=false;

  digitalWrite (lights, HIGH); //Lights turn on
  while (alarm_on==true){

    tone(speakerPin, 1046, 100); //Speaker sounds
    sensorValue = readCapacitivePin(sensorPin1); //read the touch of sensor 1
    sensorValue2 = readCapacitivePin(sensorPin2); //read the touch of sensor 2
    sensorValue3 = readCapacitivePin(sensorPin3); //read the touch of sensor 3
    if (sensorValue > 1) sensor1_touched=true; //must touch all 3 to turn off, touch 1
    if (sensorValue2 > 1) sensor2_touched=true; // touch 2
    if (sensorValue3 > 1) sensor3_touched=true; // touch 3

    if ((sensor1_touched==true)&&(sensor2_touched==true)&&(sensor3_touched==true)) {
       alarm_on=false; //once all sensors have been touched speaker stops sounding
  digitalWrite (lights, LOW);  //once all sensors have been touched lights turn off

void TestAlarm(){
  boolean alarm_on=true;
  boolean sensor1_touched=false;
  boolean sensor2_touched=false;
  boolean sensor3_touched=false;

  digitalWrite (lights, HIGH);
  while (alarm_on==true){

    tone(speakerPin, 1046, 100);
    sensorValue = readCapacitivePin(sensorPin1);
    sensorValue2 = readCapacitivePin(sensorPin2); //read the touch sensor value
    sensorValue3 = readCapacitivePin(sensorPin3);
    if (sensorValue > 1) sensor1_touched=true;
    if (sensorValue2 > 1) sensor2_touched=true;
    if (sensorValue3 > 1) sensor3_touched=true;

     if ((sensor1_touched==true)&&(sensor2_touched==true)&&(sensor3_touched==true)) {
    digitalWrite (lights, LOW); 

void WeeklyAlarm(){
  Serial.println("Alarm: - its Monday Morning");     

void ExplicitAlarm(){
  Serial.println("Alarm: - this triggers only at the given date and time");      

void Repeats(){
  Serial.println("15 second timer");        

void OnceOnly(){
  Serial.println("This timer only triggers once"); 

void digitalClockDisplay()
  // digital clock display of the time

void printDigits(int digits)
  if(digits < 10)

// readCapacitivePin
//  Input: Arduino pin number
//  Output: A number, from 0 to 17 expressing
//  how much capacitance is on the pin
//  When you touch the pin, or whatever you have
//  attached to it, the number will get higher
//  #include "pins_arduino.h" // Arduino pre-1.0 needs this
uint8_t readCapacitivePin(int pinToMeasure) {
  // Variables used to translate from Arduino to AVR pin naming
  volatile uint8_t* port;
  volatile uint8_t* ddr;
  volatile uint8_t* pin;
  // Here we translate the input pin number from
  //  Arduino pin number to the AVR PORT, PIN, DDR,
  //  and which bit of those registers we care about.
  byte bitmask;
  port = portOutputRegister(digitalPinToPort(pinToMeasure));
  ddr = portModeRegister(digitalPinToPort(pinToMeasure));
  bitmask = digitalPinToBitMask(pinToMeasure);
  pin = portInputRegister(digitalPinToPort(pinToMeasure));
  // Discharge the pin first by setting it low and output
  *port &= ~(bitmask);
  *ddr  |= bitmask;
  // Make the pin an input with the internal pull-up on
  *ddr &= ~(bitmask);
  *port |= bitmask;

  // Now see how long the pin to get pulled up. This manual unrolling of the loop
  // decreases the number of hardware cycles between each read of the pin,
  // thus increasing sensitivity.
  uint8_t cycles = 17;
       if (*pin & bitmask) { cycles =  0;}
  else if (*pin & bitmask) { cycles =  1;}
  else if (*pin & bitmask) { cycles =  2;}
  else if (*pin & bitmask) { cycles =  3;}
  else if (*pin & bitmask) { cycles =  4;}
  else if (*pin & bitmask) { cycles =  5;}
  else if (*pin & bitmask) { cycles =  6;}
  else if (*pin & bitmask) { cycles =  7;}
  else if (*pin & bitmask) { cycles =  8;}
  else if (*pin & bitmask) { cycles =  9;}
  else if (*pin & bitmask) { cycles = 10;}
  else if (*pin & bitmask) { cycles = 11;}
  else if (*pin & bitmask) { cycles = 12;}
  else if (*pin & bitmask) { cycles = 13;}
  else if (*pin & bitmask) { cycles = 14;}
  else if (*pin & bitmask) { cycles = 15;}
  else if (*pin & bitmask) { cycles = 16;}

  // Discharge the pin again by setting it low and output
  //  It's important to leave the pins low if you want to
  //  be able to touch more than 1 sensor at a time - if
  //  the sensor is left pulled high, when you touch
  //  two sensors, your body will transfer the charge between
  //  sensors.
  *port &= ~(bitmask);
  *ddr  |= bitmask;

  return cycles;

Step 1: Photos of My Project

Here are some pictures, and videos as an example of the alarm clock.