Kann mir jemand bei einer Rolladenschaltung wieter helfen?

vor 33 weeks 1 day von acoolio

Hallo,
ich hoffe es kann mir jemand helfen.Ich habe mir für meine Rolladen eine Schaltung aufgebaut, die soweit bis auf 2 Sachen funktioniert.

1.Die Rolladen fahren manchmal morgens ganz nach oben(angesteuert vom LDR) und manchmal fehlt halt noch ein paar cm.
2.was mich langsam zum verzweifeln bringt.Ich habe mir die Werte vom LDR Seriel ausgelesen, um zu sehen wann die Rolladen automatisch nach oben bzw. nach unten fahren sollen.Sobald ich diesen Befehl lösche: Serial.begin(9600); und Serial.print("photovalue "); , spint das Programm und die Relays schalten komplett unkontrolliert, vielleicht hat ja jemand eine Idee warum das so ist.

int analog_photoresistor=0; //auf analog Pin0 Photosensor
const int S_R8_off=35; //Partyschalter um Wohnzimmer3_runter zu sperren
const int HT1=36; //Haupttaster hoch
const int HT2=37; //Haupttaster runter
const int T1 =52; //Tater Küche hoch
const int T2 =53; //Taste Küche runter
const int T3 =50; //Taster Wohnzimmer1 hoch
const int T4 =51; //Taster Wohnzimmer1 runter
const int T5 =48; //Taster Wohnzimmer2 hoch
const int T6 =49; //Taster Wohnzimmer2 runter
const int T7 =46; //Taster Wohnzimmer3 hoch
const int T8 =47; //Taster Wohnzimmer3 runter
const int T9 =44; //Taster Wohnzimmer4 hoch
const int T10=45; //Taster Wohnzimmer4 runter
const int T11=42; //Taster Bad hoch
const int T12=43; //Taster Bad runter
const int T13=40; //Taster Büro Vorne hoch
const int T14=41; //Taster Büro Vorne runter
const int T15=38; //Taster Büro Seite hoch
const int T16=39; //Taster Büro Seite runter

const int R1 =7; //Relais Küche hoch
const int R2 =6; //Relais Küche runter
const int R3 =5; //Relais Wohnzimmer1 hoch
const int R4 =4; //Relais Wohnzimmer1 runter
const int R5 =3; //Relais Wohnzimmer2 hoch
const int R6 =2; //Relais Wohnzimmer2 runter
const int R7 =25; //Relais Wohnzimmer3 hoch
const int R8 =24; //Relais Wohnzimmer3 runter
const int R9 =27; //Relais Wohnzimmer4 hoch
const int R10=26; //Relais Wohnzimmer4 runter
const int R11=29; //Relais Bad hoch
const int R12=28; //Relais Bad runter
const int R13=31; //Relais Büro Vorne hoch
const int R14=30; //Relais Büro Vorne runter
const int R15=33; //Relais Büro Seite hoch
const int R16=32; //Relais Büro Seite runter

int HT1_state,HT1_oldState=0; //Hauptaster hoch
int HT2_state,HT2_oldState=0; //Hauptaster runter

int T1_state,T1_oldState=0; //Tasterküche hoch
int T2_state,T2_oldState=0; //Tasterküche runter
int T1_T2_val=0;

int T3_state, T3_oldState=0; //Wohnzimmer1 hoch
int T4_state,T4_oldState=0; //Wohnzimmer1 runter
int T3_T4_val =0;

int T5_state, T5_oldState=0; //Wonzimmer2 hoch
int T6_state, T6_oldState=0; //Wohnzimmer2 runter
int T5_T6_val =0;

int T7_state, T7_oldState=0; //Wohnzimmer3 hoch
int T8_state, T8_oldState=0; //Wohnzimmer3 runter
int T7_T8_val =0;

int T9_state, T9_oldState=0; //Wohnzimmer4 hoch
int T10_state, T10_oldState=0; //Wohnzimmer4 runter
int T9_T10_val =0;

int T11_state, T11_oldState=0; //Bad hoch
int T12_state, T12_oldState=0; //Bad runter
int T11_T12_val =0;

int T13_state, T13_oldState=0; //Büro vorne hoch
int T14_state, T14_oldState=0; //Büro vorne runter
int T13_T14_val =0;

int T15_state, T15_oldState=0; //Büro Seite hoch
int T16_state, T16_oldState=0; //Büro Seite runter
int T15_T16_val =0;

unsigned long previousMillis1=0;
unsigned long previousMillis2=0;
unsigned long previousMillis3=0;
unsigned long previousMillis4=0;
unsigned long previousMillis5=0;
unsigned long previousMillis6=0;
unsigned long previousMillis7=0;
unsigned long previousMillis8=0;
unsigned long previousMillis9=0;
unsigned long previousMillis10=0;
unsigned long previousMillis11=0;
unsigned long previousMillis12=0;
unsigned long previousMillis13=0;
unsigned long previousMillis14=0;
unsigned long previousMillis15=0;
unsigned long previousMillis16=0;
unsigned long photoSensorMillis=0;

int photosensorValue=0; // Photosensorvariabel um den Wert zu speichern
int stateLight=0;
int stateDark=0;

int lightvalue=270; //Schwellwert ab wann hochgefahren wird
int darkvalue=240; //Schwellwert ab wann runtergefahren wird

unsigned long delayPhoto=180000UL; //Verzögerung, wie lange es hell oder dunkel sein muß das die Rolladen gefahren werden.
unsigned long rollMoveTime = 50000UL; //Rolladen fahrdauer
unsigned long delayWohnzimmer3=180000UL; //Verzögerung, wann Wohnz.3 heruntergefahren wird

void setup(){
Serial.begin(9600);

pinMode(analog_photoresistor, INPUT);//analog pin für photoresistor
pinMode(S_R8_off,INPUT); //Partyschalter Wohnzimmer3_runter zu sperren

pinMode(HT1,INPUT); //Haupttaster hoch
pinMode(HT2,INPUT); //Haupttaster runter
pinMode (T1,INPUT); //Taster hoch
pinMode (T2,INPUT); //Taster runter
pinMode (T3,INPUT); //Taster hoch
pinMode (T4,INPUT); //Taster runter
pinMode (T5,INPUT); //Taster hoch
pinMode (T6,INPUT); //Taster runter
pinMode (T7,INPUT); //Taster hoch
pinMode (T8,INPUT); //Taster runter
pinMode (T9,INPUT); //Taster hoch
pinMode (T10,INPUT); //Taster runter
pinMode (T11,INPUT); //Taster hoch
pinMode (T12,INPUT); //Taster runter
pinMode (T13,INPUT); //Taster hoch
pinMode (T14,INPUT); //Taster runter
pinMode (T15,INPUT); //Taster hoch
pinMode (T16,INPUT); //Taster runter

pinMode (R1,OUTPUT); //Relais hoch
pinMode (R2,OUTPUT); //Relais runter
pinMode (R3,OUTPUT); //Relais hoch
pinMode (R4,OUTPUT); //Relais runter
pinMode (R5,OUTPUT); //Relais hoch
pinMode (R6,OUTPUT); //Relais runter
pinMode (R7,OUTPUT); //Relais hoch
pinMode (R8,OUTPUT); //Relais runter
pinMode (R9,OUTPUT); //Relais hoch
pinMode (R10,OUTPUT); //Relais runter
pinMode (R11,OUTPUT); //Relais hoch
pinMode (R12,OUTPUT); //Relais runter
pinMode (R13,OUTPUT); //Relais hoch
pinMode (R14,OUTPUT); //Relais runter
pinMode (R15,OUTPUT); //Relais hoch
pinMode (R16,OUTPUT); //Relais runter

digitalWrite(S_R8_off,HIGH);//aktiviert den internen Pullupwiderstand
digitalWrite(HT1,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(HT2,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T1,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T2,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T3,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T4,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T5,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T6,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T7,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T8,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T9,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T10,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T11,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T12,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T13,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T14,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T15,HIGH); //aktiviert den internen Pullupwiderstand
digitalWrite(T16,HIGH); //aktiviert den internen Pullupwiderstand
delay (500);
}

void loop(){

Serial.print("photovalue ");
//Serial.println(photosensorValue);
//Serial.print("lightstate ");
//Serial.println(stateLight);
//Serial.print("darkstate ");
//Serial.println(stateDark);

unsigned long currentMillis=millis();

HT1_state=digitalRead(HT1);
HT2_state=digitalRead(HT2);
T1_state= digitalRead(T1);
T2_state= digitalRead(T2);
T3_state= digitalRead(T3);
T4_state= digitalRead(T4);
T5_state= digitalRead(T5);
T6_state= digitalRead(T6);
T7_state= digitalRead(T7);
T8_state= digitalRead(T8);
T9_state= digitalRead(T9);
T10_state=digitalRead(T10);
T11_state=digitalRead(T11);
T12_state=digitalRead(T12);
T13_state=digitalRead(T13);
T14_state=digitalRead(T14);
T15_state=digitalRead(T15);
T16_state=digitalRead(T16);

photosensorValue = analogRead (analog_photoresistor);

//***************************Photoresistor***alle Rolladen/hoch********************************

if (((photosensorValue>lightvalue)&&(stateLight==0)&&(photosensorValue<500))){
photoSensorMillis=currentMillis;
stateLight=1;}

if(((stateLight==1)&&(currentMillis-photoSensorMillis>delayPhoto)&&(photosensorValuedelayPhoto)&&(photosensorValue>500))){
stateLight=0;}

if((((stateLight==1)&&(currentMillis-photoSensorMillis>delayPhoto)&&(photosensorValue>lightvalue)&&(photosensorValue<500)))){

previousMillis1=currentMillis;
previousMillis3=currentMillis;
previousMillis5=currentMillis;
previousMillis7=currentMillis;
previousMillis9=currentMillis;
previousMillis11=currentMillis;
previousMillis13=currentMillis;
previousMillis15=currentMillis;

T1_T2_val=0;
T3_T4_val=0;
T5_T6_val=0;
T7_T8_val=0;
T9_T10_val=0;
T11_T12_val=0;
T13_T14_val=0 ;
T15_T16_val=0 ;

T1_T2_val --;
T3_T4_val --;
T5_T6_val --;
T7_T8_val --;
T9_T10_val --;
T11_T12_val --;
T13_T14_val --;
T15_T16_val --;

stateLight=2;
stateDark=0;}
//photoSensorMillis=currentMillis;}}

//**************************Photoresistor***alle Rolladen/runter*******************************

if((photosensorValue < darkvalue)&&(stateDark==0)){
photoSensorMillis=currentMillis;
stateDark=1;}

if(stateDark==1){
if((currentMillis-photoSensorMillis > delayPhoto)&&(photosensorValue > darkvalue)){
stateDark=0;}}

if(stateDark==1){
if((currentMillis-photoSensorMillis > delayPhoto)&&(photosensorValue < darkvalue)){
T1_T2_val=0;
T1_T2_val ++;
previousMillis2=currentMillis;
T3_T4_val=0;
T3_T4_val ++;
previousMillis4=currentMillis;
T5_T6_val =0 ;
T5_T6_val ++;
previousMillis6=currentMillis;
T9_T10_val=0;
T9_T10_val ++;
previousMillis10=currentMillis;
T11_T12_val=0 ;
T11_T12_val ++;
previousMillis12=currentMillis;
T13_T14_val=0 ;
T13_T14_val ++;
previousMillis14=currentMillis;
T15_T16_val=0 ;
T15_T16_val ++;
previousMillis16=currentMillis;
stateDark=2;
stateLight=0;
photoSensorMillis=currentMillis;
}}

if(stateDark==2){
if((currentMillis-photoSensorMillis > delayWohnzimmer3)&&(digitalRead(S_R8_off)==HIGH)){
T7_T8_val=0;
T7_T8_val ++;
previousMillis8=currentMillis;
stateDark=3;}}

if(stateDark==2){
if((currentMillis-photoSensorMillis>delayWohnzimmer3)&&(digitalRead(S_R8_off)==LOW)){
stateDark=3;}}

//***********************************Haupttaster/hoch**************************************

if(HT1_state !=HT1_oldState){
if(HT1_state == LOW){

if(T1_T2_val > -1){
T1_T2_val --;}
if(T3_T4_val > -1){
T3_T4_val --;}
if(T5_T6_val > -1){
T5_T6_val --;}
if(T7_T8_val > -1){
T7_T8_val --;}
if(T9_T10_val > -1){
T9_T10_val --;}
if(T11_T12_val > -1){
T11_T12_val --;}
if(T13_T14_val > -1){
T13_T14_val --;}
if(T15_T16_val > -1){
T15_T16_val --;}}}

HT1_oldState=HT1_state;

//***********************************Haupttaster/runter**************************************

if(HT2_state !=HT2_oldState){
if(HT2_state == LOW){

if(T1_T2_val < 1){
T1_T2_val ++;}
if(T3_T4_val< 1){
T3_T4_val ++;}
if(T5_T6_val< 1){
T5_T6_val ++;}
if(T7_T8_val < 1){
T7_T8_val ++;}
if(T9_T10_val< 1){
T9_T10_val ++;}
if(T11_T12_val< 1){
T11_T12_val ++;}
if(T13_T14_val< 1){
T13_T14_val ++;}
if(T15_T16_val< 1){
T15_T16_val ++;}}}

HT2_oldState=HT2_state;

//*************************************Rolladenküche/hoch***********************************

if(T1_state !=T1_oldState){
if(T1_state == LOW){

if(T1_T2_val > -1){
T1_T2_val --;}}}
T1_oldState=T1_state;

if (T1_T2_val == -1){
digitalWrite(R1,LOW);

if (currentMillis-previousMillis1 > rollMoveTime){
previousMillis1=currentMillis;
T1_T2_val ++;
T1_oldState=1;
HT1_oldState=1;}}

else{digitalWrite(R1,HIGH);
previousMillis1=0; }

//*************************************Rolladenküche/runter***********************************

if(T2_state !=T2_oldState){
if(T2_state == LOW){

if(T1_T2_val < 1){
T1_T2_val ++;}}}
T2_oldState=T2_state;

if (T1_T2_val == 1){
digitalWrite(R2,LOW);

if (currentMillis-previousMillis2 > rollMoveTime){
previousMillis2=currentMillis;
T1_T2_val --;
T2_oldState=1;
HT2_oldState=1;}}

else{digitalWrite(R2,HIGH);
previousMillis2=0; }

//***************************************Wohnzimmer1/hoch***********************************

if(T3_state !=T3_oldState){
if(T3_state == LOW){

if(T3_T4_val > -1){
T3_T4_val --;}}}
T3_oldState=T3_state;

if (T3_T4_val == -1){
digitalWrite(R3,LOW);

if (currentMillis-previousMillis3 > rollMoveTime){
previousMillis3=currentMillis;
T3_T4_val ++;
T3_oldState=1;
HT1_oldState=1;}}

else{digitalWrite(R3,HIGH);
previousMillis3=0; }

//***************************************Wohnzimmer1/runter***********************************

if(T4_state !=T4_oldState){
if(T4_state == LOW){

if(T3_T4_val < 1){
T3_T4_val ++;}}}
T4_oldState=T4_state;

if (T3_T4_val == 1){
digitalWrite(R4,LOW);

if (currentMillis-previousMillis4 > rollMoveTime){
previousMillis4=currentMillis;
T3_T4_val --;
T4_oldState=1;
HT2_oldState=1;}}

else{digitalWrite(R4,HIGH);
previousMillis4=0; }

//***************************************Wohnzimmer2/hoch***********************************

if(T5_state !=T5_oldState){
if(T5_state == LOW){

if(T5_T6_val > -1){
T5_T6_val --;}}}
T5_oldState=T5_state;

if (T5_T6_val == -1){
digitalWrite(R5,LOW);

if (currentMillis-previousMillis5 > rollMoveTime){
previousMillis5=currentMillis;
T5_T6_val ++;
T5_oldState=1;
HT1_oldState=1;}}

else{digitalWrite(R5,HIGH);
previousMillis5=0; }

//***************************************Wohnzimmer2/runter***********************************

if(T6_state !=T6_oldState){
if(T6_state == LOW){

if(T5_T6_val < 1){
T5_T6_val ++;}}}
T6_oldState=T6_state;

if (T5_T6_val == 1){
digitalWrite(R6,LOW);

if (currentMillis-previousMillis6 > rollMoveTime){
previousMillis6=currentMillis;
T5_T6_val --;
T6_oldState=1;
HT2_oldState=1;}}

else{digitalWrite(R6,HIGH);
previousMillis6=0; }

//***************************************Wohnzimmer3/hoch*******************************************

if(T7_state !=T7_oldState){
if(T7_state == LOW){

if(T7_T8_val > -1){
T7_T8_val --; }}}
T7_oldState=T7_state;

if (T7_T8_val == -1){
digitalWrite(R7,LOW);

if (currentMillis-previousMillis7 > rollMoveTime){
previousMillis7=currentMillis;
T7_T8_val ++;
T7_oldState=1;
HT1_oldState=1;}}

else{digitalWrite(R7,HIGH);
previousMillis7=0; }

//***************************************Wohnzimmer3/runter***********************************

if(T8_state !=T8_oldState){
if(T8_state == LOW){

if(T7_T8_val < 1){
T7_T8_val ++;}}}
T8_oldState=T8_state;

if (T7_T8_val == 1){
digitalWrite(R8,LOW);

if (currentMillis-previousMillis8 > rollMoveTime){
previousMillis8=currentMillis;
T7_T8_val --;
T8_oldState=1;
HT2_oldState=1;}}

else{digitalWrite(R8,HIGH);
previousMillis8=0; }

//***************************************Wohnzimmer4/hoch***********************************

if(T9_state !=T9_oldState){
if(T9_state == LOW){

if(T9_T10_val > -1){
T9_T10_val --;}}}
T9_oldState=T9_state;

if (T9_T10_val == -1){
digitalWrite(R9,LOW);

if (currentMillis-previousMillis9 > rollMoveTime){
previousMillis9=currentMillis;

T9_T10_val ++;
T9_oldState=1;
HT1_oldState=1;}}

else{digitalWrite(R9,HIGH);
previousMillis9=0; }

//***************************************Wohnzimmer4/runter***********************************

if(T10_state !=T10_oldState){
if(T10_state == LOW){

if(T9_T10_val < 1){
T9_T10_val ++;}}}
T10_oldState=T10_state;

if (T9_T10_val == 1){
digitalWrite(R10,LOW);

if (currentMillis-previousMillis10 > rollMoveTime){
previousMillis10=currentMillis;

T9_T10_val --;
T10_oldState=1;
HT2_oldState=1;}}

else{digitalWrite(R10,HIGH);
previousMillis10=0; }

//***************************************Bad/hoch***********************************

if(T11_state !=T11_oldState){
if(T11_state == LOW){

if(T11_T12_val > -1){
T11_T12_val --;}}}
T11_oldState=T11_state;

if (T11_T12_val == -1){
digitalWrite(R11,LOW);

if (currentMillis-previousMillis11 > rollMoveTime){
previousMillis11=currentMillis;
T11_T12_val ++;
T11_oldState=1;
HT1_oldState=1;}}

else{digitalWrite(R11,HIGH);
previousMillis11=0; }

//***************************************Bad/runter***********************************

if(T12_state !=T12_oldState){
if(T12_state == LOW){

if(T11_T12_val < 1){
T11_T12_val ++;}}}
T12_oldState=T12_state;

if (T11_T12_val == 1){
digitalWrite(R12,LOW);

if (currentMillis-previousMillis12 > rollMoveTime){
previousMillis12=currentMillis;
T11_T12_val --;
T12_oldState=1;
HT2_oldState=1;}}

else{digitalWrite(R12,HIGH);
previousMillis12=0; }

//***************************************Büro/vorne/hoch***********************************

if(T13_state !=T13_oldState){
if(T13_state == LOW){

if(T13_T14_val > -1){
T13_T14_val --;}}}
T13_oldState=T13_state;

if (T13_T14_val == -1){
digitalWrite(R13,LOW);

if (currentMillis-previousMillis13 > rollMoveTime){
previousMillis13=currentMillis;
T13_T14_val ++;
T13_oldState=1;
HT1_oldState=1;}}

else{digitalWrite(R13,HIGH);
previousMillis13=0; }

//***************************************Büro/vorne/runter***********************************

if(T14_state !=T14_oldState){
if(T14_state == LOW){

if(T13_T14_val < 1){
T13_T14_val ++;}}}
T14_oldState=T14_state;

if (T13_T14_val == 1){
digitalWrite(R14,LOW);

if (currentMillis-previousMillis14 > rollMoveTime){
previousMillis14=currentMillis;
T13_T14_val --;
T14_oldState=1;
HT2_oldState=1;}}

else{digitalWrite(R14,HIGH);
previousMillis14=0; }

//***************************************Büro/Seite/hoch***********************************

if(T15_state !=T15_oldState){
if(T15_state == LOW){

if(T15_T16_val > -1){
T15_T16_val --;}}}
T15_oldState=T15_state;

if (T15_T16_val == -1){
digitalWrite(R15,LOW);

if (currentMillis-previousMillis15 > rollMoveTime){
previousMillis15=currentMillis;
T15_T16_val ++;
T15_oldState=1;
HT1_oldState=1;}}

else{digitalWrite(R15,HIGH);
previousMillis15=0; }

//***************************************Büro/Seite/runter***********************************

if(T16_state !=T16_oldState){
if(T16_state == LOW){

if(T15_T16_val < 1){
T15_T16_val ++;}}}
T16_oldState=T16_state;

if (T15_T16_val == 1){
digitalWrite(R16,LOW);

if (currentMillis-previousMillis16 > rollMoveTime){
previousMillis16=currentMillis;
T15_T16_val --;
T16_oldState=1;
HT2_oldState=1;}}

else{digitalWrite(R16,HIGH);
previousMillis16=0; }}

//**********************************************************************************

Vielen Dank und LG

Ähnliche Posts

1 Antwort auf “Kann mir jemand bei einer Rolladenschaltung wieter helfen?”


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
  1. uwe sagt:

    Wieso? Wurde Dir auf http://arduino.cc/forum/index.php/topic,142956.0.html nicht geholfen?

    HAst Du schon mal was von for-Schleifen, arrays und Funktionen gehört? diese würden den Sketch nämlich sehr vereinfachen.

    Grüße Uwe

    Login or register to post comments