Arduino and Circuitry


Building circuits with multiple circuit components is an important skill that will be very useful to applications in EGR 101 and in future engineering classes at Duke. Circuits with an Arduino can be used to provide light through an LED, create noise through a speaker, or power a stepper motor through a PWM signal.

In this Instructable, we will be taking a look at how to build a LED and button circuits to provide a foundation in circuit building with an Arduino. The first project we will be building will be a circuit that can blink an LED in intervals of 1 second, and then we will be modifying that circuit to incorporate a push button.

Also, please note that while example code and diagrams are given to you for this Instructable, it is important to use the examples to learn how to draw circuit diagrams, create Fritzing circuit diagrams, build physical breadboard circuits, code in the Arduino IDE, and test/troubleshoot the circuit.

Step 1: Safety

Before beginning to work with any electronics, it is important to follow these safety guidelines to prevent injuries to yourself or the equipment:

1. Tie back any loose hair.

2. Wear appropriate clothing for the job, such as closed toes shoes.

3. Remove any dangling jewelry.

4. Wear safety glasses.

5. Always work with a partner in case an accident happens.

Also, make sure that you follow these specific electronics guidelines when handling electronics:

1. Discharge your body of static by touching a surface like the wall before working with electronics

2. Always double check the polarity of the device that you are using before inserting it into a circuit

Step 2: LED Sketch Circuit

To start learning how to create a circuit with Arduino, we will be building a very simple LED circuit that blinks in intervals of 1 second. An video of the circuit working is shown above.

The following steps will give you correct examples in images and walk you through how to make these pieces of the circuit. While this whole Instructable is not graded, it is important that you understand why each example is correct and be able to use this Instructable in making your final Arduino Tools Mastery product.

Step 3: Downloading the Arduino IDE

To begin work with Arduino on your computer, you have to download the Arduino IDE for your respective device from the Arduino website at

Once downloaded, upon opening the IDE, the IDE should look similar to the image above.

Step 4: Configuring the Arduino IDE

Before we can use the Arduino IDE, we must make some changes in the settings in order to be able to upload code to an Arduino.

Make sure you plug in the Arduino to your computer with a USB printer cable and then open up the Arduino IDE.

The settings that need to change will be found under the Tools tab in the menu bar. The first setting we have to change is the Board setting so that the IDE is uploading code to the correct board type. When you open the tab for boards, a list of different types of Arduinos will open up. For this instructable, we will be using the Arduino/Genuino Uno board. Please select the Arduino/Genuino Uno board like in the picture shown above.

After selecting the board, you will now select the correct port. This port tab is found underneath the Board tab, and you will select the COM with the Arduino Uno indicator next to it.

With this configuration done, you are ready to code on Arduino!

Step 5: Sketching a Circuit Diagram/Schematic

With your Arduino configured, we need to figure out what we want to do first before writing any code or building a circuit. To do this, we need to make an electronic or hand drawn schematic of the circuit first.

A circuit diagram/schematic is a drawing of how the connections of your circuit are going to connect together. This schematic will act as the blueprint for building the physical circuit and also as the starting place for any necessary circuit troubleshooting.

To draw your circuit diagram, use the following steps:

1. Pick your circuit elements that you plan on using in your circuit

2. With your selected circuit elements, sketch out how each circuit element will be connected together via wires by using each circuit element's schematic symbol and connecting them with a solid black line. For information circuit diagram symbols for the different components, please see this link to correctly draw your components in your schematic:

Also, be sure to look online to see how circuit elements are supposed to connect together. For example, a resistor must be connected in series with and LED in order for the LED to work because LEDs require a lower current flow than what the Arduino outputs.

3. With your circuit symbols connected together, make sure to have them drawn in their correct orientation. For example, an LED must have its anode end be powered first before its cathode end.

A good circuit drawing needs to be either a neat electronic or physical drawing, have circuit elements clearly labelled with their appropriate schematic symbol, and have the values for each circuit element labelled.

The example circuit diagram above is a correct way to draw the circuit diagram for the LED circuit that you should build. As seen in the diagram, the voltage signal from the Arduino will exit from digital pin 12, goes through a resistor of 220 Ohms into the anode end of the LED, exits out of the cathode end of the LED, and then back into the ground pin of the Arduino. (Note that digital pins on an Arduino can send a HIGH or LOW voltage signal. If you want to learn more about the Arduino pin functions, I would recommend researching on your own about Arduino).

Step 6: Designing Your Physical Circuit on Fritzing

After finishing your schematic, it is very helpful to design your circuit on Fritzing so that you can plan how to wire your circuit on a breadboard. In order to use Fritzing, download Fritzing at the following link:

After downloading Fritzing for your respective device, you will electronically wire your circuit on Fritzing based on your circuit schematic that you made before.

To use wire your circuit on a breadboard, use the Breadboard tab at the top of the program. From there, you can import circuit elements from the "Parts" sidebar on the right. In this sidebar, you can find different types of electrical components such as Arduinos, LEDs, and push buttons.

To create wires, Fritzing automatically creates a wire when you click and hold from a pin on the breadboard or an Arduino. By clicking and holding the end of a created wire, you can move the wire end to connect two pins together. From here, you can click and hold the middle of the wire to make the wires neater like the ones in the example.

For more information and tutorials on how to use Fritzing, please use the following site for Fritzing tutorials and references:

The video above provides a walkthrough on how to create the Fritzing file of this LED circuit. Recreate the Fritzing file as seen in the example above, using the video for help if necessary, and save it. From this file, you can then modify it for your own circuit design.

It is imperative that you learn how to draw a schematic and use Fritzing because engineers in the real-world use them both for developing circuits. It will help tremendously as you begin to build your physical circuit.

Step 7: Building Your Physical Circuit on a Breadboard

After making your schematic and the Fritzing file, you may begin to build your circuit on a physical breadboard. To begin building, gather the material needed to the make circuit. This includes the following:

- Breadboard

- Jumper Wires

- An LED

- A 220 Ohm Resistor

- Arduino Uno

Breadboards work by having many different pins on a grid that can be used to plug in circuit elements and create a prototype circuit. Breadboards have conductive strips of metal that transmit current across multiple pins. This is seen in the picture above in how the middle pins of the bread board conduct current across in rows, while the pins conduct current in a column along the rail.

To determine how many Ohms a resistor has, refer to the resistor's color bands. The color bands follow the color band code found in the images above. For example, the 220 Ohm resistor has a color band pattern of red, red, brown, gold.

Before building the circuit, make sure the Arduino is turned off by unplugging any power sources connected to the Arduino, including your computer. Then, by following the Fritzing file and the circuit schematic, build the circuit onto the breadboard with the materials you gathered. Be sure to insert the LED correctly by connecting the anode end of the LED into the row with the resistor and the cathode end to the ground wire. The cathode end is denoted by the flat side on the LED's casing and the anode end of an LED is denoted with the longer LED lead.

After building the circuit as seen in the Fritzing file, you may move on to the next step.

Step 8: Writing the Arduino Code

After building the circuit, all there is left to do is write the code on the Arduino IDE and upload it!

In the images above, there is a correct example of code for the LED circuit above with comments and proper attribution. This code was modified slightly from the Blink.ino example from Arduino to work with the circuit we made by using the digital pin 12 of the Arduino. While we provide you with this example code, it is still important for you to learn the specific syntax of Arduino coding that went into the example code so that you will be able to write your own code in the future.

The code utilizes a constant int value so that the LED pin can be changed easily. The main functions used in this code are digitalWrite(), pinMode(), and delay(). You can infer what these functions do based on the comments, but it would beneficial to read more about Arduino syntax and different Arduino functions at so that you can create your own code in the future.

Keep in mind that when creating code, you must comment your code and provide code attribution at the top. To create comments, use two forward slashes ("//") for a line comment or block comment with an your comment starting with a forward slash and asterisk and ending in an asterisk and forward slash (/* your comments */). These comments should be concise and provide information about what your code is doing. This allows a reader to know what your code is doing on a high-level and shows that you understand how your code is working.

For attribution, if you used code from an online resource or from an example with permission, it is important to give credit to where you go your code from. To attribute code, use a block comment at the top of the code file with what your code does, where you got code from (include a link if possible), the date that you modified it, and who modified it. See the examples above for reference.

Copy the code and upload this code onto the Arduino by verifying and uploading with the two circle buttons in the top left of the Arduino IDE. If your circuit behaves by turning on the LED for one second and then turning it off for one second repeatedly, like in the video above, you may continue on to the rest of this step. If not, troubleshoot to figure out what went wrong with your circuit. To troubleshoot, start with your schematic, then your Fritzing file and physical circuit, and then your code.

After verifying that your circuit works correctly with the Blinking_LED.ino file (there is a video of a Blinking_LED circuit in the images above), try experimenting with the LED circuit to make it do the following:

- Make the circuit blink the LED, but instead of pin 12, use pin 6 instead.

- Make the circuit blink the LED with intervals of 5 seconds instead of 1 second.

Once you successfully change the code/wiring to make the circuit perform the actions above and understand why, change the code back to the original example code and move on to the next step to learn how to add a push button into the system.

Step 9: Modifying the Circuit to Add a Push Button

In this step, we will be adding a push button to the circuit so that the LED turns on when the button is pressed. We will need to modify how the code and circuit works in order for this behavior to be achieved.

Starting with the schematic, we have to add the push button. A push button works by having two different terminal ends that are normally opened when the button is unpressed, but when the button is pressed, the two ends become connected together and current can flow.

We will be using the Arduino to detect whether or not the button is pressed, so we will connect one of the terminal ends to digital pin 2 and the ground pin with a 10k Ohm resistor. We will connect the 5V pin to the other terminal end of the button. So, when the button is not pressed, the Arduino is reading a LOW voltage value at digital pin 2 because it is connected to ground; however, when the button is pressed, the button connects the 5V pin to pin 2, which will then cause the Arduino to read a HIGH voltage value at digital pin 2. The 10k Ohm resistor makes it so that there will be a voltage drop that can be read. This is the premise of the button that we will use in order to actively change states in this step.

Moving on to the Fritzing file, we must create design the circuit so that the behavior described above is fulfilled. This is done by plugging in a wire from the digital pin 2 to a terminal end and then the ground port on the same terminal end (a push button has 4 metal legs that curl inwards; a terminal end is denoted by one pair of legs that point towards each other). Then, connect the 5V pin to the other terminal end and our Fritzing file is complete. The Fritzing file and schematic are provided for you; make sure you understand why their circuits look like that so that you can make your circuits with buttons and LEDs work.

Next, follow the Fritzing file with building the physical circuit on a breadboard. If you want to make sure you know which sides of the button are connected together, you can test continuity with a multimeter.

Then, write the code for the modified circuit. This code is going to differ from the previous code in that we are depending on an input from the button in order to turn on the light. This is the basic premise of a logic statement of if the button is pressed, then turn on the LED. So, the code will incorporate an if-else statement that will turn on the LED when the Arduino senses a button press, and turns off the LED when the button is not pressed. The Arduino senses this by using the digitalRead() function to see if there is a HIGH or LOW voltage. Refer to the website for more information on if-else statements or the digitalRead() function if necessary. Also, be sure to comment your code and attribute your code as well.

Lastly, test and troubleshoot your circuit. If your circuit behaves like it should, congratulations! You have completed a very useful Arduino circuit and you can move on to making your own circuit in the Electronics Tools Mastery Project. If not, double-check to see if your schematic is correct, then your Fritzing file, then your physical breadboard circuit, and finally your code.

With this Instructable, you will probably find this useful in completing your Electronics Tools Mastery Project. Please keep in mind the safety rules as you work on it and read the instructions to the assignment carefully. You may use the examples in this Instructable as references, but be sure to provide necessary documentation, such as attributing code. Good luck on your Electronics Tools Mastery Project and any future circuits that you will build!



    • Sensors Contest

      Sensors Contest
    • Growing Beyond Earth Maker Contest

      Growing Beyond Earth Maker Contest
    • Classroom Science Contest

      Classroom Science Contest