| GP2D02 to BrainStem Example Last Modified: 2006-11-01 | | |
| Acroname Robotics | PDF webpage version | ||
| Introduction In this example, a BrainStem microcontroller uses a Sharp GP2D02 detector to measure distances to obstacles. The program uses the built-in Sharp GP2D02 driver in the BrainStem GP 1.0 module. Circuit Schematic The following schematic uses the BrainStem GP2D02 interface cable to plug the GP2D02 directly into the BrainStem GP1.0 module. There is no need to use the diode for current limiting protection as it is already included on the GP2D02 port of the GP 1.0 module. Additionally, this circuit uses the 4 AA battery pack to power the circuit. ![]() Source Code This code uses TEA syntax. It runs with the current version of the steep compiler which is included in the BrainStem console application. This example requires build 5 or higher of the console application and associated libraries which is available in the Acroname Download Center . /* gp2d02-6.tea */
#include <aCore.tea>
#include <aPrint.tea>
#include <aGP.tea>
void main(void)
{
int j;
while (1) {
// take the reading
j = aGP_ReadGP2D02();
// display the result
aPrint_IntDec(j);
aPrint_Char('\n');
// sleep for 0.5 seconds
aCore_Sleep(5000);
}
}
Notes This example shows how to interface the Sharp GP2D02 detector using a TEA program running on the module. The GP 1.0 Application is an example of a program that interfaces with the GP2D02 from the host computer and displays the information visually. Revision History:
| ||||
| voice: 720-564-0373, email: sales@acroname.com, address: 4822 Sterling Dr., Boulder CO, 80301-2350, privacy © Copyright 1994-2008 Acroname, Inc., Boulder, Colorado. All rights reserved. |