Arduino

One of my classes this semester (Design Studio) focuses on learning particular technologies. I recently finished the Arduino section and wanted to share it!

Arduino is a small computer (an open-source single-board microcontroller) that works with flexible, easy-to-use, and inexpensive hardware and software. It is intended to be used by artists, designers, and hobbyists to create interactive objects or environments.

My Project

After completing introductory exercises that controlled LED lights, I became interested in using the Arduino to regulate sounds. I found a few tutorials online that used different accessories to make noise through the microcontroller, particularly one that used a potentiometer to regulate pitch. While I really liked this idea, I thought the design and code I found online was far too complicated for such a simple task. Using other project tutorials (controlling the speed of a LED light, coding a song through a speaker), I pared down the original coding to match a simpler layout. The final result included a small Piezo speaker attached directly to the Arduino board and a potentiometer connected to the computer through a breadboard.

Controlling a Light with a Potentiometer

Light/Potentiometer Code

Coding a Musical Tune

Musical Code

Controlling a Tone with a Potentiometer

Original Tone Adjustment Code

My Code
/*

Simple Tone Adjustment with Potentiometer

*/
// set pin numbers:
const int speakerPin = 11; // the number of the Piezo speaker

const int sensorPin = 2; // the number of the potentiometer
// variables will change:

int sensorValue = 0; // the value read from the pot

int noteValue = 0; // gets converted to a “note”

void setup() {

pinMode(speakerPin, OUTPUT); // set the speaker’s pin for output

}
void loop(){

sensorValue = analogRead(sensorPin); // get the pot’s value

noteValue = ((((1024 – sensorValue) / 1024.0) * 959) + 956); // convert

digitalWrite(speakerPin, HIGH);

delayMicroseconds(noteValue);

digitalWrite(speakerPin, LOW);

delayMicroseconds(noteValue);

}

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply