One button controls the light

One button controls the light

Physical computing - Master the challenges and experience how to connect the physical and virtual world

Easy

15 mins

from 8 years on

1What you need
- LED - button - 4 wires
2Challenge
####Connect an LED and a button to the Calliope mini. When you press the button, the LED lights up. When you release it, the LED turns off again.
3Solution
###Code

Note: This program code is nested. The parameter block "digital read pin P1" is executed first and the result (state of the pushbutton) is transferred to the block "digital write pin P2", which switches the LED on or off.

Electronics

LED (+/-)!

  • short leg: GND (-)
  • long leg: analog output (P2)

Button

  • outer leg: digital input (P1)
  • outer leg: VCC (+)

This text as well as the image is published under a CC BY-SA 4.0 DE license popup: yes. It was originally published in German popup: yes by phzh popup: yes and translated into English by the Calliope team.