![]() If you are getting false triggers from noise pick-up you may have to use shielded cable. If you are getting false triggers try increasing the threshold. (And you shouldn't need to detect another hit within 1/10th of a second.) The 100mS delay after you detect a hit is good because you want the LED to say-on long enough to see it. There should be no delays while waiting for the next hit! ![]() You want your loop to run as fast as possible so it can read as frequently as possible. Your program makes an instantaneous read, and if you're not over the threshold at that exact-instant it does nothing but wait for 5 milliseconds.There's a very good chance it will miss the drum hit because it's delaying (not reading) during the hit.Most of the time, your program is delaying and not reading the input. I am planning to connect two more LED strips so any advice would be extremely helpful!!! (At the moment the Piezo is connected to a breadboard and a 1 megohm resistor). They are 12v and at the moment I am powering the Arduino Uno with USB power. I have also bought some solid colour LED strips which only came with two wires for an output (red and white/greyish colour) and i am unsure what I need/where I need to plug them into for them to work as part of the circuit. I have set the delay to really low and the threshold to 100 as this seems to be where it is most responsive. The lights are reacting to each tap a little better however it is still quite temperamental. Serial.println("Knock!") // Write to serial.ĭigitalWrite(8, statePin) // set pin Offĭelay(5) // we have to make a delay to avoid overloading the serial port ![]() I have amended the code with some guidance from people in another forum and below is the code I am currently using: int knockSensor = 0 It seems to be triggering the LED tester ok, however when triggered once, the lights do not turn off for a couple of seconds and the serial print is printing hundreds of hits when I only tapped it once or sometimes I haven't even touched it at all. I am a complete beginner in coding and was recommended this arduino Knock! ( ). I have been doing this on an Arduino Uno, a breadboard and have been using this code on LED testers at the moment, however, the lights don’t seem to be responding as consistently to the code as Id hope. I have been working on my final uni project which involves triggering LEDs from Piezo elements connected to a drum set (so each time I hit a drum an LED strip gets activated and deactivated).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |