Week 3
In Class
In class, it began with a lot of our lab questions being answered. One important thing that I learnt that I felt like I wasn't clear about was understanding how serial numbers worked, and also how to read them. Through the serial plotter, we could monitor the changes in the serial numbers, and sometimes it lines up with the pattern of your heartbeat, which was really interesting to learn about.
Then, the other lab questions were about the Force sensor lab and how that should have a limited range, and we can add the limited range with this:
constrain(brightness, 0, 255)
I had questions about the potentiometer lab. I was wondering if the potentiometer was working correctly. The potentiometer wasn't dimming as well as I thought. Then I learnt that the potentiometer changes the light on a logarithmic scale, so that we could map the potentiometer to a logarithmic scale or ten different states. Hence, it dims more smoothly. In class, Arjun asked how many LEDs might be marked on various states, and it made me think that that's such a tedious process. There must be a more efficient method.
Another interesting fact that I learnt while lab questions were being answered was that the EU bans photoresistors.
Furthermore, in class, we learned that Fritzing is a valuable tool for drawing circuit schematics. However, it is paid. However, the good part is that the free version allows users to upload SVGs and create circuit schematics.
I further understood how transistors can be used as switches or to change the routing of the circuits.
More general debugging in the labs includes taking as clear and close-up photos, and checking whether the LEDs are working or not. The simplest program to run is "blink!". It's also important to give PINs names.
It's usually better to use a different and bigger data type than int because int in Arduino Uno is only 16 bits.
Then, in class, I understood more about pull-down resistors and their importance.
Assignments
In the first lab, "Tone Output Using an Arduino," I first checked the sensor input range. For the sensor input range, the lowest value I obtained was 0, and the highest was 951.
Then I checked whether the speaker worked. I was able to hear a tone of 440Hz, continually. However, it was soft.
Then, in the 'Play Tones' section of the lab, I adjusted the analog input circuit range values, and, instead of photocells, I used force sensing resistors (FSR), so when I pressed on the FSR, it would play a tone.
void setup() { // nothing to do here } void loop() { // get a sensor reading: int sensorReading = analogRead(A0); // map the results from the sensor reading's range // to the desired pitch range: float frequency = map(sensorReading, 0, 951, 100, 1000); // change the pitch, play for 10 ms: tone(8, frequency, 10); delay(10); }