HW for week4

3C6B6FB0-E632-4619-BE3A-8EEA36E5DAB8 6CB93C17-1DCB-43FA-AB33-128855B3BB87

871C4E07-1D7D-4D0E-BAE5-9C2FDC7D35BB

This circuit is about using a button to control two leds to flicking in different frequency.  I  changed a little from the  the first assignment. The button here is separate from the leds, and connect the arduino boarder with the A5 pin.

 

int led1=7;
int led2=6;
void setup()
{
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
}
void loop()
{
int i;
i=analogRead(5);
if(i>1000){
digitalWrite(led1,HIGH);
delay(200);
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
delay(800);
digitalWrite(led2,LOW);
}
else{
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *