Lab 3

1: Tone Output Using an Arduino

Components

-Arduino Nano 33 IOt microcontroller
-solderless breadboard
-jumper wires
-alligator clips
-22 AWG solid core wires 
-force sensing resistor (FSR)
-8-ohm speaker
-100-ohm resistor

Process

Akshita, Erik, and I worked together to connect a speaker to an Arduino. We followed the diagram below to set up our breadboards and circuits using the 5V port instead of the usual 3.3V (Erik and I were on the floor Zooming with Akshita). Tom Igoe and ITP residents, Nun and Arnab, helped us troubleshoot when our speaker was not working.

A diagram of the circuit

We each saw different analog sensor values emerge in our serial monitors when we applied pressure to the FSR; the value hovered around 450 when no FSR was pressed, and when pressing the FSR closest to the microcontroller, the value dropped by about 50-100 to the 350-400 range; when the FSR below this was pressed, the value dropped to 0.

The speaker is connected to the breadboard and circuit using alligator clips
Starting to read and map the analog sensor value

We changed the 200-900 analog sensor values to match the values we saw in our serial monitors

Once we knew the FSRs were being read correctly, we tried using the class example code to play tones from the speaker, but this did not work. We discussed the issue with Tom during office hours and he advised that the range in the sample code (200-900) did not match the range we were seeing on our serial monitor (0-400). Once we changed the values from 200 to 0 and 900 to 450, the speaker began to play sounds šŸ™‚

Videos + Demos

Reading the FSR values
The speaker playing tones

2: Servo Motor Control with an Arduino

Components

-Arduino Uno or Nano 33 IOt microcontroller
-solderless breadboard
-jumper wires
-force sensing resistor (FSR)
-10-kilohm resistor
-RC servomotor
-12V DC 2A wall power supply adapter

Process

Akshita and I worked together to connect a servomotor to an Arduino. This lab also required some troubleshooting; many thanks to Dave Currie for helping our servomotor come to life.

For our microcontrollers, Akshita used the Nano 33 IOt and I switched over to the Arduino Uno. We each set up our own breadboards and circuits while connecting via Zoom/ Discord. Luckily, we had the same servomotors and parts so it was easy to get started.

What proved more challenging was getting the servomotor to work. Our breadboards and circuits looked exactly as they did in the diagrams. We read and adjusted our varying analog sensor values (from a FSR) according to the ranges we could see in our serial monitors. We stuck with 0 to 179 as the range for the sensor in degrees (although some code examples we came across had listed 180 instead of 179).

Reading the FSR values

The required servo library was installed, and a variable for the servomotor was declared, along with the right digital pin (3) it was attached to. We compiled and uploaded our code, but the servomotor did not move; there was a slight motion and buzzing sound emitting from the servomotor, but it was not quite kicking it 90 degrees yet.

The code we initially used to test movement by the servomotor
The code is being uploaded to the final circuit; in the video linked below it is powered by the 12V DC 2A wall power supply adapter

In the end, what turned out to be keeping our servomotor from turning was the power source. While the class notes suggest that “most RC servomotors will run on as low as 3 volts, even if they are rated for 4-6 volt input,” our servomotors required a more powerful voltage supply. When we switched our power source from the Arduinos to a 12V DC 2A wall power supply adapter, the servomotor began to rotate 90 degrees every half-second.

Videos + Demos

The servomotor beginning to move

Once the servomotor was up and running, I also tried the original code (from the class example) to see if the FSR could control it. I was thrilled that this too, worked šŸ™‚

Stay tuned for a video of the servomotor being controlled by the FSR.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s