Coursera Assignment 1


Coursera Assignment 1


I have build a circuit which has two pushButtons connected to the pins redButtonPin and yellowButtonPin. And a led connected to the pin ledPin.

When the any of the button is pressed the led will turn on. You can see the code below :-

 
int ledPin = 7;

int redButtonPin = 11;
int yellowButtonPin = 9;


int redButtonReading = 0;
int yellowButtonReading = 0;


void setup()
{
  pinMode(ledPin, OUTPUT);

  pinMode(redButtonPin, INPUT);
  pinMode(yellowButtonPin, INPUT);
}

void loop() 
{
  redButtonReading = digitalRead(redButtonPin);
  yellowButtonReading = digitalRead(yellowButtonPin);

  if( redButtonReading == HIGH   ||   yellowButtonReading == HIGH )
    digitalWrite(ledPin, HIGH);
  else
    digitalWrite(ledPin, LOW);
} 

Comments

Popular posts from this blog

4.Sort an array of 0's, 1's & 2's.

1. Reverse

3. Height of Binary tree