PCOM assignment 1 : a button

here is the code :

int led = 13;
int controller = 2;
int n =0;

void setup()
{
pinMode(2,INPUT);
pinMode(13, OUTPUT);
pinMode(4,OUTPUT);
}

void loop()
{
n = digitalRead(2);
Serial.println(n);
if (n == HIGH)
{

digitalWrite(13,HIGH);
digitalWrite(4, LOW);

}
else {

digitalWrite(13, LOW);
digitalWrite(4, HIGH);
}
}

 

 

i  make a button to control one RGB led’s light color which is also a  switch for the  other 2 led .

here is the video

 

 

 

Leave a Reply

Your email address will not be published.