Jul 8, 2008 0
Feb 17, 2008 1
Sonar Distance Sensor
[code lang="c"]
//MAXBOTIX EZ-1 SONAR DISTANCE SENSING CODE FOR ARDUINO DIECIMILA
//INPUT ANALOG 0 FROM EZ-1 ANALOG OUTPUT//rippond@gmail.com
// http://www.danrippon.com
void setup()
{
Serial.begin(9600);
}
void loop()
{
int signalValue = 0;
pinMode(signalValue, INPUT); //ANALOG 0 TO INPUT
int sensorValue = analogRead(signalValue);
int distance = sensorValue * 1.24; //is distance in CM
printInteger(distance);
serialWrite(10);
serialWrite(13);
delay(500); //time between next reading in milliseconds - 1s/1000ms
} // Loops Continuously
[/code]