Week 3

Questions that I got throughout the Lab:

  • When do we have to use float() syntax?
  • Can we go over void makeTone(){ }? I could not get the sound + I want to know about the numbers in the function.
  • I would like to know how to connect servo motor with potentiometer.

  • Sensor and Speaker

Change of Hz is a change of pitch

tone (pin , frequency (Hz), duration )

float frequency = map(sensorReading, 200, 900, minimum HZ, maximum HZ);

Musical Instrument

My sensors worked after I copy and pasted the codes from the lab. However, there were buzzing sounds as a default that I wasn’t sure how to remove them.

I put delay(100) in void loop(), however it did not remove the background sound completely.

  • Servo Motor

int servoAngle = map(analogValue, 0, 1023, 0, 179);

* 0~1023 sensor / 0~179 angle

syntax millis( ) – Returns the number of milliseconds passed since the Arduino board began running the current program. Use it instead of delay() for complex things.

*An experiment that did not gone well

I could not get the servo motor with potentiometer. This is an image of the circuit. I put analog pin from A0 to potentiometer and digital PIN number 9 to servo motor. This is the code that I tried.

On the serial monitor, the numbers of servo angle are keep changing even though I wasn’t controlling the slider. (same thing happened for the analog value)