Cerebellum API Reference: The purpose of this document is to provide you with a quick means of referencing the API functions used to control your Cerebellum unit. Included are the function prototypes, descriptions, and an example of using the function. Timer Control: void pause(char c) Pauses the program for c milliseconds, where c is in the range [1,255] Nothing else will execute during this period, so be careful what you do. pause(100); //pauses the program for a tenth of a second void halfPause(char c) Pauses the program for c half-seconds. Use this to pause for longer periods of time. Nothing else will execute during this period. halfPause(2); //pauses the program for one second void fullPause(char c) Pauses the program for c seconds. Use this to pause for really long periods of time. Nothing else in the program executes during the pause period. fullPause(60); //pauses for an entire minute ======================================================================================== LED Control: void ledOn(char c) Turns on the LED. Use the predefined GREEN and YELLOW values as input to this function. ledOn(GREEN); //turns on the green LED void ledOff(char c) Turns off the LED. Once again, used the predefined GREEN/YELLOW values. ledOff(GREEN); //turns off the green LED void ledFlash(char c, char msec) Turns on a particular LED for msec miliseconds. Program execution halts during this function call. ledFlash(GREEN, 100); //turns on the GREEN LED for a tenth of a second. void allLedOff(void) Turns off all of the LEDs. allLedOff(); //turns off all LEDs void allLedOn(void) Turns on all of the LEDs. allLedOn(); //turns on all of the LEDs ========================================================================================= Button control: char btn1(void) Checks to see whether button 1 is pressed. Returns a TRUE/FALSE (1/0) value. while( !btn1() ); //waits until button 1 is pressed char btn2(void) Checks to see whether button 2 is pressed. Returns a 1 or 0 value. while( !btn2() ); //waits until button 2 is pressed before continuing execution char button(char which) Checks to see whether the which (1 or 2) button is pressed. while( !button(1) ); //waits for button 1 to be pressed ========================================================================================== Initialization of the Cerebellum- void initialize(void) Initializes the chip by initializing the chip, servos, and interrupts. initialize(); //should be at the start of all of your programs void initializeChip(void) Only initializes the chip, such that you save memory if not using the servos. initializeChip(); //initialized for limited usage void initializeServos(void) Only initializes the servos. Make sure that you initialize the chip first! initializeChip(); initializeServos(); //I'm only using the servos void initializeAnalog(void) Only initializes the analog IO for sensors. initializeChip(); initializeAnalog(); //sets up the analog IO for sensors void initializeSerial(void) This function will set up the code for sending and receiving data over the serial port cable. It must be called in addition to initialize() and any of the other specific initializations. initialize(); initializeSerial(); //setup to use functions for sending and receiving data ============================================================================================== Analog Input/Output char readPort(char port) Reads the analog value of the port. Port should be on the range [0,7]. sendValue( readPort(0) ); //writes out the numeric value being read on port 0 ============================================================================================== Serial Input/Output void sendByte(char c) Used to send printed characters across the serial cable to a program like Hyperterminal. for( char c = 'A'; c <= 'Z'; c++ ) //prints out the alphabet in capital letters sendByte(c); void sendString(const char *text) Sends a string over the serial, taking escape sequences such as \n, \r, \t, \\, \" sendString("this is a string with \ttabs, \\backslashes\\, and linebreaks\n"); void sendValue(char c) Sends the numeric value of the character over the serial port. sendValue('A'); //will print out 65 if read in Hyperterminal char checkSerial() Gets a character in buffer, using a nonblocking method. That is, if the buffer is empty, the function will return a 0 and not stop your program. while( !checkSerial() ); //will halt your program until you send it a character over the serial cable.