What you will make:
In this tutorial, you’ll learn the most simple and one of the core aspects of Arduino, digital output, by blinking a LED.
What you will need:
For this project you will need:
- Arduino UNO with cable
- mblock software (download instructions here)
- Jumper wires
- Connect the components as shown in schematic.
- If you want to learn more about that white rectangular part called breadboard, check out our quick guide here.
- Plug in the Arduino with your computer using the cable.
- Download the mBlock software and open it up. You can find the instructions here.
- After installation your should be able to see this following icon in your Windows/Mac OSX/ Linux. Open this software with this icon.
- You should be able to see the following window opened. (In this example its a window of mBlock opened in Window 10 OS).
- Now select Arduino and Communication options in Extensions Tab
- Now select Arduino UNO in Boards Tab
- Now select Arduino mode in Edit Tab
- Your final screen of mBlock software with all the setup will look like this
- We are almost there now.
Make a simple LED blink program as shown above.
- Hint: match the colors of the program blocks with sections of script as shown below
- Now connect your Arduino Board to your laptop/PC using the USB cable you possibly got with your board.
- Go to Connect Tab in upper top bar and then go to Serial Port and Select your respective port no. to which your Arduino is connected e.g. ‘COM7’.
- On code main screen towards right as show in following picture. Select the Upload to Arduino option.
- After it says Upload Finish. You should be able to see an LED blinking connected to pin 10 on your Arduino UNO board .
Troubleshooting: If shows Upload failed then select another COM port. If problem still persists then attach Arduino with other port.
- Wait for a few seconds for uploading to complete, and with little luck the LED will start blinking.
Yes yes I know, some of you may be expecting to make their first robot, but you can’t write a book without first learning to spell A for Arduino and B for Bot.
What you essentially did back there is programming a digital pin to go HIGH and LOW consecutively. Observe that our code is divided into two parts, or functions in programming terms, which are Arduino Program() and forever().
Everything inside Arduino Program() function runs only once when the program first starts, and everything in forever() repeats itself as long as the board is powered.
We programmed our pin to stay HIGH (or ON) using the set digital pin() function, and then paused further execution of our program using the wait() function, which accepts time in seconds as input, in our case a 1 seconds. Try changing the delay to 0.5 or 2 , and the blinking will get rapid or slow respectively. After the wait we are turning our pin to LOW (or OFF), followed by another wait of one second.