Monday, 21 April 2014

Piezo, LED and Arduino - knock sensor

Hardware Required

Arduino Board(UNO)
(1) Piezo electric disc
(1) Megohm resistor
(1)LED 


*LED on Pin 13 & GND





* When piezo is touched the LED goes on on and prints "LED on" .

Arduino code:

const int LED = 13;
const int KNOCK = 0;

void setup()
{
  pinMode(LED, OUTPUT);
  Serial.begin(9600);       // use the serial port
}

void loop()
{
  int value = analogRead(KNOCK);
  if (value>100)
  {
    digitalWrite(LED, HIGH);
     Serial.println("LED on");
  }
  else
  {
    digitalWrite(LED, LOW);
  }
  delay(100);
}

* Prints "Led on"  when piezo is touched

1 comment:

  1. Thanks for this dead-simple idea! I'm looking for a way to modify this for multiple light-up drums, possibly with a fast fade out. Any ideas?

    ReplyDelete