Advertisement
tuixte

Knock sensor

Mar 23rd, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. const int knockSensor = A0;
  2. const int threshold = 100;
  3.  
  4. void setup() {
  5.  pinMode(knockSensor, INPUT);
  6.  Serial.begin(9600);
  7. }
  8.  
  9. void loop() {
  10.   if(analogRead(knockSensor) >= threshold)
  11.     Serial.println("Knock!");        
  12.   delay(100);
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement