The intent of this intro to arduino, is to explain the basics of Arduino. This is a great place to start, if you’re just starting out with Arduino programming.
What is an Arduino?
Arduino is actually the language running on your device. What people know as an Arduino is a microcontroller, which runs whatever code you’ve uploaded to the device. Arduino was created to simplify electronics prototyping, but it can be used in more permanent situations. The following is the most popular board, the Arduino UNO. You can get one here.
What is an IDE?
IDE stands for Integrated Development Environment. There are a lot of programming languages that provide an IDE for you to work in, compile your program for execution, and deploy the finished product to your Arduino. Download the IDE here.
What is compiling?
When your program is compiled, it is being built. What this does, is converts your more “people readable” code to a language that your Arduino can understand.
How does Arduino work?
There are 4 parts of Arduino code that you need to understand. They are very simple, and easy to follow. Arduino is a dumbed-down version of the C programming language. C has been around for a long time, and will be for years to come. The following are the 4 parts to Arduino code, the images are going to be from the code in my “Hello World:Serial” tutorial:
- You define any libraries you’d like to include in your project, libraries will be explained in another post. You don’t need to know about these yet
- You define any global variables you’d like to set before running the main part of your code.
- This is a run-once part of your code that prepares things, some sensors need to be fired up, or initialized, before you can begin reading from them.
- Some times you need to do things like connect to wifi, that may only get done once.
- This is your main code, this loop will run forever until the world ends, or until you disconnect power from the device.
- I’m just calling this post loop, it’s actually an area where you can define functions for your code.
- You’ll learn that functions are very handy when your code gets long. Some of my Loop statements are only 4 lines long, because they are looping through functions.
- Anything you put here, is to simplify repetitive tasks, and/or clean up your code.
Is there code that isn’t run?
Yes, you can comment out lines of code. Commenting allows you to “hide” code from the compiler, if you’d like to test your code without a statement or have a reference inside your code for later. Commenting is also a great way to add a “bookmark” to your code, so you can identify sections of code easier, and remember what they are for. Adding a comment is as simple as putting // at the beginning of the line you’re commenting out.
You can keep reading, to find out how to communicate with your Arduino via a Hello World example.
I hope you enjoyed my introduction to Arduino. Let me know if you have any questions, I’d be happy to answer them! Please subscribe below to get the latest posts by Anarchy Development.
Join the newsletter
Subscribe to get our latest content by email.