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