Update light_fast.ino

would probably work ...  dk
This commit is contained in:
i3le 2024-07-11 19:02:28 +02:00
parent 269e012679
commit 23c0ccd7b5

View file

@ -1,3 +1,6 @@
#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 4);
#define Light_sensor A0 #define Light_sensor A0
#define Lamp_mod 6 #define Lamp_mod 6
#define Move_sensor 2 #define Move_sensor 2
@ -52,9 +55,7 @@ void movement(){
else{ else{
movement_threshold = 80; movement_threshold = 80;
} }
if (Serial.availableForWrite()) { if (movement_threshold-25 > 0) mySerial.write(movement_threshold-25);
if (movement_threshold-25 > 0) Serial.write(movement_threshold-25);
}
} }
void setup() { void setup() {
@ -64,6 +65,7 @@ void setup() {
pinMode(Light_sensor,INPUT); pinMode(Light_sensor,INPUT);
pinMode(Lamp_mod,OUTPUT); pinMode(Lamp_mod,OUTPUT);
Serial.begin(9600); Serial.begin(9600);
mySerial.begin(38400);
} }
// functions werte definiert von 0 bis 100 darüber und unter chaos! // functions werte definiert von 0 bis 100 darüber und unter chaos!
@ -109,14 +111,13 @@ void loop() {
if (movement_threshold) movement_threshold--; // time based light reduction! if (movement_threshold) movement_threshold--; // time based light reduction!
setlight_with_wehtherinfluence(movement_threshold); setlight_with_wehtherinfluence(movement_threshold);
delay(100); delay(100);
int8_t i; while (mySerial.available()){
while ((Serial.available())&&(i<10) ){ uint8_t msg = mySerial.read();
uint8_t msg = Serial.read(); Serial.println(msg);
if (msg < 101){ if (msg < 101){
if ( msg >= movement_threshold ) movement_threshold= msg; if ( msg >= movement_threshold ) movement_threshold= msg;
} }
i++;
} }
} }