Today’s class was cool because I got to see what everyone had made, and none of them were stupid but some of them did involve animals/pets. I was a bit in awe…
But anyways I will kind of talk about my project.
This is the code:
#include "pitches.h"
int notes[] = {
NOTE_FS1 , NOTE_GS1 , NOTE_AS1 , NOTE_CS2 , NOTE_DS2 };
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(2)/4;
Serial.println(sensorValue, DEC);
if (sensorValue <6 && sensorValue >0){
tone(8, 92.499, 500);
}
if (sensorValue <11 && sensorValue>6){
tone(8, 103.83, 500);
}
if (sensorValue <16 && sensorValue >11){
tone(8, 116.54, 500);
}
if (sensorValue <21 && sensorValue >16) {
tone(8, 138.59, 500);
}
if (sensorValue <26 && sensorValue >21) {
tone(8, 155.56, 500);
}
if (sensorValue <31 && sensorValue >26){
tone(8, 185.00, 500);
}
if (sensorValue <36 && sensorValue > 31){
tone(8, 207.65, 500);
}
if (sensorValue <41 && sensorValue >36){
tone(8, 233.08, 500);
}
if (sensorValue <46 && sensorValue >41){
tone(8, 277.18, 500);
}
if (sensorValue <51 && sensorValue >46){
tone(8, 311.13, 500);
}
if (sensorValue >50){
tone(8, 369.99, 500);
}
}


The Pitches.h file is included, but because I wasn’t using the same notes, I had to use specific frequency values from a table of frequency values matched with notes.
When I got back to my room to try it out again, the light levels were lower, and actually the values (as seen in Serial Monitor) did not really go above 25-30, so to get the same results I divided analogRead(2) by 2 instead of 4, and that worked fine. However, it would be better probably to put in either a Map or a Calibration function.
It’s really cool too because it wouldn’t have come together without the help of my classmates, teacher Scott Fitzgerald, and the people of ITP. It was like each person gave me a piece of the puzzle and then it was easy to put together.
The soldering was kind of a last-minute thing I decided to do, because obvious the sound is going to be hard to hear when the speaker is inside the box. I didn’t want to make a stupid looking hole in the box last-minute for the speaker, so I just stuck it at the edge. It’s okay.
Oh yeah, and today I went to the NYU Computer Store to pick up a packet of photo resistors. While I was there, I noticed they had medium Servo motors among other things like LED’s and a hugeeee packet of resistors. Honestly, I don’t really understand what was going on with the photo resistors. All I know is that in the end it worked. But the values coming out of analogRead(0) were all 1000+. I just tried analogRead(2) and the values were between approximately 0-50, so I decided to go with that. Since I believe it’s a serial circuit, I wonder if the values would change if there were only 2 photoresistors on the board, or 1.
I guess I’m curious now about batteries.