Playing with LEDs
LEDs
- An LED (Light Emitting Diode) is a device that emits light when an electric current passes through.

- There are several types of LEDs, with different sizes and colors. There are even some that can light up with any color (RGB). 
- There are also RGB LED strips that are widely used for home automation and lighting in public places.   
Connecting the LED
 For all boards with digital and analog connections.
- Connecting the LED to the board is done in a similar way to the potentiometer, but in this case we will use the digital pins instead of the analog ones.

- The colors of the cables and pins must be respected, otherwise the LED will not light up. 
- To test how it turns on and off, we will use the block - set digital pin _ to _from Pins category, while changing the state of the logic switch.
 
Challenge 1: try to create a program that makes the blinking effect (blink) with the LED

Solution to challenge 1
 
Challenge 2: Make the blinking effect faster or slower depending on the value read from the potentiometer

Solution to challenge 2
 
Brightness control
- MicroBlocks allows analog values to be used on digital pins, so we can manipulate the level of light emitted by the LED. 
- For this we will use the block - set pin _ to _that we will find in the Pins category.
 
- As the range of values is the same for the inputs as for the analog outputs, we can insert the analog reading block directly inside the previous one.
 
Challenge 3: Make the LED turn on gradually, like a beacon or a visual alarm.
Hint: Use a variable to control the brightness.

Solution to challenge 3
 
| ⬅️ Previous activity | Next activity ➡️ | 
|---|
					© by Citilab Edutec 2019-2025.
					This work is licensed under a CC-BY-SA 4.0 license.
				
