Project

General

Profile

Serial (USB)

Serial is used to print from and read data into the robot.

Sample Code

#include <dragonfly_lib.h>
/*
 * Prints to and reads from serial.
 */
void usb_sample()
{
    usb_init(); // must be called before using any usb code

    usb_puts("Pick a letter from a to z"); // prints out "Pick a letter from a to z" 
    usb_puts("\r\n"); // prints a newline
                      // now, the next thing that is printed will be on the next line

    int letter = usb_getc(); // puts the next character that the user types into the variable letter

    usb_puts("You picked "); // prints out "You picked " 
    usb_putc((char) letter); // prints the character that the user typed
    usb_puts("\r\n"); // prints a newline
}

Header File

For a full list of functions, see the serial code header file

Schematic

usb.png View (217 KB) Emily Hart, 09/07/2009 11:18 PM

serial_schematic.png View (36.1 KB) Emily Hart, 09/16/2009 09:50 PM