September 21, 2022
Yellow Highlight >> Questions for Monday’s PCOMP Workshop
I’m glad there are instructions for this because prior to realizing this is a way to find the sensor range, I tried looking up the component’s data sheet in hopes that it would be outlined clearly there but got lost trying to read the data sheet.
Sensor range for FSR
Sensor range for phototransistor
How does int analogValue differ from int sensorRead >> There is no significant difference because they are both personally set naming conventions and functionally serve the same purpose, which is set to analogueRead.
What is the role of resistor values in creating voltage divider when using certain components in the circuit? How do I know what resistor I need, or how do I know what would be a compatible range?
After re-reading the articles on sensors and asking Elias to clarify, I got the general understanding that sensors in voltage divider circuit, changes in mechanical (or other forms) energy > changes in electrical resistance > changes in voltage. Voltage is the amount of potential energy between two points. Microcontrollers read the change in voltage at a specific point. So, in a voltage divider circuit with a variable resistor and fixed resistor, if the microcontroller is connected between the two resistors, it reads the voltage from the connection point to the source. And, since resistors require a certain voltage to conduct, the microcontroller’s voltage reading is the difference between the voltage of the resistor and the power supply. So, if the variable resistor in the circuit described above, is for example, a potentiometer that is set at 2 volts, and the power supply is 5 volts, the microcontroller would read 1 volt (or high/low since the microcontroller pins only read digital inputs). If the microcontroller was connected above both resistors, it would read 5 volts. If the microcontroller was connected below both resistors, it would read 0 volts and be essentially connected to ground.
To also follow up on my question in class about how resistor value influences the circuit: The fixed resistor value need to be high enough to pull the remaining voltage to zero/ground. If it is too high, then it would be like there was nothing there and none of the current would go to ground. And, we need it to go to ground. If it is too low, the circuit risks short circuiting from the voltage feeding back into itself. I learned from Elias that usually, you should choose a resistor value of a magnitude higher than the components used in the circuit.
I also tried playing tones with the phototransistor, but the tone barely changed when I waved my hand around the phototransistor (Video 1). I tried adding more light instead of removing light by shining my phone’s flashlight on the phototransistor, which gave me a wider range of tones. However, I wasn’t able to film with the flashlight on, so I tried using my laptop’s screen light to raise the overall light around the phototransistor and covered parts of the light with my hand to control the tone being played instead (Video 2). I ended up noticing that my sensor mapping range was still the same as I had set when using my FSR, even though I switched my analog input pin to read from the phototransistor instead of the FSR. So, I used the serial monitor to find the phototransistor’s sensor range (which ended up being around 0-30) like I did when first setting up the FSR (Video 3). The tonal change was still rather subtle, so I tried putting the phototransistor near my laptop screen again (with the lowered sensor range values) and was able to get a more noticeable tonal change when controlling the incoming light to the phototransistor.