Pulse Width Modulation (PWM) -> fake an analog voltage by producing a series of voltage pulses at regular intervals, and varying the width of the pulses
-> PWM with a 50% duty cycle-> PWM with a 33% duty cycle
LAB : Tone Output Using An Arduino
- Frequency : the number of vibrations per second
- Hertz (Hz) : frequency is measured in Hertz
ex) 20 times a second = 20Hz - Period : the length of time it takes to move from rest through one back-and-forth motion
** frequency = 1 / period
- How to make sound from an Arduino? ->
Attach a speaker to an output pin and turn it on and off at a set frequency
Prepare The Breadboard
Connect the Sensors and the Speaker
1. Check the Sensor Input Range
-> I confirmed that the sensor input range was displayed as numerical values on the serial monitor
2. Check that the Speaker Works
-> A single tone was continuously played!
3. Play Tones
-> I confirmed that a higher-pitched tone was produced when the sensor was pressed
More Complex Example
-> This note codes are COOL🤩 (I now really want to make some musical instrument later)
-> It worked!! 🥳 🎉 Cute :)
Musical Instrument
-> Each sensor was assigned a musical note, making it feel like the sensor became a piano key 🎹
-> I used different keys from the example. Specifically, I used C4, D4, and E4 to produce the notes Do, Re, and Mi
-> I found music that can be played using only the notes Do, Re, and Mi, and decided to try performing it. **
This song is very famous children song in Korea, though I'm not sure if it's well-known in the U.S. 🤔
-> It worked and it was fun!! 😆
** I wanted to create all eight musical notes from Do to Do and try a proper performance, but unfortunately, I only had three sensors, which was a bit disappointing...
LAB : Servo Motor Control With An Arduino
Prepare The Breadboard
Connect An Analog Input Sensor And A Servor
Programming Microcontroller
-> I confirmed that the angle of the servo motor changes depending on the pressure applied to the sensor. I think I need to brainstorm how to apply this concept further. 🤔