Hello everyone. First of all, I would like to clarify that I'm pretty new to coding, and I'm using an ATTiny88.
I have created a simple sketch to test if my button is working as expected, using a simple code to make an LED strip turn red when pressing the button, and blue when releasing it. However, when I release the button, it takes a couple of seconds to turn blue again.
Also, I don't have an Serial Monitor Module to use with the board.
Is this a fault of my board? Or is this how the void loop function should actually work?
This is my code;
#include <FastLED.h>
#define NUM_LEDS 40
#define LED_PIN 3
const int buttonPin = 6;
CRGB leds[NUM_LEDS];
int buttonState = 0;
void setup() {
pinMode(buttonPin, INPUT);
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(50);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
leds[0] = CRGB::Red;
FastLED.show();
} else {
leds[0] = CRGB::Blue;
FastLED.show();
}
}
And here, this is how it looks: