![](https://static.wixstatic.com/media/a7e1ad_ad316365c5d54fed8aae7fa9d857174f~mv2_d_2250_2371_s_2.jpg/v1/fill/w_980,h_1033,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/a7e1ad_ad316365c5d54fed8aae7fa9d857174f~mv2_d_2250_2371_s_2.jpg)
"This lab explores analog input and output using variable resistors. You will learn to read sensor values to the serial monitor and utilize pulse width modulation (PWM) and frequency modulation to affect outputs."
Part 1: Variable Input & Output
For part 1 of this lab we needed to build a circuit that had two inputs, a potentiometer and another variable resistor; I used a slide potentiometer. The output for the circuit is LEDs.
I connected the slide potentiometer to a 10k ohm fixed resistor and then connected the slider to pin A1. I soldered a potentiometer and connected it to pin A0. We need two LED outputs for this circuit, so I used my breakout board from the previous lab and a separate LED. The breakout board has two yellow LEDs and a 100 ohm resistor.
V= I*R ---->. R=V/I -----> R= Vs-Vf/I -----> 5-2-2/.02 ----> 50 ohms
Since I used 100 ohms for two LEDs, I used another 100 ohm resistor for the single red LED
The two yellow LEDs are connected to pin ~9 and the red LED is connected to pin ~10
![](https://static.wixstatic.com/media/a7e1ad_76ac3084df8b48aebfd4ebee8f8f1cf5~mv2_d_2448_2518_s_4_2.jpg/v1/fill/w_980,h_1008,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/a7e1ad_76ac3084df8b48aebfd4ebee8f8f1cf5~mv2_d_2448_2518_s_4_2.jpg)
The pictures below show the completed circuit. The next step was to write the code in Arduino. The potentiometer should change the brightness of the two yellow LEDs and the slide potentiometer should change the brightness of the red LED.
The first thing I did in Arduino was use the serial monitor to find the sensor range for the variable resistor. The range is from 0 to 1023 but it varies for each variable resistor.
Below is the code for the circuit.
Part 2: Tone Output
For part 2 of this lab we needed to create a circuit with two photoresistors (input) and a speaker (output). I connected the photoresistors to pin A0. Then I connected one end of the speaker to pin 8 and used a 100 ohm resistor.
![](https://static.wixstatic.com/media/a7e1ad_b25dac9256bf45c986ec425d6216e2f2~mv2_d_2339_1876_s_2.jpg/v1/fill/w_980,h_786,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/a7e1ad_b25dac9256bf45c986ec425d6216e2f2~mv2_d_2339_1876_s_2.jpg)
When you touch or hover over the photoresistors, the sound from the speaker changes. Low/High frequency.
Part 3: Laser Cut Sensor Box
For part 3 of this lab, we needed to laser cut a creative enclosure for a circuit with two different inputs and outputs. I worked with Ashleigh on this part of the lab. We had the idea of creating a mini tv for the enclosure. The inputs we chose include two potentiometers and photoresistors. The outputs are light and sound. We used the circuit from part 2 and added a potentiometer so the sound could be turned off. We adjusted the circuit from part 1 to include a neopixel strip and a potentiometer that changes the colors.
The tv was designed in Rhino, we measured all of the components and scaled accordingly.
We used a small piece of wood/padding to support the breadboard and Arduino. The photoresistors were initially on the breadboard but we decided to make a breakout board for them so they could be easily positioned.
The knob at the top changes the color of the neopixel strip and the second knob turns the sound on/off. The photoresistors are below the second knob and they change the sound.
Our code was combined into one Arduino file.
Below is a video of Ashleigh testing out the sensor box while I film.
Below is a video of me testing out the sensor box while Ashleigh films.