Someone/thing Listens
Video documentation of Someone/Thing Listens:
p5 code: https://editor.p5js.org/blatinegra/sketches/AE6-51dL-
arduino code:
Arduino code: #include <Adafruit_NeoPixel.h>
#define LED_PIN 6
#define LED_COUNT 30
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
String incomingByte;
void setup() {
Serial.begin(9600);
pinMode (LED_PIN, OUTPUT);
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.show(); // Turn OFF all pixels ASAP
strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
}
void loop() {
int sensorValue = digitalRead(4);
Serial.print(sensorValue);
delay (100);
if (sensorValue == LOW) {
colorWipe(strip.Color(0, 0, 0), 50);
}
if (Serial.available() > 0) {
incomingByte = Serial.readString();
if (incomingByte == "something") {
colorWipe(strip.Color(104, 8, 146), 50); // purple
colorWipe(strip.Color(212, 113, 235), 50); // Green
colorWipe(strip.Color(252, 3, 218), 50); // Pink
}
}
}
void colorWipe(uint32_t color, int wait) {
for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...
strip.setPixelColor(i, color); // Set pixel's color (in RAM)
strip.show(); // Update strip to match
delay(wait); // Pause for a moment
}
}
}