<< Previous Post | | Visit my Traditional Programming Blog | | Next Post >> |
Well, much has been written already online and in print media regarding setting up and writing programs for the Arduino. However, I decided to write about the bare basics, primarily for the sake of completeness of my blog and also for sharing my experience on a particular platform. Hence I will not reinvent the wheel, instead point you to relevant technical literature on the Arduino Foundation's website for the purpose of the first time setup, and then add some personal observations that may help you getting started additionally.
Bare Basics of First Time Setup
Depending upon the operating system of your computer, you may visit one of these links for a detailed step-by-step guide for setting your Arduino UNO R3 board and starting to write the first program.
Windows - https://www.arduino.cc/en/Guide/Windows
Mac - https://www.arduino.cc/en/Guide/MacOSX
Linux - https://www.arduino.cc/en/Guide/Linux
Provided below is my experience of setting up the Arduino on my Windows 7 laptop:
Bare Basics of First Time Setup
Depending upon the operating system of your computer, you may visit one of these links for a detailed step-by-step guide for setting your Arduino UNO R3 board and starting to write the first program.
Windows - https://www.arduino.cc/en/Guide/Windows
Mac - https://www.arduino.cc/en/Guide/MacOSX
Linux - https://www.arduino.cc/en/Guide/Linux
Provided below is my experience of setting up the Arduino on my Windows 7 laptop:
- While the framework gets installed there is no need to connect the Arduino board to your computer.
- After the installation is completed, and you connect the board for the first time, wait a bit for Windows to install the board drivers automatically.
- After the drivers get auto-installed by Windows, launch the Arduino IDE (you may find the shortcut on your desktop).
- Once the IDE is open, navigate to Tools menu and perform the Board and Port selections as instructed in the setup steps.
- Just to verify I double checked the board connection by navigating to the menu Tools > Get Board Info. If everything has been completed successfully, you should receive a pop-up with the board details such as Serial Number, etc.
- That is all, for the first time setup!
Arduino Program Structure & Execution
All Arduino C programs need at least two functions: setup() and loop(), as shown below in the Arduino IDE. To understand what is going on, we must appreciate these three things:
Figure 1 - Basic structure of an Arduino C Program |
- The C program, after getting loaded into the Arduino board, keeps running in an infinite loop, until the board is powered off.
- The setup() function is executed once, every time when the Arduino board is powered up. So all one time configuration/setup related code has to be written here. Think of it like a constructor.
- The loop() function keeps getting invoked infinitely. Whatever you write here will keep getting executed infinitely, until the power supply to the Arduino board is turned off.
Some advice for your Hello World with LED Blinking
Right after the installation you will be tempted to try the LED blinking lesson that comes with the installation guide. If you are blinking the onboard LED on PIN 13 then is should be straight forward. However, if you try to blink an external off-board LED, and if the LED does not blink for the first time, then do not get dis-heartened. There could be several reasons for the LEDs not working such as:
- Faulty LED (most common and in my case this is what had happened)
- Defective jumper wire cable (this also happened in my case)
- Defective Breadboard section rails (also common)
- Defective resistor
- Faulty circuit arrangement
Caution: Please remember to add a resistor to the LEDs always, otherwise they will burn out.
Cheers!
KB
No comments:
Post a Comment