Do you want to use the Arduino to develop Arduino based circuits?
If so, you’ve come to the right place.
In this guide, i will introduce you to the Arduino IDE (Arduino Integrated Development Environment), different electronic components and the greatest Arduino beginner kit.
The best part?
I’m going to show you how to program your very own circuit into doing what you want it to.
Following products will be reviewed at the end of this post:
The Arduino IDE used in this project can be downloaded here (FREE). If you want learn more about the Integrated Develepment Environment in the Arduino Uno R3 microcontroller board, you can check out our post by clicking here.
Getting to know your breadboard
Now, you might want to watch this video explaining how a normal breadboard works:
(Skip to 1:50 to get straight to the point)
Credit: Parallax Inc. Rights Reserved.
This is a 400 tie point solderless breadboard and it’s what we’ll be using to connect electrical components to eachother. The breadboard is included in the Arduino kit.
Feel free to skip the following part, if you want to skip the details and get started with building the circuit itself, scroll down to “Time to create your first circuit”.
The Arduino IDE
Once you’ve downloaded, installed and opened up the Arduino software, you’ll see this interface:
Right away, we see two bits of code.
void setup() and
void loop(). We can also see two sentences that are in grey. These are comments marked with “//” and will be ignored by the computer. As explained by the comments,
void setup() only runs once, and sets up the Arduino.
void loop() runs continuously as long as the Arduino is connected to power.
void loop()is basicallly the meat and potatoes of your code.
Using example sketches
At first we’re going to use pre-written open source Arduino projects found in the IDE. I will break down the code for you and help you understand how it all works.
Each project you write is called a “sketch”. To open the example sktech, simply go to “File” –> “Examples” –> “01. Basics” –> “DigitialReadSerial”
Your sketch should look like this:
(this is the best arduino based project to start learning with)
Before you continue reading, make sure you’ve read all the comments inside the sketch so you have an idea about what it does.
Declaring and initializing variables
On line 9, the variable
pushButton was declared and initialized. This means that we assigned it a value, 2 in this case, and we gave it a datatype. The datatype for
pushButton is integer, this means the only accepted data
pushButton can store is whole numbers. To declare an integer variable we use
int. Also, each statement ends with a semicolon.
The Serial.begin function
Serial.begin makes essentially makes it possible for the Arduino to communicate with your computer while running code. The Arduino uses 9600 bits per second to communicate, hence
(9600). But that’s to complicated to get into now.
The pinMode function
pinMode function takes two inputs, a pin number and the pin mode you want to set it to. For instance, in this project we will set
pushButton which represents pin 2, to an
INPUT pin. This is because we want to measure whether or not pin 2 is being applied voltage.
This is the function which this project is built around. The
digitalRead function reads the state of a digital pin, which is either 0 or 1. If we apply voltage to pin 2
digitalRead(pushButton) will be equal to 1, otherwise 0.
We now initialize a new variable, just like we did in the beginning, and we assign this value to that new variable. We will use this on the next line.
Serial.println function prints its input to the serial monitor which we will soon access.
Since the input we give
buttonState (either 0 or 1), we will now print either 0 or 1 (depending on the voltage applied) to the serial monitor.
Remember, this will happen continuously since it’s inside the
void loop function.
Finally, we use the
delay function to delay by 1 millisecond for a smooth run.
Time to create your first circuit
The circuit requires a breadboard, some jumper wires, a pushbutton, a 220 ohm resistor and of course an Arduino Uno R3 to function as your microcontroller. All of this can be obtained by purchasing the basic breadbaord kit AND the Arduino Uno R3 (made by Elegoo) OR this great Arduino Starter kit.
This is the schematic for the circuit:
The small thing with 3 stripes is a resistor and increases resistance. In the products on this page the resistors are with 5 stripes, and should be Red, Red, Black, Black, Brown (220 Ohm). You can use this calculator to decide the resistance level of a resistor.
As you can see we have connected the red power rail to the 5V supply on the Arduino, and the ground rail to the GND pin. We then connect the pushbutton and the resistor as well as pin 2 which will be measuring the voltage applied. You can also attach an LED light. If you don’t know how to do so, we will soon have a guide on that as well.
Now simply connect your Arduino to your computer and upload the code using the USB cable. Your computer will also function as the power supply.
The last thing we have to do is to open the serial monitor.
Using the serial monitor
To access the serial monitor you will have to go to “tools” and “serial monitor” this will monitor pin 2.
Now, whenever you press the pushbutton the serial monitor will display 1.
What to Buy
I’ve found the best products which you as a beginner should use if you want to get started with programming, coding and building circuits.
This great Arduino Starter kit Compacts everything you need right now. This kit is suitable for beginners as well as more seasoned programmers. The kit comes with fascinating electronic components such as light, motion and temperature sensors while still containing the most essential ones like a variety of resistors, LEDs and pushbuttons. Arduino is of course included.
This makes it perfect for a ton of cool arduino based projects!
Since it’s sold as a complete kit, you only pay $23.99!
If you think the starter kit seems like a bit too much for you, i would recommend buying the Arduino by Elegoo and also the simple starter kit listed uderneath. The arduino electronics kit includes the very essentials for your circuit-building and so you’ll miss out on the cool gadgets. The total price will be almost $24.
I recommend buying the full kit above to get the most bang for buck.