Good Day All!
Please forgive me if I’m posting the code or link in a wrong way.
First time here, but been reading for a while.
This is my first Arduino Project!!
Some Guide is greatly appreciated, been for Hours trying different ways to make the code work but just don’t know how to tackle it.
I’m pretty good with tools and PC, learning to code with Arduino using tutorials from here and Youtube!
The code is attached.
Used the Adafruit_NeoPixel.h library
As you can see the Leds light up one by one till the 24th, then OFF in the same way when the IR switch don’t detect an object (IR output is a high signal) then it Loops all over again.
When an object is a detected (signal LOW) it clears all the Leds.
That Works!!!
I need help with the following:
would like have each led light up and as the IR detects an object the Leds freeze on that Position.
like a Button with leds on a game show!
lets say 6 leds lit up (1/4th of the ring) and the IR detected and object then it will no longer turn the others ON, but keep those 6 on for few milisecond or even flash as visual indication where it stopped.
then clear the Ring and loops again.
Also how to capture the time from the first led that turned on until object was detected and display it.
well this is what I have so Far!
Thank you in advance!!!
#include <Adafruit_NeoPixel.h>
#define button 2 //IR signal
#define PIN 4 //WS2812 DI
boolean buttonState = 1;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(24, PIN, NEO_RGB + NEO_KHZ800);
void setup() {
strip.begin();
strip.setBrightness(30); //adjust brightness here
strip.show(); // Initialize all pixels to 'off'
pinMode(button, INPUT);
}
void loop() {
buttonState = digitalRead(button);
switch (buttonState) {
case HIGH:
colorWipe(strip.Color(0, 255, 0), 50); // Green
colorWipe(strip.Color(0, 0, 0), 50); // Blank
break;
case LOW:
//colorWipe(strip.Color(255, 0, 000), 50); // RED
//colorWipe(strip.Color(0, 0, 255), 50); // Blue
colorWipe(strip.Color(0, 0, 0), 50); // Blank
break;
}
}
//// LEDS EFFECTS///////////
void colorWipe(uint32_t c, uint8_t wait) {
for (uint16_t i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(42);
}
}
neopixel-24RGB-IR-SWITCH.ino (1.02 KB)