# Cover It. Timer With Vibrating Alarm (TfCD)

687

8

3

As a prototype for a wearable we have made a bracelet with a timer and a vibrating alarm. the alarm can be turned off by covering a LDR sensor. The idea behind this prototype is that it can be integrated in a (smart)watch. Initially the idea was to deactivate the alarm with an accelerometer, shaking the arm would have turned off the alarm. With no accelerometer at hand a LDR was used to show the principle and interaction. This instructable was inspired by other instructables.

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Step 1: Components

For this prototype the following components are used:

• Arduino (in this case Duemilanove but uno or another arduino would also work)
• 7 segment display
• LDR
• Transistor P2N2222A
• DC Motor
• Diode 1N4148
• 4,7 KOhm resistor
• 3x 220 Ohm resistors
• Jumper wires

## Step 2: Step 2: Assembly

Assemble the components as shown in the picture. when you extend the wires of the LDR and motor you can place them on a bracelet.

The 7 segment display is connected as follows

• a = pin 2
• b = pin 3
• c = pin 4
• d = pin 5
• e = pin 6
• f = pin 8
• g = pin 9

One of the COM pins should be connected to the ground via a 220 Ohm resistor and the other COM pin should be connected to the VCC also via a 220Ohm resistor.

the 3rd 220 Ohm resistor is used for the motor.

and the 4,7 KOhm resistor is for the LDR.

## Step 3: Step 3: Programming

Copy the following Code to Arduino:

int a = 2; //For displaying segment "a"
int b = 3; //For displaying segment "b"

int c = 4; //For displaying segment "c"

int d = 5; //For displaying segment "d"

int e = 6; //For displaying segment "e"

int f = 8; //For displaying segment "f"

int g = 9; //For displaying segment "g"

int LDR = A0; //LDR

int LDRValue = 0;

int tril = 12; // motor

void setup() {

pinMode(a, OUTPUT); //A

pinMode(b, OUTPUT); //B

pinMode(c, OUTPUT); //C

pinMode(d, OUTPUT); //D

pinMode(e, OUTPUT); //E

pinMode(f, OUTPUT); //F

pinMode(g, OUTPUT); //G

pinMode(LDR,INPUT); //LDR

pinMode(tril,OUTPUT); //motor

Serial.begin(9600);

}

void displayDigit(int digit) {

//Conditions for displaying segment a

if(digit!=1 && digit != 4)

digitalWrite(a,HIGH);

//Conditions for displaying segment b

if(digit != 5 && digit != 6)

digitalWrite(b,HIGH);

//Conditions for displaying segment c

if(digit !=2)

digitalWrite(c,HIGH);

//Conditions for displaying segment d

if(digit != 1 && digit !=4 && digit !=7)

digitalWrite(d,HIGH);

//Conditions for displaying segment e

if(digit !=1 && digit !=3 && digit !=4 && digit!=5 && digit!=7 && digit!=9)

digitalWrite(e,HIGH);

//Conditions for displaying segment f

if(digit != 1 && digit !=2 && digit!=3 && digit !=7)

digitalWrite(f,HIGH);

if (digit!=0 && digit!=1 && digit !=7)

digitalWrite(g,HIGH); }

void turnOff() {

digitalWrite(a,LOW);

digitalWrite(b,LOW);

digitalWrite(c,LOW);

digitalWrite(d,LOW);

digitalWrite(e,LOW);

digitalWrite(f,LOW);

digitalWrite(g,LOW); }

void loop() { LDRValue = analogRead(LDR);

int i;

for( i=9;i>0;i--) { displayDigit(i); delay(1000); turnOff();

if (i <= 3)

digitalWrite(tril,LOW);

else digitalWrite(tril,HIGH);

Serial.println(LDRValue);

if (LDRValue < 500)

{

digitalWrite(tril,HIGH); } } }

Open the Serial Monitor to check the values of the LDR, to define the threshold that fits your environment, adjust "if (LDRValue < 500)" to your threshold.

## Step 4: Step 4: Testing

The motor starts vibrating when the countdown reaches 3 and when the LDR is covered the motor stops again.

## Recommendations

• ### Internet of Things Class

22,770 Enrolled

## 3 Discussions

im wondering if how i will set the alarm?

How will u set the alarm?