racer.h Quick Reference

#include <racer.h>
Insert this text at the very top of you sketch. This will bring the functions provided in racer.h into your sketch.

int racerActivate();
Run this function in Setup. racerActivate() will attach the racer servo and initialize communication with sensors.


int servoCenter(int steerCenter);
Run this function in setup. This function tells your racer where the servo center is. Function accepts inputs from 0-255, but center is usually between 75 and 125. After setting the servo center, a servoSteer value of "0" will send the car in a straight line.

int servoSteer(int steerValue);
If servoCenter is set, an input to servoSteer of "0" will send your racer in a straight line. Negative inputs from -1 to -127 will steer the car left, and positive inputs from 0 to 127 will steer the car right.

int camLineTop();
This command returns the "top" of the line in the thickest line the camera can see. The "top" of the line will be the furthest down the track that the camera can see. This returns 0 for center, -39 for far left and 39 for far right. These numbers can be used to determine where the car is on the track and make corrections.

int camLineBottom();
This command returns the "bottom" of the line in the thickest line the camera can see. The "bottom" of the line will be the furthest up the track (nearest the car) that the camera can see. This returns 0 for center, -39 for far left and 39 for far right. These numbers can be used to determine where the car is on the track and make corrections.

int lineFollow([L3, L2, L1, R1, R2, R3]);
This commend accepts the steering values for each of the line sensors. L3 is the furthest left, and R3 is the furthest right. This command will steer the racer by the amount specified in the input array.

int getSteeringValues(int photoMeasurememt[8]);
This command updates photoMeasurement, elements 0 through 5 with the value of the 6 line sensors on the line follow board. These can be used by user-specified code to control the racer.

int photoSensitivity(int photoSense);
This command sets the sensativity of the line follow board sensors. This command is not required but can be used for fine tuning if default values are not adequate.