Go Down

Topic: Maybe somone can help me with my second or third code  (Read 105 times) previous topic - next topic

forti

I have a problem with this to work, it seems nothing is changes when i uplod code to my board. Maybe somone can find the problem and give me solution what i wrote wrong. thank you
Code: [Select]


int sw2h  = 13;
int sw4h  = 14;
int sw4l  = 15;
int posb  = 5;
int posc  = 6;
int posd  = 7;
int engc  = 9;
int engcc = 10;
int ind4h = 11;
int ind4l = 12;

void setup(){
  
    pinMode (sw2h,INPUT);
    pinMode (sw4h,INPUT);
    pinMode (sw4l,INPUT);
    pinMode (posb,INPUT);
    pinMode (posc,INPUT);
    pinMode (posd,INPUT);
    pinMode (engc,OUTPUT);
    pinMode (engcc,OUTPUT);
    pinMode (ind4h,OUTPUT);
    pinMode (ind4l,OUTPUT);
}

void loop(){
    
    if ((sw2h==LOW)&&(posd==LOW)&&(sw4l==HIGH)&&(sw4h==HIGH)&&(posb==HIGH)&&(posc==HIGH)){
    
    digitalWrite(engc,LOW);
    digitalWrite(engcc,LOW);
  
    }
    
    if ((sw4h==LOW)&&(posd==LOW)&&(sw2h==HIGH)&&(sw4l==HIGH)&&(posb==HIGH)&&(posc==HIGH)){
  
    digitalWrite(engc,LOW);
    digitalWrite(engcc,HIGH);

    }
    
    if ((sw4h==LOW)&&(posb==HIGH)&&(sw2h==HIGH)&&(sw4l==HIGH)&&(posc==LOW)&&(posd==HIGH)){
  
    digitalWrite(engc,HIGH);
    digitalWrite(engcc,HIGH);

    }
    
    if ((sw2h==LOW)&&(posb==HIGH)&&(sw4h==HIGH)&&(sw4l==HIGH)&&(posc==LOW)&&(posd==HIGH)){
  
     digitalWrite(engc,HIGH);
     digitalWrite(engcc,LOW);
        
    }
    
    if ((sw4l==LOW)&&(posb==HIGH)&&(sw2h==HIGH)&&(sw4h==HIGH)&&(posc==LOW)&&(posd==HIGH)){
    
     digitalWrite(engc,LOW);
     digitalWrite(engcc,HIGH);
          
    }
    
    if ((sw4l==LOW)&&(posb==HIGH)&&(posc==HIGH)&&(sw2h==HIGH)&&(sw4h==HIGH)&&(posd==HIGH)){
    
    digitalWrite(engc,HIGH);
    digitalWrite(engcc,HIGH);
 
        
    }
    
    if ((sw4h==LOW)&&(posb==HIGH)&&(posc==HIGH)&&(sw2h==HIGH)&&(sw4l==HIGH)&&(posd==HIGH)){
    
    digitalWrite(engc,HIGH);
    digitalWrite(engcc,LOW);
  
    }
    
    if ((sw2h==LOW)&&(posb==HIGH)&&(posc==HIGH)&&(sw4h==HIGH)&&(sw4l==HIGH)&&(posd==HIGH)){
 
    digitalWrite(engc,HIGH);
    digitalWrite(engcc,LOW);
  
        }
        }


TheMemberFormerlyKnownAsAWOL

#1
May 24, 2020, 12:24 pm Last Edit: May 24, 2020, 12:27 pm by TheMemberFormerlyKnownAsAWOL
Code: [Select]
((sw2h==LOW)&&(posd==LOW)&&(sw4l==HIGH)&&(sw4h==HIGH)&&(posb==HIGH)&&(posc==HIGH))
 Needs more digitalRead


(BTW, this isn't your first code)
Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

Robin2

I have a problem with this to work,

Code: [Select]
    if ((sw2h==LOW)
Think about it. This can't work because sw2h = 13 so it can never be LOW.

It should be like this

Code: [Select]
sw2hValue = digitalRead(sw2h);
if (sw2hValue == LOW


etc etc

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

forti

Thanks guys, i will have to learn how to read with undertanding. Both of you help me a lot, and now code works great. Thanks one more time.

Go Up