LED Blinky
In this project, we change intensity of an LED at intervals of time by which we can see a twinkling effect.
Circuit
Components
- 1 Smowboard Think Mini
- 2 male-to-female jumper wires
- 1 LED (any colour)
- 1 100 Ohm Resistor
In the circuit, we use an LED that emits light when voltage is applied across it. The cathode pin of the LED is grounded by connecting it to the ground pin of Smowboard. To limit the flow of current in the LED, a 100 ohm resistor is connected in series with the LED on the cathode side. The voltage across the LED is controlled by connecting its anode to the pin number 2 of Smowboard. Smowboard then smartly varies the voltage on its pin 2, with respect to ground, based on the code written using Smowcode for it.
When a current will pass through the LED, the LED will glow. As the voltage across the LED is varied by Smowboard, the current will also vary due to which the LED will glow at different intensities.
Project 1: Blinking LED
Flow
To import this code to the Studio , copy it and paste it into the import nodes dialog box in the import section.
Let’s understand the code,
- The flow starts with an
on interval
node. All next nodes connected to it get triggered repeatedly after the specified interval of time. - Double click on the node to change its properties.
- We set the time interval of the
on-interval
node to 1 second. - We now connect a
pin write
node. We set it’s ‘Pin Number’ as 2 and ‘Pin Level’ as 1 to glow the LED. - After that, a delay node is used to add a delay of 1 second before the of next node,
pin write
runs. - This delay keeps the LED glowing for 1 second.
- Then, we use another
pin write
node and set its ‘Pin Number’ as 2 and ‘Pin Level’ to 0. This will turn OFF the LED. - After that, another
delay
node is used to add a delay of 1 seconds. The flow doesn’t restart before this node’s activity (i.e. delay) finishes. - This delay keeps the LED OFF for 1 seconds.
- Now, we upload the code to the Smowboard using the
upload
button on the Studio. - We can see the LED blinking as it turns ON and OFF every 1 second.
Output
Project 2: Twinkling LED
Flow
To import this code to the Studio , copy it and paste it into the import nodes dialog box in the import section.
Let’s understand the code,
- The flow starts with an
on interval
node. All next nodes connected to it get triggered repeatedly after the specified interval of time. - Double click on the node to change its properties.
- We set the time interval of the
on-interval
node to 1 second. - We then use an
analog write
node to glow the LED and to set its intensity to 35%. - We configure the
analog write
node by clicking on the pencil icon on the output property ofanalog write
node. We set the pin number as 2. We then click onAdd
anddone
button to complete the configuration. - After that, a delay node is used to add a delay of 1 second before the of next node,
analog write
runs. - This delay keeps the LED glowing at low intensity (35%) for 1 second.
- Then we use another
analog write
node and set intensity of the LED to 100%. - We configure this
analog write
node by clicking on the pencil icon on the output property ofanalog write
node. We set the pin number as 2. We then click onAdd
anddone
button to complete the configuration. - After that, another
delay
node is used to add a delay of 0.01 seconds. The flow doesn’t restart before this node’s activity (i.e. delay) finishes. - This delay keeps the LED glowing at full intensity(100%) for 0.01 seconds.
- Now, we upload the code to the Smowboard using the
upload
button on the Studio. - We can see the twinkling effect as the LED remains glows dim (35% intensity) for 1 second and then turns bright(100% intensity) for a short 0.01 second time.
Output
Learn Coding and Electronics easily using Smowcode.