Homework 5: Quick mapping
due at the start of class on Thursday 9/17
In class today, we learned a few new parts: the servo motor and the piezo speaker (both of which are fun and useful outputs that are in your kit).
I used Zoom’s random breakout rooms to assign you into groups, asking you to learn on your own about the map()
function and use it to connect a continuous input to a continuous output.
There were two distinct assignments, assigned to the teams based on their team number:
- Read a potentiomer and a pushbutton as inputs. Make it so that turning the potentiometer from one extreme to the other will drive the servo motor to turn from its one extreme to the other. When the pushbutton is held down, the servo motor should flip to the mirror of what its position would be (i.e. 180º would become 0º, 41º would become 139º, etc.). You should still be able to turn the potentiometer during this time and get updated feedback as you do so.
- Read a potentiometer and a pushbutton as inputs. Make it so that turning the potentiometer from one extreme to the other will drive the piezo speaker to make a tone in a range (for instance, 200 to 1000 Hz). When the pushbutton is held down, the frequency of the speaker should double. You should still be able to turn the potentiometer during this time.
Please use this Canvas assignment to turn in your assignment’s share link before class on Thursday; we’ll briefly look at them together.