Hi!
I have in an earlier project used an ultrasonic sensor to measure distance and convert the data to MIDI-signals. I now want the measurement to be more precise and I wonder:
Is there any laser sensor that is well adapted for this?
/Robert
Hi!
I have in an earlier project used an ultrasonic sensor to measure distance and convert the data to MIDI-signals. I now want the measurement to be more precise and I wonder:
Is there any laser sensor that is well adapted for this?
/Robert
Since this is an Arduino forum, I expect your trying to use a laser with an Arduino. Bear in mind that a light wave travels way faster than a sound wave, so if you try to send out a laser pulse and time how long until it returns, the light travels 62.5 feet in one tick of a 16 MHz clock. Too fast for the Arduino. If you can find a laser sensor already built up that delivers the range to your Arduino directly, then why not?
you might check lidar e.g. - http://pulsedlight3d.com/ - up to 40-meter range capability with 1cm resolution,
not cheapest, but impressive.
jrdoner:
Since this is an Arduino forum, I expect your trying to use a laser with an Arduino. Bear in mind that a light wave travels way faster than a sound wave, so if you try to send out a laser pulse and time how long until it returns, the light travels 62.5 feet in one tick of a 16 MHz clock. Too fast for the Arduino. If you can find a laser sensor already built up that delivers the range to your Arduino directly, then why not?
robtillaart:
you might check lidar e.g. - http://pulsedlight3d.com/ - up to 40-meter range capability with 1cm resolution,not cheapest, but impressive.
Yes, I am trying to control a MIDI device with a laser sensor via Arduino. I work as a freelancing designer and artist in Sweden and this is a new project I am working on. Since I am novice in this world of Arduino I need some good edvice from experts.
Do you think this laser sensor could deliver the range to my Arduino directly?: http://pulsedlight3d.com/
Here you can take a look at my latest project, that also involved Arduino: http://ekrobert.com/abs.html
Thank you for your answer.
/Rob
They seem to have a software library to communicate with it - PulsedLight · GitHub -
so connection to Arduino is very well possible.
IIRC it works with I2C bus
robtillaart:
They seem to have a software library to communicate with it - PulsedLight · GitHub -so connection to Arduino is very well possible.
IIRC it works with I2C bus
Thank you. I see that it is has a reading range up to 40 meters. In my project I will only need a reading range up to around maybe 1 meter. But I also see that it has a 1 cm resolution which is enough for this project. So maybe this sensor would do perfect anyway...
kreationsministern:
Thank you. I see that it is has a reading range up to 40 meters. In my project I will only need a reading range up to around maybe 1 meter. But I also see that it has a 1 cm resolution which is enough for this project. So maybe this sensor would do perfect anyway…
You might also look into the Parallax LIDAR sensor:
https://www.parallax.com/product/28044
Just another option - but it may not be accurate enough for your project…?
Also - have you looked into the various Sharp IR sensors? Again, they may not be accurate enough for your needs, but they have a much lower cost than the 1D LIDAR sensors - might be worth playing with, at least.
Finally - if you need to be able to have multiple “positions” to work with, rather than using a single sensor per “position”, or using a servo-based (or similar) scanning system - you might look into re-purposing a Neato XV-11 or XV-21 2D LIDAR sensor.
These can be had fairly cheaply (around $80.00 USD) from various ebay vendors; they are easy to hook up to the Arduino, and you can obtain a 360 degree scan of points centered on the sensor (it scans in a circle); I could see using such a device to scan a “fan” of 90 or 180 degrees, for something like a “laser harp” instrument (not sure if the update rate would be high enough, though - might not be for a musical instrument, if that was your goal).
cr0sh:
You might also look into the Parallax LIDAR sensor:https://www.parallax.com/product/28044
Just another option - but it may not be accurate enough for your project...?
Ah, thank you. I will definitely look that one up!
Since I have some financial support for this project, I think I´ll buy both of them to compare with each other. And, yes, it's some sort of musical instrument, containing sythezisers and so on
And in this earlier project -- http://ekrobert.com/abs.html -- I used the sharp ultra sonic sensor. But that one is not accurate enough for this new machine.
/Rob
cr0sh:
.
robtillaart:
.
jrdoner:
.
Hi! Sorry for the strange quotings. I didn’t know how to get your attention in an other way.
I now have done some simple Arduino tests with my Lidar Lite sensor, and it seems to work perfect and I think it is accurate enough for my project.
I wonder. Do you think you could help me / tutor me in some way with producing a code that converts the measurement data from the sensor into MIDI-signals? Or if you know someone else that have any idea how to do this?
/All the best, Robert
robtillaart:
and
Yeah thanks. I have been using this code in my earlier project (with an ultrasonic sensor)
#include <MIDI.h>
int pingPin = 13;
int inPin = 12;
long duration;
int cm_new = 20;
int cm_old = 20;
int sens = 5; // sensivity range when to launch a new note
void setup() {
Serial.begin(31250); // MIDI Begin
pinMode(pingPin, OUTPUT); // setup the Pins
pinMode(inPin, INPUT); // setup the Pins
}
void loop()
{
// The PING is triggered by a HIGH pulse of 2 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
duration = pulseIn(inPin, HIGH); // the singal from the Sensor is measured. The length of the pulse describes the distance form an object to the sensor.
cm_new = map(constrain(duration, 20, 2500), 20, 2500, 10, 1); // contrain --> set a threshold to cut values of the sensor that are to far away of to short (20 .. 3000) MAP --> Map the sensor range to a note values vom 96 (A high C) to 48 (a low C)
if (cm_new != cm_old) // only if a new sensor value is detected, a new nite will be send. IF the object stays stable infront of the sensor, no note will be send.
{
MIDI.sendNoteOff(44,0,cm_old); // Stop the old note
MIDI.sendNoteOn(44,127,cm_new); // Send a new Note (pitch , velocity 127, on channel x)
cm_old = cm_new;
}
delay(150); // for staiblity
}
But to be honest, I have no idea what the code should contain now that I am using my Lidar Lite sensor… I guess I have to replace the ultrasonic-part in the code with this:
#include <Wire.h>
#include <LIDARLite.h>
// Create a new LIDARLite instance
LIDARLite myLidarLite;
void setup() {
Serial.begin(115200);
// First we want to set the aquisition count to 1/3 the default (works great for stronger singles)
// can be a little noisier (this is the "1"). Then we set the "true" to enable 400kHz i2c
// communication speed.
myLidarLite.begin(1,true);
}
void loop() {
// Next we need to take 1 reading with preamp stabilization and reference pulse (these default to true)
Serial.println(myLidarLite.distance());
// Next lets take 99 reading without preamp stabilization and reference pulse (these read about 0.5-0.75ms faster than with)
for(int i = 0; i < 99; i++){
Serial.println(myLidarLite.distance(false,false));
}
}
But I do not know how to modify this. Sorry, I am really new on this stuff. Hope to get some guiding towards the correct code.