Go Down

Topic: need help with LED controlling/disabling an out put (Read 239 times) previous topic - next topic

ingar195

May 06, 2013, 09:33 am Last Edit: May 06, 2013, 09:50 am by ingar195 Reason: 1
i whan to disable on of the lied bun im  not sure how to do it, and somebody told me that setting them
to an in put work,s but im not sure ho to do that
Code: [Select]

int led1 = 13;
int led2 = 12;
int led3 = 10;

void setup(){
 pinMode(led1, OUTPUT);
 pinMode(led2, OUTPUT);
 pinMode(led3, OUTPUT);
 
}
void loop(){
 pinMode(led3, INPUT); //this does not work
 digitalWrite(led1,HIGH);
 digitalWrite(led2,LOW);
 digitalWrite(led3,LOW);
 pinMode(led3, OUTPUT); //this does not work
 delay(500);
 
 pinMode(led1, INPUT); //this does not work
 digitalWrite(led1,LOW);
 digitalWrite(led2,LOW);
 digitalWrite(led3,HIGH);
 pinMode(led1, OUTPUT); //this does not work
 delay(500);

pinMode(led2, INPUT); //this does not work
 digitalWrite(led1,HIGH);
 digitalWrite(led2,HIGH);
 digitalWrite(led3,LOW);
 pinMode(led2, OUTPUT); //this does not work
 delay(500);
 
pinMode(led3, INPUT); //this does not work
 digitalWrite(led1,LOW);
 digitalWrite(led2,HIGH);
 digitalWrite(led3,HIGH);
 pinMode(led3, OUTPUT); //this does not work
 delay(500);

}

BillHo

Code: [Select]
int led1 = 13;
int led2 = 12;
int led3 = 10;

void setup(){
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
 
}
void loop(){

  pinMode(led3, INPUT); //this does not work ??? why???
  digitalWrite(led1,HIGH);
  digitalWrite(led2,LOW);
  // digitalWrite(led3,LOW); --> If you already set it to input, don't write
  delay(500);
 
  pinMode(led3, OUTPUT); //this does not work ??
  pinMode(led1, INPUT); //this does not work ??
  // digitalWrite(led1,LOW);  --> If you already set it to input, don't write
  digitalWrite(led2,LOW);
  digitalWrite(led3,HIGH);
  delay(500);
 
  pinMode(led1, OUTPUT); //this does not work ??
  pinMode(led2, INPUT); //this does not work ??
  digitalWrite(led1,HIGH);
//  digitalWrite(led2,HIGH);  --> If you already set it to input, don't write
  digitalWrite(led3,LOW);
  delay(500);
 
  pinMode(led2, OUTPUT); //this does not work ??
  pinMode(led3, INPUT); //this does not work ??
  digitalWrite(led1,LOW);
  digitalWrite(led2,HIGH);
//  digitalWrite(led3,HIGH);  --> If you already set it to input, don't write
  pinMode(led3, OUTPUT); //this does not work ??
  delay(500);

}


Go Up