Week 4: Talk Seesaw [LAB]

Oct 1, 2018

This week's lab of creating a simple application, I've created the Talk Seesaw. It is a visualization of how a conversation between two people sway back and forth. The more one person on one end of the seesaw talks, the more the seesaw will swing down to that side. It also provides a "warning" system - if one person has talked for too long (when one end of the seesaw hits the ground), the speaker gives warning "buzzes".

Materials used:


The final product ended up not doing exactly what I wanted to do - but still sort of illustrates the original intentions. The microphones that I purchased for this project ended up not being "sensitive" enough to detect the level of amplitude of the environment. I opted to buy the cheaper and simpler microphone, and not the ones that also have a built in amplifier, and this resulted in having to tap on the mic, rather than being able to speak directly to it.

Stuff I learned:

Stuff I'm still not sure of:

Arduino Source Code:




Week 4's Self-graded Quiz:

Question 1: Microcontrollers read a variable input using an analog-to-digital circuit inside the controller. The Arduino Uno can read the input voltage with a resolution of 10 bits using the analogRead() command. Give the numeric range (in base 10) for this resolution. How much memory does this take up?

analogRead will return values between 0 and 1023. The size of this data is 10bits. As the data will keep updating according to the input of the sensor itself, the memory of this incoming data is always 10 bits.

Question 2: Two resistors in series create a voltage divider. When one of the resistors is a variable resistor, they can be used to create an analog input to a microcontroller. Describe or draw the schematic for this circuit.

V + -> variable resistor -> Analog IN -> static resistor -> GND
This way, as the variable resistor changes in resistance, analog input changes. The static resistor acts as pull down resistor to prevent from short circuit.

Question 3: A potentiometer is a variable resistor in which a wiper moves across the surface of the resistor, creating a variable resistance. Describe or draw the schematic for connecting a potentiometer to a microcontroller’s analog input pin.

A potentiometer has 3 pins: to power, ground and analog input. The two pins on the ends of the potentiometer go either to ground or power. The middle pin goes into analog input of the microcontroller.

Question 4: How can you test the output of an analog sensor before connecting an analog sensor to your microcontroller’s analog input?

You can connect the analog output pin of the sensor to an LED (with a 220 ohm resistor also) to see the brightness of the LED change as the value of the sensor changes.

Question 5: Imagine you used analogRead() to read an analog input. You got a reading of 10. Assume an analog input voltage range from 0 to 5 V. What is the voltage of your reading?

The voltage that I am reading is (10 / 1023) * 5, which is approximately 0.05 V.

Question 6: Under the same conditions as the last question, what’s the voltage difference when the reading difference is 1 point? For example, what’s the voltage difference between a reading of 10 and a reading of 11?

The voltage difference between 1 point (between 10 and 11) is (1 / 1023) * 5, which is approximately 0.005 V.

Question 7: Assume the analog input voltage range is 0 to 3.3 volts instead of 5 volts. What are the answers for the previous two questions now?

The answer to question 5 is now (10 / 1023) * 3.3, which is approximately 0.03 V, and the answer to question 6 now is (1 / 1023) * 3.3 which is approximately 0.003 V.

Question 8: Most microcontrollers cannot output a true analog voltage. Instead they create a pseudo-analog voltage by producing a series of pulses. What is this principle called? What property of the pulses is the microcontroller changing in order to produce this effect?

The principle is called PWM (Pulse With Modulation). The microcontroller changes the pulse width within a given time period (1ms) , thus changing the duty, a ratio of pulse width to time period.

Question 9: The principle described in the previous question is used by Arduino’s analogWrite()command. What property of the pulses is controlled by the tone() command?

The tone() function changes the pulse width within a given time period (duty) to change the frequency (in Hertz) to be sent to a speaker to produce as sound.

Question 10: What is the resolution of the output from Arduino’s analogWrite() command? Give a decimal numeric range.

The range of numbers that can be passed to analogWrite() is between 0 - 255 (8 bits).

Question 11: Write a program to read an analog input on an Arduino, map the result to the range you just cited, and fade an LED or play a tone on a speaker.

    #define sensor A0
    #define led 9

    void setup(){
    pinMode(led, OUTPUT);
    }

    void loop(){
    int sensorVal = analogRead(sensor);
    int ledVal = int(map(sensorVal, 0, 1023, 0, 255));

    analogWrite(led, ledVal);
    }
        
BACK TO MAIN