Week 3: “Tone Output Using An Arduino” and “Servo Motor Control with an Arduino”

I didn’t have much trouble with these labs. In both cases, it was simply a matter of wiring up the breadboard as specified and running the provided code.

I’ll start with the servo motor, since it was the easiest. The only problem is that I wasn’t sure what capacitor to use for the “decoupling capacitor”. For some reason it was omitted in the “what you need” section, and the instructions didn’t specify what kind to use. ChatGPT said that a 0.1 µF capacitor should work, and it did. I didn’t need to tune the map function – the FSR’s outputs were already in the right range. See video:

Next up is the tone output. This was also very simple. See video:

For fun, I decided to generate a sawtooth wave instead. This took a while. The waveform of Arduino’s built-in tone function is a simple square wave. This makes sense, as a square wave can be generated by a signal alternating between “HIGH” and “LOW” states. In order to generate a more continuous signal, PWM is necessary. I used ChatGPT to generate some code that would produce a sawtooth wave instead. After a fair bit of trial and error, I got the code to run. I set up the first FSR to control the pitch. Then, I added a second FSR to control the cutoff parameter of software low-pass filter. This let me make screaming cat noises, which was a lot of fun:

Leave a Reply

Your email address will not be published. Required fields are marked *