Skip to content

Instantly share code, notes, and snippets.

@kevinprince
Created April 2, 2012 12:30
Show Gist options
  • Save kevinprince/2283130 to your computer and use it in GitHub Desktop.
Save kevinprince/2283130 to your computer and use it in GitHub Desktop.
example flashing light / speaker on switch
void setup() {
Serial.begin(9600);
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(12, OUTPUT);
pinMode(9, OUTPUT);
}
void loop() {
int sensorOneValue = digitalRead(2);
int sensorTwoValue = digitalRead(3);
if (sensorOneValue > 0) {
Serial.print(1);
digitalWrite(12, HIGH);
delay(125);
digitalWrite(12, LOW);
digitalWrite(9, HIGH);
delay(125);
digitalWrite(9, LOW);
}
if (sensorTwoValue > 0) {
Serial.print(2);
digitalWrite(12, HIGH);
delay(125);
digitalWrite(12, LOW);
delay(125);
digitalWrite(12, HIGH);
delay(125);
digitalWrite(12, LOW);
digitalWrite(9, HIGH);
delay(125);
digitalWrite(9, LOW);
delay(125);
digitalWrite(9, HIGH);
delay(125);
digitalWrite(9, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment