Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Jeremy Nir 2014
// For Wearable Computing Class Final
// Thanks to Connor Campbell for concept help
// Thanks to Lilypad + Arduino websites for guidance
int buzzA = 10; // Buzzer connected to digital pin 10
int buzzB = 9; // Buzzer connected to digital pin 9
int vibe = 5; // Vibe Motor connected to digital pin 5
int switchPin = 11; // switch connected to digital pin 11
int switchValue; // a variable to keep track of when switch is pressed
int counter = 0;
void setup()
{
pinMode(buzzA, OUTPUT); // sets the Pins to be outputs
pinMode(buzzB, OUTPUT);
pinMode(vibe, OUTPUT);
pinMode(switchPin, INPUT); // sets the switchPin to be an input
digitalWrite(switchPin, HIGH); // sets the default (unpressed) state of switchPin to HIGH
}
void loop() // run over and over again
{
switchValue = digitalRead(switchPin); // check to see if the switch is pressed
if (switchValue == LOW && counter == 0) { // if the switch is pressed then,
digitalWrite(buzzA, HIGH); //Beep1
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep1
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(1000);
digitalWrite(buzzA, HIGH); //Beep1
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep1
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(1000);
digitalWrite(buzzA, HIGH); //Beep2
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep2
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(700);
digitalWrite(buzzA, HIGH); //Beep2
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep2
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(700);
digitalWrite(buzzA, HIGH); //Beep3
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep3
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(500);
digitalWrite(buzzA, HIGH); //Beep3
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep3
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(500);
digitalWrite(buzzA, HIGH); //Beep4
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep4
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(300);
digitalWrite(buzzA, HIGH); //Beep4
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep4
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(300);
digitalWrite(buzzA, HIGH); //Beep5
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep5
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(100);
digitalWrite(buzzA, HIGH); //Beep5
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep5
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(100);
digitalWrite(buzzA, HIGH); //Beep6
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep6
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep6
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep6
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep7
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
// digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep7
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
delay(0);
digitalWrite(buzzA, HIGH); //Beep7
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(50);
digitalWrite(buzzA, LOW);
digitalWrite(buzzB, LOW);
// digitalWrite(vibe, LOW);
delay(50);
digitalWrite(buzzA, HIGH); //Beep7
digitalWrite(buzzB, HIGH);
digitalWrite(vibe, HIGH);
delay(100);
counter = 1; // pushes the counter up to 1
}
if (switchValue == HIGH) { // otherwise,
counter = 0;
digitalWrite(buzzA, LOW); // turn off
digitalWrite(buzzB, LOW);
digitalWrite(vibe, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.