Hi, i recently acquired an arduino uno and after going through some of the tutorials i'm looking for a bigger challenge. Specifically i want to replicate the input system of a device called lightharp. i've built a prototype based on what i see on this video, and i've written some code following that explanation but i can't get to the same effect. I'm also using a High-brightness blue led and a LDR photoresistor.
I've written an email to the author but i didn't get any response. The project and it's website seem to be long dead and there is no activity in that youtube channel since at least three years. And i cant find any information on google about how to achieve that backscatter reading while the led stays on. So i will appreciate any help, references, pseudocode, (or pseudo-schematics ?) on the subject.
Here are links you may find helpful:
The complete list of videos on that youtube channel.
A blog from a guy who successfully replicated the device four years ago (i don't know if he modified the original schematics once found on the lightharp website, but the photos on his blog have good quality).
I wrote another code and made some progress. But now i have another problem, while i hold my hand above the "key" (led+photoresistor), the note stops and replays itself every 500 millisecods because of the nature of the playTone() function, but i need the note to be continuous, or to give that illusion.
#include "pitches.h"
int sensorLow;
int sensorHigh;
int referenceValue;
float threshold = 1.5; //decimal threshold.
int ledPin = 12;
int speakerPin = 8;
void setup() {
pinMode(ledPin, OUTPUT);
referenceValue = measureKey();
tone(speakerPin, NOTE_D1, 500);
delay (500);
noTone(speakerPin);
}
void loop() {
int difference;
difference = measureKey();
if (pulseKey(difference)){
playTone();
}
}
int measureKey(){
int difference;
digitalWrite(ledPin, LOW);
delay(100);
sensorLow = analogRead(A0);
digitalWrite(ledPin, HIGH);
delay(100);
sensorHigh = analogRead(A0);
return difference = sensorHigh - sensorLow;
}
boolean pulseKey(int difference){
if (!withinThreshold(difference)){
return true;
}
else{
return false;
}
}
boolean withinThreshold(int difference){
if (difference <= referenceValue * threshold){
return true;
}
else{
return false;
}
}
void playTone(){
// if ( !digitalRead(ledPin) ){
// digitalWrite(ledPin, HIGH);
// }
tone(speakerPin, NOTE_C4, 500);
delay (500);
noTone(speakerPin);
}
void playTone(){
// if ( !digitalRead(ledPin) ){
// digitalWrite(ledPin, HIGH);
// }
tone(speakerPin, NOTE_C4, 500);
delay (500);
noTone(speakerPin);
}
This code says, play that tone for 500 milliseconds and turn it off, emphasize on the "turn it off". What do you expect other than a tone that is played for 0.5 seconds and turned off? Any thought on how to make the proper change?
I commented that line and the problem persists, i even tryed different delay times.
If you want a non-stop tone, first, remove 500 from tone().
If you want the tone to stop after you move your hand away, then add a separate threshold for hand is removed. Remember, this needs to be different than the first hand-over threshold.
You also need a flag to indicate you are playing a tone, so if loop reiterates, it won't call tone() again but rather do nothing.
Thank you liudr !! I'll try to implement all that. Here's my progress so far:
Yeah! I love videos!
Since you have only one sensor, you don't need to save the tone being played. Once you have more than one sensor, you also need to save what tone is being played so when a sensor is triggered, arduino decides whether to change to a different tone or not.
I did clean up the code a bit. Now it plays a non-stop tone but the led keeps blinking for some reason, even as you play the note. At least is functional as a "light key". I'll leave the code here in case anyone is interested and i'll move on to the "midi" or output aspect of the device.
#include "pitches.h"
int sensorLow;
int sensorHigh;
int referenceValue;
float threshold = 1.5; // threshold.
int ledPin = 12;
int speakerPin = 8;
void setup() {
pinMode(ledPin, OUTPUT);
referenceValue = measureKey();
tone(speakerPin, NOTE_D1, 500);
delay (500);
noTone(speakerPin);
}
void loop() {
int difference;
difference = measureKey();
if (pulseKey(difference)){
playTone();
}
else{
stopTone();
}
}
int measureKey(){
int difference;
// if ( digitalRead(ledPin) ){
// digitalWrite(ledPin, LOW);
// }
digitalWrite(ledPin, LOW);
delay(50);
sensorLow = analogRead(A0);
digitalWrite(ledPin, HIGH);
delay(50);
sensorHigh = analogRead(A0);
return difference = sensorHigh - sensorLow;
}
boolean pulseKey(int difference){
if (!withinThreshold(difference)){
return true;
}
else{
return false;
}
}
boolean withinThreshold(int difference){
if (difference <= referenceValue * threshold){
return true;
}
else{
return false;
}
}
void playTone(){
// if ( !digitalRead(ledPin) ){
// digitalWrite(ledPin, HIGH);
// }
tone(speakerPin, NOTE_C4);
}
void stopTone(){
// if ( digitalRead(ledPin) ){
// digitalWrite(ledPin, LOW);
// }
noTone(speakerPin);
}
Looks like the original airharp creator "Peter DeSimone" tried a kickstarter campain but it failed to meet its funding in April this year.
https://www.kickstarter.com/projects/lyratron/airharp-ultrasonic-digital-autoharp
There is a web site at http://www.airharp.com/ with schematics and source code and the ability to buy complete units.
There is also an instructable about building it.
Chris