CODE BLOCKS FOR LED BLINKING USING ARDUINO IN TINKERCAD

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

arduino led blinking tinkercad

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

codeblock led blinking tinkercad
Click to Enlarge

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). 

setpin Arduino block programming Tinkercad

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.

setpin 13 high Arduino block programming Tinkercad

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

wait block tinkercad

This means the LED will be ON for 1 second (1000 milliseconds).

set high and wait

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

setpin Arduino block programming Tinkercad

Similar to step 1, select pin 13 and set the state of the pin to LOW (0). 

setpin high wait low

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.

LED Blinking codeblock Tinkercad

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 – 

  1. First one is pin number and
  2. 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 –

  1. We set pin number 13 state to high
  2. Give delay of 1 second
  3. Then we again change pin number 13 state to low
  4. Then delay by 1 second
  5. 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.

led blinking output simulation tinkercad

 

[pad]


NEXT POST
CODE BLOCKS FOR RGB LED INTERFACING WITH ARDUINO IN TINKERCAD


PREVIOUS POST
LIGHT UP LED USING ARDUINO IN TINKERCAD