First Arduino assignment

Our first assignment for the Prototype Course was to create a small project with two components. Due to my limited experience with electronics, I decided to build something from the Arduino Projects Book that came with Arduino kit. I felt the need to make sure that I wasn’t going to burn down my building or cause a major blackout. Safety first, right?

I chose the Light Theremin for my project. Theremin is an instrument that makes sounds based on the movements of a musician’s hands around the instrument [Anduro Projects Book]. Instead of motion detector this project used a photoresistor which meters light.

I started the project by building the circuit. Components for my psychedelic piano were:

  • 1 piezo
  • 1 photoresistor
  • 1 10 kilohm resistor
  • Few jumper cables and an Arduino

With the guidebook in hand building the circuit was fast and straightforward procedure. I really like how Arduino makes it easy to mess around with electronics. It’s plug and play like legos. No soldering needed.

Next I duplicated the code from the book.

int sensorValue;
int sensorLow = 1023;
int sensorHigh = 0;

const int ledPin = 13;

void setup() {
 pinMode(ledPin, OUTPUT);
 digitalWrite(ledPin, HIGH);

while (millis() < 5000) {
 sensorValue = analogRead(A0);
 if (sensorValue > sensorHigh) {
 sensorHigh = sensorValue;
 if (sensorValue < sensorLow) {
 sensorLow = sensorValue; 
 digitalWrite(ledPin, LOW);

void loop() {
 sensorValue = analogRead(A0);
 int pitch =
 map(sensorValue, sensorLow, sensorHigh, 50, 4000);
 tone(8, pitch, 20);

Then I was ready to launch my application. I plugged the USB cable and ran the program. It didn’t work.

Error compiling. 
lightThemerin.ino:3:1: error: expected unqualified-id before numeric constant. 
lightTheremin.ino:8:1: error: expected ’,’ or ‘;’ before ‘void’

Some Hebrew. Nice.

I double checked my code and found a few stupid mistakes:
const in ledPin = 13 //missed a semicolon.
sensorValue = analogRead()A0; // A0 outside the parenthesis.

After fixing the code everything worked smoothly. For the first five seconds Theremin needs to be calibrated by moving your hand on top of the photoresistor. Then you play. Making weird noise is awesome.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.