top of page

Lab 4:Arduino & analog i/o

Part 1: Analog Input &Output

Completed Analog I/O

Analog I/O Schematic

Step-by-Step Process

1)The power and ground for the circuit were set up by inserting 2 jumper cables into the Arduino; one in the 5v slot, and one into the ground slot on the analog side. I then put the other end of these cables into the corresponding rails on the left side of the breadboard. Another small cable was used to connect the power to the right side of the board.

2) A jumper cable connected digital pin 9 to the breadboard next to a 220 Ohm resistor. An LED was placed next to the resistor, and its cathode was connected to ground. I repeated this process for digital pin 10. 

3) A cable was then inserted into analog pin 0, and placed into the breadboard, directly in front of the central prong of a potentiometer. Two more cables were placed behind the other two prongs of the potentiometer, connecting the right side to power, and the left side to ground. This allowed the LED to get brighter when the dial was turned right. 

4) A small cable connected power from the left side of the board to the breadboard. One end of a 10k Ohm resistor was inserted next to the cable, and the other end was placed next to a Light Dependent Resistor (LDR). A small cable connected the other leg of the LDR to ground on the right side of the board. The 10k resistor and the LDR were situated so that their legs could intersect in row 45.

5) One end of a cable was inserted into analog pin 1, and the other end was placed at the intersection of the 10k Ohm resistor and the LDR to listen for an input.

6) My Arduino was programmed to use analog pins 0 and 1 as inputs, collecting information from the potentiometer and the LDR. The two LEDs and their respective pins 9 and 10 were initialized as outputs to communicate the changing analog resistance from the two variable resistors. The range of the sensors were then mapped to suit the range of the LEDs. 

7) I tested my circuit using the serial.print() function to see if the outputs and inputs of my pins seemed reasonable, and to see how they would change when the sensors were manipulated. This confirmed that both sensors were working. In the video below, I decided to use my phone flashlight to shine light onto my LDR to get a more visible response from the LED.

 

NOTE: my 10v battery was dead, so I had to use the power supply from my laptop, but the code is uploaded to the Arduino.  

Testing Analog I/O

Materials Used

  • jumper cables (11)

  • 220 Ohm resistors (2)

  • 10k Ohm resistor (1)

  • Light Dependent Resistor (1)

  • LEDs (2)

  • potentiometer (1)

  • breadboard

  • Arduino Uno

bottom of page