Catching up on PCOMP labs

I didn’t do these labs last week because I was busy with the Stupid Pet Trick, so I did them this morning.

I set up the servo motor:

[yframe url=’′%5D

And then built the musical instrument.  I only had one FSR so I used different pressures to determine notes in order to play a melody.  My speaker was really quiet for some reason, but I could hear the melody.

Here’s the code I used:

#include “pitches.h”
int analValue;

void setup() {

void loop() {
analValue = analogRead(A1);

int pitch = map(analValue, 0, 1000, 0, 3);

if (pitch == 0){
tone(8, NOTE_C4, 10);
} else if (pitch == 1) {
tone(8, NOTE_G3, 10);
} else if (pitch == 2) {
tone(8, NOTE_B3, 10);



Author: owen ribbit


Leave a Reply

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

You are commenting using your 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