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

LineFollowingCode

*Line Following*

// Include the Command Module API

include "create.h"

//Casey Judge

// Red Group

//November 8,2007

//this program enables the robot to follow a black piece of tape made into a track.

//This Line following uses cliff sensor data to instruct the robot on the way to turn.

//If the data is less than 700 on the left then the robot is on the line and should turn to the right.

//If the data is less than 700 on the right then the robot is on the line and should turn to the left.

//If the data is more than 700 then no line is detected and the robot should continue straight.

// 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);
// Start Robot Code Here
while(cr8->button_play == 0)
//will loop while the play button is not pressed
{
cr8_update(cr8);
//pulls the sensor data
if (cr8->cliff_frontleft_range<700)
//if the left front cliff sensor data is less that 700(black tape recognized)
{
cr8_drive_direct(-100,150);
//turns slightly to left
cr8_set_leds(off, off, 0, 255); //power button goes on
}
else if (cr8->cliff_frontright_range<700)
//if the front right cliff sensor is less than 700(on black tape)
{
cr8_drive_direct(150,-100);
//turns slightly to the right
cr8_set_leds(off, on, 0, 0);
//advanced light goes on
}
else
//if no tape is detected
{
cr8_drive_direct(100,100);
//drive straight
cr8_set_leds(on, off, 0, 0);
//play light is on
}
 }

// release the sensor data strucutre memory and exit the program

cr8_free(cr8);

return 0;

}

Attach:judgediscussion3.doc Δ

Attach:judgelinefollowing.ppt Δ

Edit - History - Print - Recent Changes - Search
Page last modified on December 24, 2007, at 11:21 AM