Arduino Theremin

Hello,

This is a theremin I did by using Arduino and few other pieces. 6 LED’s – photoresistor and a piezo. Photoresistor detects the amount of light and the serial read commands the piezo and LED’s. First blue LED stands for the first note , when the serial read is below LED turns on and piezo plays the note. Her is the video of it. thanks for watching. 🙂

IMAG2516-01IMAG2523-01 IMAG2519-01 IMAG2518-01

 

 

The Code :

#include “pitches.h”

int tonepin = 9; // PWM0 output = 9, PWM1 output = 10

// these are the “piano keys” – they are just input pins
#define D2 2
#define D3 3
#define D4 4
#define D5 5
#define D6 6

void setup() {
Serial.begin(9600);
pinMode ( 3, OUTPUT);
pinMode ( 4, OUTPUT);
pinMode ( 5, OUTPUT);
pinMode ( 6, OUTPUT);
pinMode ( 7, OUTPUT);
pinMode ( 8, OUTPUT);
}

void loop() {
while (1) {

int sensorValue = analogRead(A0);
Serial.println(sensorValue);

if (sensorValue < 10 ) {
tone(tonepin, NOTE_D7);
} else if (sensorValue < 20 ) {
tone(tonepin, NOTE_C7);
} else if (sensorValue < 30) {
tone(tonepin, NOTE_G6);
} else if (sensorValue < 40) {
tone(tonepin, NOTE_C7);
} else if (sensorValue < 50) {
tone(tonepin, NOTE_A6);
} else if (sensorValue < 60) {
tone(tonepin, NOTE_B6);
} else {
noTone(tonepin);
}
if (sensorValue < 10 ) {
digitalWrite ( 3, HIGH);
} else digitalWrite (3, LOW);

if (sensorValue < 20 ) {
digitalWrite ( 4, HIGH);
} else digitalWrite (4, LOW);
if (sensorValue < 30 ) {
digitalWrite ( 5, HIGH);
} else digitalWrite (5, LOW);
if (sensorValue < 40 ) {
digitalWrite ( 6, HIGH);
} else digitalWrite (6, LOW);

if (sensorValue < 50 ) {
digitalWrite ( 7, HIGH);
} else digitalWrite (7, LOW);
if (sensorValue < 60 ) {
digitalWrite ( 8, HIGH);
} else digitalWrite (8, LOW);
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *