Get Out of My Space!

by Chloe and Kristina,

with many thanks to Michelle Ma for acting for us :)

The following is out Fritzing diagram: 

 

Clearly the epitome of style, this personal space sensor is all you’ll ever need to let those people who’ve been in your bubble too long it’s time for them to go — or at least to take a step back.

Screen Shot 2013-11-14 at 2.30.19 PM

 We used: the Pico Buzzer from our Arduino Kits, the 7-segment display provided for the assignment, and an arbitrary InfraRed sensor in order to sense the distance between a person and the machine.

The following images are excerpts from our planning:

20131114_155939 20131114_155928

And here is our code:

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
 
 
#include <Wire.h> // Enable this line if using Arduino Uno, Mega, etc.
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
 
int irReader = 2;
int irVal = 0;
int buzzerPin = 9;
int songLength = 8;
int frequencies[] = {
330,262,330,440,330,262,330,440};
int tempo = 150;
int lastCountDownTime = 0;
boolean play = false;
int displayNum = 10;
 
void playBuzzer(boolean play){
if (play == true){
int i,tempo;
for ( i = 0; i < 2; i++){
tone(buzzerPin,frequencies[i],tempo);
delay(tempo);
}
}
while(true){
}
}
 
Adafruit_7segment matrix = Adafruit_7segment();
int myNum;
void setup() {
pinMode(buzzerPin,OUTPUT);
myNum = 10;
Serial.begin(9600);
Serial.println("7 Segment Backpack Test");
matrix.begin(0x70);
 
}
 
void loop() {
play = false;
int now = millis();
irVal = analogRead(irReader);
Serial.println(irVal);
 
if (irVal > 250){
int elapsed = now-lastCountDownTime;
if (elapsed >= 1000)
{
myNum = (myNum + 1)%11;
int displayNum = 10-myNum;
lastCountDownTime = now;
matrix.print(displayNum, DEC);
matrix.println(displayNum);
matrix.writeDisplay();
if (displayNum == 0) {
if (irVal > 250){
//play = true;
displayNum = 0;
//playBuzzer(play);
tone(buzzerPin,1000,tempo);
delay(200);
tone(buzzerPin,1000,tempo);
delay(200);
tone(buzzerPin,1000,tempo);
 
}
else
{
play = false;
playBuzzer(play);
}
}
 
}
play = false;
}
else
{
myNum = -1;
}
 
}

 

 

Comments are closed.