Introduction: Smart Alarm: With Arduino and Velostat Sensors

Objective:

Waking up is the hardest part of the day, and for most people, its the getting out of bed part. The purpose of the Smart Alarm Project is to create an interactive alarm clock that requires the user to physically do an action/pose that will turn the alarm off (ie. jumping jacks, yoga sequences, specific dance moves etc.) In order to do this we used a pressure sensitive conductive sheet called velostat. When the alarm goes off the velostat squares light up and once the user puts pressure on them for at least 5 seconds the alarm will turn off.

Step 1: Supplies and Tools

Materials Used:

  • Arduino uno
  • alarm clock
  • wire
  • velostat : (we got our's here: https://www.adafruit.com/products/1361 )
  • LED lights
  • foam mat
  • solder
  • electric tape (we used red and yellow)
  • Conductive Thread
  • Arduno connecting wires

Tools Used:

  • soldering iron
  • scissors
  • screwdriver
  • voltmeter
  • wire strippers
  • wire cutters
  • exacto-knife
  • measuring tape

Step 2: Hacking the Alarm

In order to hack the alarm first take the alarm apart with a screwdriver. Next, locate the power and ground wire connected to the speaker. Cut these and use a voltmeter to determine the power wire, this will be used later to know when the alarm is going off. We than disconnected the end of the wires that were connected to the inside clock aspect of the alarm, but left the speaker end in place. This allowed our Arduino to send a signal to the alarm/speaker to go off (see fritzing photo in next step).

Step 3: Wiring Assembly

Alarm:

From the signal side of the alarm clock connect the power line to an analog pin (we used pin A3) and the other to the ground line. For the speaker side connect one side to ground and the other to a PWM pin (we used pin 6). In the fritzing diagram just assume the LCD display is the alarm clock.

Velostat:

One side of the velostat should be connected to ground using wire. The other side should be connect to 5V power on the Arduino board and another wire connected to an analog pin (we used pin A0).

LED:

To wire the LED's connect the longer end to a PWM pin (we used pin 9) and the other end to the ground line.

NOTE: Further along, we will wire up and connect multiple LED lights into the Arduino board. This will be done in the same way as the single LED (above).

Testing The Alarm / Speaker:

This step is essential. It is important to test the speaker alarm / LED light to test the connectivity before continuing on. We used a simple LED light code in order to test this. Here is an example of the code we used to test the LED and since the speaker and LED are connected through the Arduino (see picture), they both will go off at the same time.

Code:

int led = 9; // the setup routine runs once when you press reset:
void setup() {

// initialize the digital pin as an output. pinMode(led, OUTPUT);

}

// the loop routine runs over and over again forever: void loop() { digitalWrite(led, 255); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }


Step 4: Assembly of the Velostat

1. Once you have the basic alarm working, you can continue onto creating the mat. We simply used a 2 inch thick piece of foam mat.

2.From there, we decided that we wanted 6 different sensors in order to maximize the amount of poses / sequences that we could do. We measured the foam mat to be 8' by 2' and cut our velostat into 9" by 5" squares.

3. We then took the conductive thread and taped it to the back of the velostat in a U-shape so that it was covering a large portion of the square. We taped the conductive thread onto the back of the velostat using the Electric Tape -- Set Aside

NOTE:(conductive tape or copper would work fine as well, just as long as it is conductive. Cut the velostat into the squares sizes you want.

4. Now, we cut the wire roll into 18 different pieces using the wire cutters. (12 of these will be used to connect the LED lights into the Arudino board, the other 6 will be used to connect the conductive thread).

5. Strip both ends of all of the wires so that it can be connected to the conductive thread / LED's and to the Arudino wires.

6. Now, take 6 of your stripped wires and solder one end to the conductive thread and the other end to the Arudino connecting wires.

NOTE: if you have never soldered or need further instructions, please have someone teach you proper techniques or look up further inscrutables before attempting alone.

7. Once the velostat is assembled, we used the Exacto Knife and the Measuring Tape to accurately cut hoes through the foam, right in the middle under each velostat square. This is to pull the thread from the velostat to the backside of the foam so that all of the wires are hidden.

8. Now connect each of the ground pins into the Arudino and each of the power pins into pin states as well.

NOTE: in the above picture, we tested on a normal FDM pressure sensor.

Step 5: Assembly of the LED Strips

Once the velostat is set up to the mat, it is time to set up the LED strips.

We used 3 LED lights per each square which created a total of 18 LED lights.

1. Take 3 LED lights and find the power and the ground ends (the longer end / pin is power (+)). Cut about 1" thick pieces of wire to connect each of the power ends to each other.

a. You will need to strip the ends of each piece of wire and than wrap / solder them to the LED.

2. Once you have connected each of the power ends to each other, do the same with the ground (-) ends. We also used the yellow tape to show which ends were ground and the red tape to represent the Power end, this way, we know where to plug in each of the pins to the Arduino.

3. Once the 3 LED lights have been connected, you can take the long 3' wire and connect one to the Power and one to the ground end of the LED lights.

4. After the long wires have been connected to the LED's, you can connect them to the Arudino connecting wires.

NOTE: be sure to properly label or remember which of your pins is power and which is the ground, otherwise, your LED's will not light up.

5. Use the measuring tape and the exacto-knife to cut 3 small holes centered above the velostat. Push the LED lights threw these small holes and leave the wires coming out the back / underneath the foam.

6. Now connect each of the power pins into a specific pin on the Arduino and each of the grounds into the ground state.

NOTE: we also used the electric tape to organize each of our LED strip wires. We put small pieces of tape connecting the power and the ground wires so that we knew where each wire was going to.

Step 6: Arduino Code

The layout of the code is first the alarm signal is read and once that is greater than 15 the lights turn on and the the state of the pressure sensor is checked. It uses the delay time to check once that is pressed for longer than 5s the LEDs turn off and the alarm is turned off. This will run the alarm clock (we have it on a set interval for demo purposes but this can easily be adjusted), the LED's, as well as the velostat sensor.

Here is an example of our code:

NOTE: in order to check the pressure of the velostat, by hitting "CTRL + SHIFT + F" in the Arduino window, you can see the variations in pressure as you tap on the velostat. That is how we determined the amount of pressure needed to apply in order to shut off the alarm.

int fsrAnalogPin = A3;

int LEDpin = 11; int LEDpin2 = 12; int LEDpin3 = 9; int LEDpin4 = 10; int LEDpin5 = 8; int LEDpin6 = 7; int fsrReading; // the analog reading from the FSR resistor divider

int alarmPin = 3; int alarmState; int alarmOff =6;

void setup(void) { Serial.begin(9600); // We'll send debugging information via the Serial monitor pinMode(LEDpin, OUTPUT); pinMode(LEDpin2, OUTPUT); pinMode(LEDpin2, OUTPUT); pinMode(LEDpin3, OUTPUT); pinMode(LEDpin4, OUTPUT); pinMode(LEDpin5, OUTPUT); pinMode(LEDpin6, OUTPUT); }

void loop(){

alarmState = analogRead(alarmPin); Serial.print("alarm ="); Serial.println(alarmState);

fsrReading = analogRead(fsrAnalogPin); Serial.print("Analog reading = "); Serial.println(fsrReading);

if (fsrReading >= 500) { delay(5000);

digitalWrite(LEDpin, LOW); digitalWrite(LEDpin2, LOW); digitalWrite(LEDpin3, LOW); digitalWrite(LEDpin4, LOW); digitalWrite(LEDpin5, LOW); digitalWrite(LEDpin6, LOW); analogWrite(alarmOff, LOW); delay(10000); digitalWrite(LEDpin,HIGH); digitalWrite(LEDpin2, HIGH); digitalWrite(LEDpin3, HIGH); digitalWrite(LEDpin4, HIGH); digitalWrite(LEDpin5, HIGH); digitalWrite(LEDpin, HIGH); analogWrite(alarmOff,200); Serial.print("alarm ="); Serial.println(alarmState); }

delay(500); }

Step 7: Live Demo

At the end of the semester, we presented at the AtlasExpo at CU Boulder. Here is the video demo of our alarm: