Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 112 - 2629_Devagiri_C-7
P. 112

    Step  12    Click  on the  Start  Simulation button to  see  the LED  blink  ON and  OFF with the
                                  specified delay.

                      Text based programming:

                       Step  13    Click on the EDIT MODE dropdown button and select the Text option. The code you
                                  created will be displayed here.

                      Here’s an explanation of the code you created:

                          void setup(): This is a built-in function in Arduino programming. The code inside the
                         setup() function is executed once when the program starts. It is typically used for initialising
                         things, like setting pin modes.
                          pinMode(13, OUTPUT): This line sets pin 13 as an output. This means that pin 13 will send
                         out electrical signals to control something (in this case, an LED).

                          void loop(): This function runs repeatedly after the setup() function. Everything inside
                         loop() will execute over and over again, allowing the LED to blink continuously.

                          digitalWrite(13, HIGH): This sends a high voltage signal to pin 13. In the case of an LED,
                         this will turn it on.
                          delay(10000): This pauses the program for 10,000 milliseconds or 10 seconds. The LED
                         stays on for this duration.

                          digitalWrite(13, LOW): This sends a LOW signal to pin 13, which turns the LED off.
                          delay(2000): This pauses the program again for 2,000 milliseconds or 2 seconds. The LED
                         remains off for this duration before turning on again.

                      The LED turns ON for 10 seconds and OFF for 2 seconds, repeating this cycle. This confirms that the
                      Arduino is correctly programmed and the circuit is functioning as expected.

                       110
                            Premium Edition-VII

| 107 108 109 110 111 112 113 114 115 116 117 |