# Arduino Labs

## 2. Switch and LED Circuit with Arduino

Questions:

1. Without altering the code, you can modify the circuit so that the LED is turned on by default and only turns off when someone presses the switch by reversing the ground input and power supply connected to the pushbutton switch. By re-positioning the pushbutton switch in between the Arduino Uno Pin 3 and ground, its default value will be HIGH and will be LOW when you press the switch.

## 3. Potentiometer and LED Circuit with Arduino

Questions:

1. When the potentiometer is turned all the way down, offering lowest resistance, the value read at Arduino A0 is 1023 (5V).
2. When the potentiometer is turned all the way up, offering highest resistance, the value read at Arduino Pin A0 is 0V.
3. Voltage Divider Formula: Vout = Vin[R2/(R1+R2)].Vin=5V, Vout=2.5V, R1=10000‎Ω,  R2=??? So, in order for the voltage at Arduino Pin A0 to be 2.5V, the resistance offered by the potentiometer must also be 10,000‎Ω in order to halve the voltage coming out of the circuit.
4. The potentiometer value (potVal) is multiplied by 0.25 in order to set the brightness of the LED (ledVal) because the Arduino input pins convert voltage readings to a value up to 1023 (10-bits), while the output pins only operate up to values of 255 (that is, 8-bit). So, the potVal must be converted to 8bit values.

## 4. Potentiometer and Speaker Circuit with Arduino

Questions:

1. Although the speaker is connected directly to power and ground, it does not form a short circuit and is not dangerous because the speaker contains a built-in 8‎Ω resistor.
2. To increase the volume of the sound, you would have to either lower the resistance or increase the voltage, thus increasing the current/power running through the circuit.
3. So much fun!!

## 5. Photoresistor and Speaker Circuit with Arduino

Questions:

1. Without altering the code, you can reverse the behavior of the sound in relation to the light on the photoresistor by switching the orientation of the 10k‎Ω resistor and the photoresistor. In doing this, an inverse relationship is formed.