Pages: [1]   Go Down
Author Topic: need help with LED controlling/disabling an out put  (Read 216 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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);

}
« Last Edit: May 06, 2013, 02:50:55 am by ingar195 » Logged

SG
Offline Offline
God Member
*****
Karma: 11
Posts: 532
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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);

}

Logged

Pages: [1]   Go Up
Jump to: