Recent Changes - Search:

TEAMS Academy Wiki

Explore TEAMS!
for visiting sophomores & juniors

Robotics

EnvBioTech

Bat Design

Assistive Tech


Students


Instructors

TEAMS Forum

TEAMS Calendar

TEAMS Web Site

Wiki Info

edit Student.SideBar

Code

//Trong Nguyen
//Blue Cohort
//Line Following
//November 5
// Include the Command Module API
#include "create.h"
// Pointer to the Sensor Data structure
cr8_t *cr8;
// Main function
int main(void)
{
  ->// Allocate memory for sensor data structure
  ->cr8 = cr8_alloc();

  ->// Initialize the Create and Command Module
  ->// Sync communications settings.
  ->cr8_init(cr8);
//Trong's Line Following
//starts loop
while(true)
{
//polls sensors
  ->cr8_update(cr8);
//if the frontright cliff sensor senses black
//then rotate clockwise and turn on advance and the
//power led bright red
  ->if(cr8->cliff_frontright_range < 905)
  ->{
  ->cr8_drive_direct(500,-500);
  ->cr8_set_leds(off, on, 255, 255);
  ->}
//if the frontleft cliff sensor senses black
//then rotate counter clockwise and turn on play led
  ->else if(cr8->cliff_frontleft_range < 905)
  ->{
  ->cr8_drive_direct(-500,500);
  ->cr8_set_leds(on, off, 0, 0);
  ->}
//if the left cliff sensor senses black
//then rotate counter clockwise and turn on the play and advance leds on
  ->else if(cr8->cliff_left_range < 905)
  ->{
 -> cr8_drive_direct(-500,500);
 -> cr8_set_leds(on, on, 0, 0);
 -> }
//if the right cliff sensor senses black
//then rotate clockwise and turn on the play and power led
//at bright red
  ->else if(cr8->cliff_right_range < 905)
  ->{
  ->cr8_drive_direct(500,-500);
  ->cr8_set_leds(on, off, 255, 255);
  ->}
//if both sensors do not black, then drive at
//100mm/sec
  ->else
  ->{
  ->cr8_drive_direct(100,100);
  ->}
}
  ->// release the sensor data strucutre memory and exit the program
  ->cr8_free(cr8);
  ->return 0;
}
Edit - History - Print - Recent Changes - Search
Page last modified on December 17, 2007, at 09:39 PM