Back Sensor

Hi

I´m in a project where we are supposed to do a back sensor. But I´m not good at all in programming. Therefor I need your help! I have googled for days for some help but I can´t find anything so my last hope is this forum and you guys!

The goal is that the back sensor should sound more frequently when its closing up to a object… See the picture if it´s for any help.

I´m programming in arduino… Very thankful for any help!!

My main questions are:

  1. How do I program the Led Bar?
  2. How do I program so that the Led Bar and the sensor can interact/speak to with each other?

unnamed.jpg

I’m pretty sure that if you know the make and model of the sensor, and Google "arduino " you’ll get some hits. Have you checked the manufacturer’s site, some times they have code, and at least they should provide a datasheet.

Assuming you are brand new to Ardiuno have you completed any of the examples here?

EDIT: No your pic doesn’t help at all. Post a circuit diagram. And your code so far.

And MORE EDIT: To get two parts to interact, you need to figure out how to read the sensor, ie getting a value from it. Then you need to figure out (maybe seperatley) how to drive the output device with a (maybe) random value. Then you put the two halves together so that the output from the sensor influences the input (or is the input) to the other device. You might like to look at map() for that…

JimboZA:
I’m pretty sure that if you know the make and model of the sensor, and Google "arduino " you’ll get some hits. Have you checked the manufacturer’s site, some times they have code, and at least they should provide a datasheet.

Assuming you are brand new to Ardiuno have you completed any of the examples here?

EDIT: No your pic doesn’t help at all. Post a circuit diagram. And your code so far.

And MORE EDIT: To get two parts to interact, you need to figure out how to read the sensor, ie getting a value from it. Then you need to figure out (maybe seperatley) how to drive the output device with a (maybe) random value. Then you put the two halves together so that the output from the sensor influences the input (or is the input) to the other device. You might like to look at map() for that…

Thanks for your answer.

the sensor is MaxSonar EZ1 http://www.adafruit.com/blog/2009/06/23/getting-started-with-the-maxbotix-sonar-sensor-quick-start-guide/ but the starting guide on this page won´t work for me…

So far I have programmed this:

int sonarPin = 0;
int piezoPin = 12;
int inchesAway=0;

void setup() {
pinMode(piezoPin, OUTPUT);

Serial.begin(9600);
}

float dig2analog (int value)
{
float temp;
temp=( ( float ) value / 1023 ) * 5;
return temp;
}

void loop() {
inchesAway = analogRead(0);
analogWrite( 12, x / 4);

Serial.print(inchesAway);
Serial.println(" inches from sensor");

//if (inchesAway < 24) { // if something is 24 inches away then make a 1khz sound
//digitalWrite(piezoPin, HIGH);
//delayMicroseconds(50);
//digitalWrite(piezoPin, LOW);
//delayMicroseconds(50);
delay(200);

x
}

I hope that you can se any tweaks. thanks again

Did you try the exact circuit and exact code from that adafruit page?

If so, what did or didn't happen? I see you have Serial.prints in there: what results show from that?

JimboZA:
Did you try the exact circuit and exact code from that adafruit page?

If so, what did or didn't happen? I see you have Serial.prints in there: what results show from that?

Yes and it doesn´t happen anything. I need to convert the 0-1023 (the sensor language) to voltage (which I think I have done in the code?) and then convert the voltage to inches or centimeters (This I dont know how to do at all)

What was displayed in the monitor by the Serial.print?

You can’t have used the code you posted above: it doesn’t compile because you’re using a variable “x” which isn’t declared.

 analogWrite( 12, x / 4); //<<<<<<<<<<<<<<<   x isn't declared