Ich verstehe die Welt nicht mehr, eigentlich müsste doch licht auf 0 gesetzt werden wenn ich seriell eine 0 sende und eine 1 wennich eine 1 sende... das tut es aber nicht.
Kann mir mal einer sagen warum?
const int gruenLED = 2;
const int rotLED = 3;
int bluetooth = 0; // Serial
int dunkel = 0; // Schalter
int licht = 0;
int ledState = 0;
// Zeit
unsigned long serialMillis = 0;
unsigned long previousMillis = 0;
// Intervall LED
const long standbyinterval = 1000;
const long aninterval = 500;
void setup() {
pinMode(gruenLED, OUTPUT);
pinMode(rotLED, OUTPUT);
digitalWrite(gruenLED, 1);
digitalWrite(rotLED, 1);
Serial.begin(9600);
}
void loop() {
unsigned long currentMillis = millis();
// UHR
// RELAIS
// ULTRASCHALL
// SERIAL
if (Serial.available() > 0) {
bluetooth = Serial.read();
if (bluetooth == 0) {
licht == 0;
}
if (bluetooth == 1) {
licht == 1;
}
}
// STANDBY
if (licht == 0) {
if (currentMillis - previousMillis >= standbyinterval) {
previousMillis = currentMillis;
if (ledState == HIGH) {
ledState = LOW;
} else {
ledState = HIGH;
}
digitalWrite(gruenLED, ledState);
}
}
// AN
if (licht == 1) {
if (currentMillis - previousMillis >= aninterval) {
previousMillis = currentMillis;
if (ledState == HIGH) {
ledState = LOW;
} else {
ledState = HIGH;
}
digitalWrite(rotLED, ledState);
}
}
}