Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

http://opensourcehardwarejunkies.com/tutorial-03-digitalread-and-serial-port-communication/

C++

Blocks

Code Block

void setup()
{
  pinMode (pinNumber, INPUT);
}
void loop()
{
  int buttonState = digitalRead(2);
  
if(buttonState == HIGH)
  {  // do something

  }
  
else
  {  // do something else

  }

}

 

 

image2020-1-21_21-21-50.pngImage Modified

In Tinkercad, we just need to Start Simulation, and click on the switch to turn it on/off.