Professional Documents
Culture Documents
IoT Quiz2 ComputerSciences Year4 LhetMombonhinhiEnyVieyrrah Magnan
IoT Quiz2 ComputerSciences Year4 LhetMombonhinhiEnyVieyrrah Magnan
1 Fritzing simulating
Items used:
1
In case the picture above is not readable, the code below is the same as the one in the
picture:
int buttonState=0;
//setup function managing the let and the button. Output for the led and input for the button.
void setup() {
pinMode(led, OUTPUT);
pinMode(button, INPUT);
}
2
//Loop function to manage the state of the led. To turn off the led and to turn on the led.
void loop() {
buttonState = digitalRead(button);
// The button is on by default so when clicking on the button it will become off
if (buttonState == 1)
{
digitalWrite(led, LOW);
delay(200);
}
if (buttonState==0)
{
digitalWrite(led, HIGH);
delay(200);
}
}
3