Teaching with Arduino


I’ve decided to use the Arduino in my electronics class this fall. The Arduino is an “open-source electronics prototyping platform based on flexible, easy-to-use hardware and software.” Even from the description it sounds like just what an electronics course needs. I finally had some time to tinker with it today, and after a few minutes I had it’s LED blinking away, and then after another few minutes it was an oscilloscope. A few minutes later it was playing a pulse-width-modulated (PWM) melody. Not bad for an hour’s work.

With a little inspiration, and my new-found confidence, I took to my first project in hopes of having a little demo to show the intro students to recruit them for my class in the fall. An hour and a half later (including fielding questions about homework and our exam tomorrow) I had a photo-resistor theramin up and running. The basic idea is to use a photoresistor as half of a voltage divider and tell the Arduino to read the voltage and output a PWM tone whose frequency depends on the voltage. This way the pitch can be controlled by blocking or unblocking the light at the photoresistor.

int speakerOut = 9;

void setup() {
  pinMode(speakerOut, OUTPUT);

int tone = 0;
long input = 0;
int maximum = 500;
int minimum = 400;
float range = 100;

void loop() {
    input = analogRead(0);
    if (input > maximum) maximum = input;
    if (input < minimum) minimum = input;
    range = maximum-minimum;
    tone = 9090*float(1-float((input-minimum)/range));
    //tone is the period, so large means high frequency.
    // when using analogRead, this means a high voltage gives a low sound.

    delayMicroseconds(tone / 2);

    // DOWN
    digitalWrite(speakerOut, LOW);
    delayMicroseconds(tone / 2);



5 thoughts on “Teaching with Arduino

    • This group of students are in college and taking an introductory electronics class. I think the large arduino would be cool, especially if there was a way to make everything larger. My four year old son doesn’t have trouble plugging wires into the breadboard, but I do have trouble explaining where to put them. I can see how it may help to have a blown-up version to point at when you describe things.

  1. Pingback: Arduino for Quantum Optics, Anyone? « QuantumBlah

  2. My main problem was that I was a master controls electrician always using ladder logic, NO,NC AND, OR NOT NAND LOGIC. So once I had gotten thru that and realized I now am the decider of logic it had gotten better. Right now I have 3 motion detectors with 3 addresses and an input to the PIC from the keypad, with one output to the receiver near the sirens. I have built in low battery signals and alarm cut out as well as outputs to a red LED to show what zone went off.


Leave a Reply

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

WordPress.com Logo

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