Hello fellow arduinos,
I am a newbie to the arduino world, but c++ is something I used to love during my hughschool years (13 years ago …). I am currently working on a project for college gradution.
I am working with adressable LEDs and beginning to understand it.
I need help on the following topic :
by default, when my program starts, I have to light up a certain led module (4 WS2812B leds on a sigle circuit board ) in a certain colour. The LED module is phisically attached to a pressable lamp. On the back side of the lamp, a normal open contact closes when the lamp is pressed and commands the led module to power off. I have to measure the time ( in miliseconds ) that passes from the moment the led is lit to the moment the contact closes and print it to the serial monitor for now. Later on, I will have to connect the project to a client by bluetooth and expand functionality.
Please help !
thanks in advance !
here is my sketch for now :
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == LOW) {
// turn LED on:
//digitalWrite(ledPin, HIGH);
strip.setPixelColor(0, 0, 255, 0);
// delay(1000);
strip.setPixelColor(1, 0, 255, 0);
strip.setPixelColor(2, 0, 255, 0);
strip.setPixelColor(3, 0, 255, 0);
// delay(1000);
strip.show();
}
else {
// turn LED off:
//digitalWrite(ledPin, LOW);
strip.setPixelColor(0, 0, 0, 0);
// delay(1000);
strip.setPixelColor(1, 0, 0, 0);
strip.setPixelColor(2, 0, 0, 0);
strip.setPixelColor(3, 0, 0, 0);
// delay(1000);
strip.show();
}