Created
June 20, 2012 02:47
-
-
Save donthorp/2957878 to your computer and use it in GitHub Desktop.
Z Axis Toner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int contactPin = 7; | |
const int speakerPin = 6; | |
const int ledPin = 13; | |
int contactState = 0; | |
void setup() { | |
pinMode(ledPin, OUTPUT); | |
pinMode(contactPin, INPUT); | |
} | |
void loop() { | |
contactState = digitalRead(contactPin); | |
digitalWrite(ledPin, contactState ? HIGH : LOW); | |
if (contactState == HIGH) { | |
tone(speakerPin, 1000); | |
} else { | |
noTone(speakerPin); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment