Table of Contents
LED BLINKING USING ARDUINO IN TINKERCAD
Blinking means turning ON an LED for a few seconds, then OFF for seconds, repeatedly. In this section, you will learn LED blinking using Arduino in Tinkercad.
REQUIRED HARDWARE OR COMPONENT
S.N. | COMPONENTS | QUANTITY |
1. | Arduino | 1 |
2. | LED | 1 |
3. | Resistor (280 ohm) | 1 |
4. | Connecting Wires | Few |
CIRCUIT DIAGRAM
CONNECTION TABLE FOR LED BLINKING USING ARDUINO IN TINKERCAD
S.N. | Arduino | LED |
1. | 13 | Anode (+) |
2. | GND | Cathode (–) |
CIRCUIT EXPLANATION
Here, The anode (+) and cathode (-) terminals of LED are connected to pin 13 and ground (GND) of Arduino Uno respectively and a resistor of 280 ohm is placed between the LED anode terminal and pin number 13 which help us to limit the current and prevent LED from burning.
If we do not connect the resistor here we will get a message in software during simulation that “current through LED is 52.3 mA, while the recommended maximum is 20.0 mA”. The usable lifetime of the LED may reduce. That’s why there is a need for a resistor to reduce the current.
ARRANGEMENTS OF BLOCKS AND TEXT CODE PROGRAMMING FOR LED BLINKING
CODE BLOCKS AND TEXT CODE EXPLANATION
BLOCK EXPLANATION
Step 1: Firstly select the output block. Drag set pin command from it and drop on scripting area (work area).
After that, click next to set pin and select 13 from the dropdown menu and then select HIGH and from the next dropdown menu which is a state, select HIGH means “1”, for digital pin 13. HIGH is required to glow an LED while LOW is required to turn it OFF.
Step 2: Then, we will click on the control block and drag wait command block from it and drop on the scripting area(work area) below set pin command
This means the LED will be ON for 1 second (1000 milliseconds).
Step 3: Again, click on the output block. Drag the set pin command from it and drop on the work area below the wait block command
Similar to step 1, select pin 13 and set the state of the pin to LOW (0).
Step 4: Repeat step 2, for wait or delay but you can change delay timings suck as 500 ms, 1 sec or 2 sec etc.
Step 5: All steps above execute infinitely and you will see continuously LED blinking using Arduino in Tinkercad.
TEXT CODE EXPLANATION
Step 1: In setup() function it automatically generates lines of code as soon as we select it on the set pin in blocks.
The Function “pinMode( )” has been defined here in the pin working mode as an input/output.
In this function, we have to pass two arguments –
- First one is pin number and
- Second is its mode, pinmode(pinNumber, mode).
In this we set pin number 13 as output: pinmode(13, OUTPUT).
void setup() { pinMode(13, OUTPUT); }
Step 2: In loop function we are using two inbuilt functions that are digitalWrite() and delay().
Function digitalWrite() is used to instruct the controller/Arduino to set the state of a particular digital pin as LOW or HIGH. In the digitalWrite() function we also pass two arguments that are one is pin number and second is state digitalWrite(pinNumber, state). We are setting pin number 13 as high.
And the second function is delay() which is used to provide a delay to the upper instruction so that the next instruction will wait till the delay time gets completed. In delay, we pass one parameter that is time to be delayed in milliseconds. Here we want to delay the pin number high state for 1000 milliseconds or 1 second. In simple words –
- We set pin number 13 state to high
- Give delay of 1 second
- Then we again change pin number 13 state to low
- Then delay by 1 second
- And the loop will start repeating instructions again and again.
void loop() { digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); }
And the loop gets executed continuously and follows the same pattern.
START SIMULATION FOR LED BLINKING USING ARDUINO IN TINKERCAD
Click on the start simulation button to perform the Light up LED program and to test the circuit.
[pad]
NEXT POST
CODE BLOCKS FOR RGB LED INTERFACING WITH ARDUINO IN TINKERCAD
PREVIOUS POST
LIGHT UP LED USING ARDUINO IN TINKERCAD