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

PurpleCobraWallFollowing

/* Add comment

 	- name
	- cohort
	- assignment
	- date
	- ADC CENTER 2 IS THE DIST SENSOR ON THE RIGHT SIDE OF THE ROBOT. CENTER 1 IS IN THE FRONT
  • /

// Include the Command Module API

  1. include "create.h"

// Pointer to the Sensor Data structure cr8_t *cr8;

// Declare any new function prototypes here: // For example: int dashboard(int counter, char partnumber);

// Declare GLOBAL constants used in program:

// Declare GLOBAL Variables used in program:

// Initialize GLOBAL Variables used in program:

// Declaraion for function "main" int main(void) {

  // Allocate memory for sensor data structure
	cr8 = cr8_alloc();

  /* Initialize the Create and Command Module
     Sync communications settings.     */

	cr8_init(cr8);
	cr8_adc_enable(ADC_CENTER_1);
	cr8_adc_enable(ADC_CENTER_2);
  // Declare LOCAL constants used in function main:

  	// For example:  const int Pi100 = 314; 

  // Declare LOCAL Variables used in function main:

	// For example:  int i, j; 				

  // Initialize LOCAL Variables used in function main:

	// For example:  i = 1;	

while (!cr8->button_play) { lcd_printf("%d", cr8->wall_range); cr8_delay (100); } cr8_update(cr8); lcd_printf("%d", cr8->wall_range); cr8_delay (80); if (cr8->adc_center1 < 250)

	{
	cr8_set_leds (1, 1, 0, cr8->wall_range * 2);
	if (cr8->adc_center2 <= 300 && cr8->adc_center2 >= 200 && cr8->adc_center1 < 250)
		{
		cr8_drive_direct (100, 100);
		}
	if (cr8->adc_center2 < 200 && cr8->adc_center1 < 250)
		{
		cr8_drive_direct (100, -50);
		}
	if (cr8->adc_center2 > 300 && cr8->adc_center1 < 250)
		{
		cr8_drive_direct (-50, 100);
		}
	if (cr8->adc_center2 < 100 && cr8->adc_center1 < 250) 
		{
		cr8_drive_direct (-100, 100);
		}
	}	

if (cr8->adc_center1 >=250)

	{
	cr8_drive_direct (-100, 100);
	cr8_set_leds (0, 0, 255, 255);
	}

  cr8_free(cr8);
  return(0);

} // End of function main

/* Declare other functions you create here...

For example, to define function xxxxx of type integer (int)

with two input parameters, sample_num and code...

int xxxxx(int sample_num, char code) {

	// Declare LOCAL constants used in function xxxxx: 


	// Declare LOCAL Variables used in function xxxxx: 

	// Initialize LOCAL Variables ised in function xxxxx: 

	// Write code for function XXXXX here:




  //Return int value for function xxxxx: 
  return(1);      You must always return a value to sending program
			--in this case a 1 to indicate fn done with no problems.

} // End of function xxxxx

  • /
Edit - History - Print - Recent Changes - Search
Page last modified on December 18, 2008, at 08:39 AM