Acrob007: Rozdiel medzi revíziami
Zo stránky SensorWiki
Bez shrnutí editace |
Bez shrnutí editace |
||
Riadok 9: | Riadok 9: | ||
[[Obrázok:SharpSensorFamily.jpg | [[Obrázok:SharpSensorFamily.jpg]] [[Obrázok:SharpSensorCharacteristics.png]] | ||
Verzia z 08:36, 3. jún 2011
< Previous | Home | Next >
You will need the appropriate datasheet for Your sensor (note the type on the side of the sensor):
This distance sensor uses the triangulation principle with a PSD sensor inside. There are various types, each with different operation range. Look into the datasheet of YOUR sensor used on Your robot!
Note also the non-linear sensor characteristics!
Sensor uses three wires to connect. Two of them are for power supply, third one is an analogue output ranging according the datasheet. Output voltage is measured using the internal A/D converter inside the microcontroller. Its resolution is 10-bits (values 0-1023). Simple measurement displayed on the terminal window is done with this program:
#define SerialSpeed 9600 //typical values are 9600 or 115200
#define SampFrequency 10 //sampling frequency in Hz (cycles per second)
#define AnalogPIN 5 //define your pin here
int mDelay;
void setup()
{
Serial.begin(SerialSpeed);
mDelay = 1000/SampFrequency; //calculate delay for proper sampling rate
}
void loop()
{
delay(mDelay); //delay in milliseconds
Serial.println( analogRead(AnalogPIN) ); //reads the analog port and prints value over serial
}
Do You want to know more?
< Previous | Home | Next >