Would it be possible to make a flow or write a script where it was possible to use 1 button to control a hue bulb like below. The button has only one flow card “button activated”
Short press = ON / OFF
First long press = Dimming UP
Second long press = Dimming Down
best regards
Yes, it would. What you describe is technically possible.
awneil
September 27, 2023, 11:27pm
3
What do you mean by "flow" and "flow card" ?
Based on his only previous thread, communication isn't very good. May mean Flow Chart?
Herkese teşekkür ederim, Halettim. ihtiyacı olanlar için kodu paylaşıyorum.
const byte buttonPin = 16;
const byte ledPin = 6;
const byte runled = 8;
bool ledOn, dimDown;
int pwmValue = 0;
int i = 0;
int lastvalue;
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
pinMode (ledPin, OUTPUT);
pinMode (runled, OUTPUT);
digitalWrite (runled,HIGH);
}
void loop() {
if (!digitalRead(buttonPin)) delay(20);
if (!digitalRead(buttonPin)) {
delay(500);
if (!digitalRead(buttonPin)) {
while (!digitalRead(buttonPin)) {
if (dimDown) {
if (pwmValue > 0) pwmValue--;
}
else {
if (pwmValue < 255) pwmValue++;
}
lastvalue = pwmValue;
analogWrite(ledPin, pwmValue);
delay(15);
}
dimDown = !dimDown;
} else {
if (ledOn) {
while (i < pwmValue) {
pwmValue--;
analogWrite (ledPin,pwmValue);
delay(15);
}
ledOn = false;
dimDown = false;
} else {
while (pwmValue < lastvalue) {
pwmValue++;
analogWrite (ledPin,pwmValue);
delay(15);
}
ledOn = true;
}
}
}
}
Hello lion1983
It seems to be a school assignment, doesn't it?
If my déjà vu doesn't deceive me, the task has been set before.
Use the forum's search engine and start a search.
Have a nice day and enjoy coding in C++.