Get Out of My Space!

[vimeo 79357294]

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:



#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.