Added white pixel which moves during touch
This commit is contained in:
parent
e54b4e7753
commit
86a739a0a4
1 changed files with 32 additions and 7 deletions
35
FastTouch.ino
Executable file → Normal file
35
FastTouch.ino
Executable file → Normal file
|
@ -1,18 +1,43 @@
|
|||
#include <NeoPixelBus.h>
|
||||
|
||||
#define WS_PIN 2 // On Trinket or Gemma, suggest changing this to 1
|
||||
#define NUMPIXELS 113 // Popular NeoPixel ring size
|
||||
#define TOUCH_PIN 4 //Für Touch: 2, 4, 12, 13, 14, 15, 27
|
||||
|
||||
int touch_value = 100;
|
||||
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(NUMPIXELS, WS_PIN);
|
||||
|
||||
void setup(){
|
||||
int touch_value = 100;
|
||||
int i = 0;
|
||||
int d = 1;
|
||||
|
||||
RgbColor black(0);
|
||||
RgbColor white(255);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("Touch Test");
|
||||
|
||||
Serial.println("Switching off all LEDs");
|
||||
strip.Begin();
|
||||
//strip.SetBrightness(128);
|
||||
strip.ClearTo(black);
|
||||
strip.Show();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
touch_value = touchRead(TOUCH_PIN);
|
||||
|
||||
if (touch_value < 65) { Serial.print("Touch @ "); }
|
||||
if (touch_value < 50) {
|
||||
Serial.print("Touch @ ");
|
||||
i+=d;
|
||||
}
|
||||
Serial.println(touch_value);
|
||||
strip.ClearTo(black);
|
||||
strip.SetPixelColor(i, white);
|
||||
strip.Show();
|
||||
|
||||
delay(20);
|
||||
if(i==NUMPIXELS || i == 0) { d=d*(-1); }
|
||||
|
||||
|
||||
delay(10);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue