Labs pt.2: Analog Out – Tone

Analog out – Photocell and 8 Ohm Speaker

giphy2
This gif defeats the purpose of the tone exercise. It wasn’t working properly anyway.

Some roadblocks:

The sound wasn’t coming out that audible, I am thinking it’s because of my fixed resistor – its currently 330 ohms. I adjust it to 220 ohms, it was way better.

My photocell works but I’m not seeing changes on the serial monitor just a bunch of zeros, my hunch is that my parameter not mapped properly.

void setup() {
// none needed
}

void loop() {
// get a sensor reading:
int sensorReading = analogRead(A0);
// map the results from the sensor reading’s range
// to the desired pitch range:
float frequency = map(sensorReading, 500, 900, 0, 255);
// change the pitch, play for 10 ms:
tone(8, frequency, 10);

I was very excited about making an instrument (probably will be taking a stab at it for midterms). That’s why I went all out and got those expensive FSR’s! LOL. I still couldn’t get the sound loud enough though.

 

I’ve been thinking of possible ideas: A basic theramin or a portable piano box. I have no background in fabrication so once it gets crazy, I am also interested in the idea of creating a zoetrope with a motor or servo.


UPDATE! I was able to fire up code on my FSR and Speaker!!

 

Leave a comment