"CB - Task - 1 - Sandbox.h": #Include
"CB - Task - 1 - Sandbox.h": #Include
"CB - Task - 1 - Sandbox.h": #Include
**
Team Id: <eYRC#2955>
* Author List: <Areeb, Akdas>
* Filename: <CB_task_1_sandbox.cpp>
* Theme: <contruct o bot>
* Functions: <task_1_1(), task1_1(),left_turn_wls(), right_turn_wls,e_shape, task_1_2>
* Global Variables: <forward, right, left, soft_right(), soft_left(), velocity(),
ADC_conversion()>
*
*/
#include "CB_Task_1_Sandbox.h"
/*
*
* Function Name: forward_wls
* Input: node
* Output: void
* Logic: Uses white line sensors to go forward by the number of nodes specified
* Example Call: forward_wls(2); //Goes forward by two nodes
*
*/
/*
*
*Function Name : <task1_1>
* Input : <total number of nodes that are in the scene of task 1_1>
* Output : <Return value with description if any>
* Logic : <performs the given task 1_1 for eYantra>
*Example Call : <task1_1(17)>
*
*/
void task1_1(unsigned char node) {
// Here node is the total numbe rof nodes that we find on the task_1_1 scene and
upon counting they come out to be 17
while (node > 0) {
unsigned char left_sensor = 1, centre_sensor = 1, right_sensor = 1;
left_sensor = ADC_Conversion(1); // we assign value of left white sensor to
the the variable
centre_sensor = ADC_Conversion(2); // we assign value of centre white
sensor to the the variable
right_sensor = ADC_Conversion(3); // we assign value of centre white sensor
to the the variable
if (left_sensor == 0 && centre_sensor != 0 && right_sensor == 0) {
}
else if (left_sensor != 0 && centre_sensor == 0 && right_sensor == 0) {
}
else if (left_sensor == 0 && centre_sensor == 0 && right_sensor != 0) {
forward();
velocity(255, 200);
_delay_ms(70);
stop();
_delay_ms(500);
soft_right();
_delay_ms(960);
forward();
_delay_ms(150);
}
if (node == 15) {
forward();
_delay_ms(500);
}
if (node == 14) {
stop();
_delay_ms(50);
printf("%d %d %d\n", left_sensor, centre_sensor,
right_sensor);
soft_left();
_delay_ms(1000);
forward();
_delay_ms(80);
stop();
_delay_ms(500);
soft_right();
_delay_ms(430);
forward();
_delay_ms(380);
soft_left();
_delay_ms(730);
forward();
_delay_ms(300);
soft_right();
_delay_ms(330);
forward();
_delay_ms(30);
}
if (node == 13) {
forward();
_delay_ms(550);
if (node == 12) {
soft_left();
_delay_ms(960);
forward();
_delay_ms(110);
if (node == 11) {
forward();
_delay_ms(250);
right();
_delay_ms(480);
forward();
_delay_ms(200);
int blocks = 2;
while (blocks > 0) {
forward();
_delay_ms(70);
left();
_delay_ms(130);
forward();
_delay_ms(120);
right();
_delay_ms(140);
forward();
_delay_ms(300);
right();
_delay_ms(120);
forward();
_delay_ms(100);
left();
_delay_ms(110);
forward();
_delay_ms(280);
blocks--;
}
}
if (node == 10) {
soft_left();
_delay_ms(930);
}
if (node == 9) {
forward();
_delay_ms(1100);
}
if (node == 8) {
forward();
_delay_ms(1100);
}
if (node == 7) {
soft_right();
_delay_ms(950);
forward();
_delay_ms(50);
}
if (node == 6) {
soft_right();
_delay_ms(920);
forward();
_delay_ms(50);
}
if (node == 5) {
soft_left();
_delay_ms(950);
forward();
_delay_ms(100);
if (left_sensor == 0 && centre_sensor != 0 && right_sensor ==
0)
{
forward();
_delay_ms(10);
}
else {
forward();
_delay_ms(1200);
}
forward();
_delay_ms(100);
}
if (node == 4) {
soft_right();
_delay_ms(900);
}
if (node == 3) {
forward();
_delay_ms(400);
}
if (node == 2) {
soft_left();
_delay_ms(1000);
}
if (node == 1) {
forward();
_delay_ms(200);
}
}
}
}
/*
*
* Function Name: left_turn_wls
* Input: void
* Output: void
* Logic: Uses white line sensors to turn left until black line is encountered
* Example Call: left_turn_wls(); //Turns right until black line is encountered
*
*/
void left_turn_wls(void)
{
//stop();
left();
//soft_left();
//velocity(200, 250);
//_delay_ms(250);
//forward();
}
/*
*
* Function Name: right_turn_wls
* Input: void
* Output: void
* Logic: Uses white line sensors to turn right until black line is encountered
* Example Call: right_turn_wls(); //Turns right until black line is encountered
*/
void right_turn_wls(void)
{
//stop();
right();
//soft_right();
//velocity(250, 200);
//_delay_ms(250);
//forward();
}
/*
*
* Function Name: e_shape
* Input: void
* Output: void
* Logic: Use this function to make the robot trace a e shape path on the arena
* Example Call: e_shape();
*/
void e_shape(void)
{
/*
*
* Function Name: Task_1_1
* Input: void
* Output: void
* Logic: Use this function to encapsulate your Task 1.1 logic
* Example Call: Task_1_1();
*/
void Task_1_1(void)
{
task1_1(17);
/*
*
* Function Name: Task_1_2
* Input: void
* Output: void
* Logic: Use this function to encapsulate your Task 1.2 logic
* Example Call: Task_1_2();
*/
void Task_1_2(void)
{
//write your task 1.2 logic here
}