
Output
Interface
This
workshop will focus on connecting devices to Arduino and learning how to write
blocks to control those devices. The easy-to-understand behavior of the LED,
which serves as the simple output component, will be controlled by a program that
is written using Arduino.
Activity 1:- Single LED With
Arduino
According
to the discussion, we will attach the LED to the Arduino and write a program to
regulate its operation based on time.
Components Required:-
1. Arduino
UNO - 1
2. LED
- 1
3. Resistor
220 Ohm – 1
Connection procedure:-
- Pick and place the required components to the circuit area as per the above mentioned list.
- Connect the led cathode to ground of Arduino through the 220 ohm resistor
- As we know the Arduino can supply 5V in output but the LED’s requires 1.6V to 3.5V for its operation so to prevent the LED from the Excess voltage we are using the resistor.
- Next connect the LED’s Anode to any digital pin of Arduino here we have connected in pin number 12.
- Once we done with the connection click code menu in top left corner to see the programming Area.
Circuit Diagram:-
Programming Logic:-
- Under the programming section we can see the various blocks aligned under the six menus.
- There we can see few default codes inside the forever loop and empty on start loop. Delete all the default blocks and the On start block
- Here our task is to control the LED using Arduino and we know the LED is out device because Arduino is going to send the signal out to control it.
- So we have to select the block from the output menu, under output we can see lot of blocks.
- Here our LED connected in pin number 12 and to turn on the LED we to give HIGH and to turn off the LED we have to give LOW.
- So we can check for block which helps us to select the required pin number and allows selecting HIGH/ LOW with respect to the selected pin.
- The second block under output menu named as “Set pin 0 HIGH” satisfies our requirement so we can place the block inside our forever loop.
- After placing the block select HIGH to turn ON the LED and next we have set the on time for our LED.
- This means we are going to control the LED based on time and all the control options available under the Control menu.
- Under the control menu check for the block which allows you to set the time in terms of seconds or milliseconds.
- Pick the block named as “Wait 1 Seconds”, place it in our programming area and select the required ON time for your LED. Here we have selected 3 seconds ON time.
- Next pick place one more set pin Block or duplicate the old block to turn of the LED (To duplicate the block keep the cursor on the respective block and do the right click now you can see the option to duplicate it.
- In the second set pin block we have to select LOW to turn off the LED and place the wait block again to set the OFF time. Here we have selected 1 second OFF time.
- Once we done with the circuit connection we can start the simulation see the results in the same screen.
- Now we can observe the LED will be turned on for 3 Seconds and it will be in OFF for 1 Second.
- Now change the time delay and check how the led will respond based on the given INPUT time.
Program:-
.png)
0 Comments