Arduino Home

An Open-Source platform to create digital devices and interactive objects that sense and control physical devices.

Arduino Tutorials
Arduino Projects

 

Arduino Starter Kit Competition INDEX:

 

Element14's Arduino Starter Kit Competition

Element14's Arduino Starter Kit Competition - Part 1

Element14's Arduino Starter Kit Competition - Part 2

Element14's Arduino Starter Kit Competition - Part 3

Element14's Arduino Starter Kit Competition - Part 4

Element14's Arduino Starter Kit Competition - Part 5 (motor fun)

Element14's Arduino Starter Kit Competition - Part 6

Element14's Arduino Starter Kit Competition - Part 7

Element14's Arduino Starter Kit Competition - Final Part and Conclusions

 

Following on from receiving my Arduino Starter Kit from Element 14 I have now moved on to Project 6 in the Arduino Project Book - it involves making a Light Theremin.

 

Project Book - 06 Light Theremin

The circuit construction is very simple with a piezo sounder and a Light Dependant Resistor (LDR) and the code is fairly straightforward. In this project we discover that we can actually do some looping and conditions within the setup section of the Arduino sketch rather than simple just setting up conditions sequentially.

photo_2017-08-21_17-47-52.jpg

The board make higher pitches with a bright light and lower frequencies as the LDR was covered up. This project inspired me to make a branch and try something out. I added a second LDR and coupled both to the piezo buzzer via a nominal 220R resistor. I then doubled up much of the code. Alas, the output wasn't quite as I had expected and I searched the Arduino 'tone' function. Unfortunately it states that I can only generate one tone at a time. Maybe something else to try out at a later date ?

int sensorValue1;

int sensorValue2;

int sensorLow1=1023;

int sensorHigh1=0;

int sensorLow2=1023;

int sensorHigh2=0;

 

const int ledPin=13;

 

void setup() {

  // put your setup code here, to run once:

  pinMode(ledPin,OUTPUT);

  digitalWrite(ledPin,HIGH);

 

  while(millis() <5000){

    sensorValue1=analogRead(A0);

    sensorValue2=analogRead(A1);

       

    if (sensorValue1>sensorHigh1) {

      sensorHigh1=sensorValue1;

    }

    if(sensorValue1<sensorLow1){

      sensorLow1=sensorValue1;

    }

 

    if (sensorValue2>sensorHigh2) {

      sensorHigh2=sensorValue2;

    }

    if(sensorValue2<sensorLow2){

      sensorLow2=sensorValue2;

    }

   

  }

  digitalWrite(ledPin,LOW);

}

 

void loop() {

  // put your main code here, to run repeatedly:

  sensorValue1=analogRead(A0);

  sensorValue2=analogRead(A1);

  

  int pitch1=map(sensorValue1,sensorLow1,sensorHigh1,50,4000);

  int pitch2=map(sensorValue2,sensorLow2,sensorHigh2,50,4000);

   

  tone(8,pitch1);

  delay(100);

  tone(9,pitch2);

  delay(100);

}

Summary of Project 06
Although I mention that the project is simple to build and code it is actually quite interesting and strangely rewarding. That said, hearing someone else who has built this project will probably drive you to distraction . This project teaches that the Arduino can make musical notes. Maybe I could build a simple electronic piano or play a sequence of notes from a song? I like the way this circuit can be calibrated during the initial 5 seconds after powering up.

 

Project Book - 07 Keyboard Instrument

Well I never, I turn the Project Book page over and find the natural progression from the Theremin project I was thinking of - a keyboard instrument !

photo_2017-08-22_19-22-37.jpg

The build for this is quite straightforward and I didn't actually make any errors typing in the code or building up the circuit.

 

Summary of Project 07

This project introduces a useful technique of the resistor ladder to determine several switches (or combinations of) from just one Arduino input pin. This project seems much less annoying than hearing the Theremin. I also think this project will encourage builders as everyone likes to be able to make musical notes/music and it would seem a simple progression to be able to play a simple melody using the same functions. That said, the project book also warns us that the tone will interfere with AnalogWrite on pins 3 and 11 - useful to start to realise there are also limitations on what the Uno can achieve.

 

Project Book - 08 Digital Hourglass

This neat little project uses six LEDs to count 10 minute blocks - stooping after 1 hour, when they are all illuminated. The circuit however can be reset by rocking the board to activate the tilt switch on the breadboard.

photo_2017-08-22_20-06-42.jpg

After building the circuit, coding the sketch and uploading I realised there would be a long wait wait to prove this circuit. I reduced the intervals to 5 seconds - giving a total count of 30 seconds. My modified code is:

const int switchPin=8;

 

unsigned long previousTime=0;

int switchState=0;

int prevSwitchState=0;

 

int led=2;

 

long interval=5000;

 

void setup() {

  // put your setup code here, to run once:

  for (int x=2; x<8; x++){

    pinMode(x,OUTPUT);

  }

  pinMode(switchPin,INPUT);

}

 

void loop() {

  // put your main code here, to run repeatedly:

  unsigned long currentTime=millis();

 

  if (currentTime-previousTime > interval){

    previousTime=currentTime;

    digitalWrite(led,HIGH);

    led++;

    if (led==7){     

    }

  }

 

  switchState=digitalRead(switchPin);

 

  if (switchState != prevSwitchState){

      for(int x=2; x<8; x++){

        digitalWrite(x,LOW);

      }

 

      led=2;

      previousTime=currentTime;

  }

 

  prevSwitchState=switchState;

}

Summary of Project 08

This project is a useful introduction to timing events in the real world using the  millis function. It could easily be modified to time everyday activities in people's houses - e.g. boiling an egg, limiting shower time (if run off a 9v PP3 battery), exposing a PCB to Ultraviolet (UV) light.....

 

The only issue I had with project 08 was that the tilt switch had four pins and this wasn't mentioned in the project book. To be on the safe side I put a Digital Multimeter (DMM) across the pins to check for continuity and find if they went open circuit when the switch was tilted. Another issue was that either the pins were too short or the breadboard contacts are too recessed....the switch kept popping off the breadboard. A piece of Blu-Tack would solve that in the longer term (or soldering longer wires to the tilt switch's pins).

 

[ next project in the Arduino Project Book - "Motorized Pinwheel" ]