Skip to content

Instantly share code, notes, and snippets.

@donthorp
Created June 20, 2012 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donthorp/2957878 to your computer and use it in GitHub Desktop.
Save donthorp/2957878 to your computer and use it in GitHub Desktop.
Z Axis Toner
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