Arduino Analog Read and Tones

Class Recap:

  • Introduction to Arduino
  • Circuits, Symbols and Breadboarding

At the end of class we learned about analog inputs, and how they can be mapped to tone values. Digital inputs work in a similar way, instead of reading various values you will only read 1s and 0s, 5 volts or 0 volts. Arduino programming is very similar to Processing, you can add if statements and for loops; utilize the logic you have learned so far. By adding a conditional statement that listens to the button presses, you can trigger a sound. It could be a piece of music you compose or maybe you can make a piano if you make every button have its own sound.

Assignment:

Create a project that uses the tones function, with your piezo buzzer, you can add either an analog or digital input to trigger the sound. In this prototype you should experiment in making an enclosure. This interface should be conceptual and also interactive, think outside the box, or inside the music box, or an instrument, or a toy :)

Analog Read:

buzzer5_bb

Analog Read: http://arduino.cc/en/Tutorial/AnalogReadSerial

/////////////////////////////////////////

/*Class Code: This sketch listens to light! Depending on the variable resistance of your photoresistor you can map its value to tones*/

int speaker = 11;
int sensor = A0;
int sensorValue = 0;

void setup() {
Serial.begin(9600);
pinMode(sensor, INPUT);
pinMode(speaker, OUTPUT);
}

void loop() {
sensorValue= analogRead(sensor);
sensorValue = map(sensorValue, 1, 15, 31, 3000);
tone(speaker, sensorValue);
Serial.println(sensorValue);
delay(1000/16);
noTone(speaker);
}/////////////////////////////////////////

Digital Read:

button

Serial-Begin2

Digital Read: http://arduino.cc/en/Tutorial/DigitalReadSerial

Button: http://arduino.cc/en/tutorial/button

small-circuit-solderless-breadboard-md

This entry was posted in Assignment, Resources on by .

About aisencc

Hello! I'm Aisen Caro Chacin, my curiosity led me to research the intersecting fields of art, science, and technology driven by conceptual forms of inquiry and design thinking resulting in functional prototypes. I'm looking forward to seeing your ideas materialize. My inbox is always open.. so say "Hello!".

Leave a Reply