Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- /* Knock Sensor
- *
- * Code has been modified for the Tapping Light, by PerfectPixel (2015)
- * http://www.instructables.com/member/perfectpixel/
- *
- *
- created 25 Mar 2007
- by David Cuartielles <http://www.0j0.org>
- modified 30 Aug 2011
- by Tom Igoe
- This example code is in the public domain.
- */
- #define NUM_LEDS 1
- #define DATA_PIN 9
- CRGB leds[NUM_LEDS];
- int sensorReading = 0; // variable to store the value read from the sensor pin
- void setup() {
- FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
- }
- void loop() {
- if (analogRead(7) > 2) { //change the "2" here to a different value to tweak what counts as a 'tap'
- // toggle the status of the ledPin:
- leds[0] = CRGB(random(300),random(300),random(300));
- FastLED.show();
- delay(10);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement