예제 #1
0
파일: PingSonar.c 프로젝트: bechu/hexapod
// Read all the values and store into the device
static void __ping_read(SENSOR* sensor){
	TICK_COUNT duration;

	PingSonar* device = (PingSonar*)sensor;

	// 5 us Trigger Pulse
	pin_pulseOut(device->ioPin,5,TRUE);

	// Measure the inbound pulse
	duration = pin_pulseIn(device->ioPin,TRUE);

	device->distance.cm = fraction32(duration, ping_frac);
//	device->distance.cm = duration;

}
예제 #2
0
// Read all the values and store into the device
static void __srf04_read(SENSOR* sensor){
	TICK_COUNT duration;

	Devantech_SRF04* device = (Devantech_SRF04*)sensor;

	// initialise the pins
	pin_make_output(device->out,FALSE);		// Set low
	pin_make_input(device->in,FALSE);

	// 10us high trigger pulse
	pin_pulseOut(device->out,10,TRUE);

	// Measure the inbound pulse
	duration = pin_pulseIn(device->in,TRUE);

	device->distance.cm = fraction32(duration, srf04_frac);
}