This repository has been archived by the owner on Jul 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#pragma config(Sensor, dgtl12, bowBump, sensorTouch) | ||
#pragma config(Sensor, dgtl3, ledINIT, sensorLEDtoVCC) | ||
#pragma config(Sensor, dgtl6, led2, sensorLEDtoVCC) | ||
#pragma config(Sensor, dgtl9, led3, sensorLEDtoVCC) | ||
#pragma config(Motor, port6, starboardFWD, tmotorServoContinuousRotation, openLoop) | ||
#pragma config(Motor, port7, starboardBACK, tmotorServoContinuousRotation, openLoop) | ||
#pragma config(Motor, port8, portFWD, tmotorServoContinuousRotation, openLoop) | ||
#pragma config(Motor, port9, portBACK, tmotorServoContinuousRotation, openLoop) | ||
/* | ||
Project Title: Roomba | ||
Team Members: Grennon, Kyle, Pat, Buddy | ||
Date: 10/22/2018 | ||
Section: Block C | ||
Task Description: Make a roomba that turns when it hits stuff | ||
Pseudocode: | ||
Make the robot move forward until bowBump is pressed | ||
Then have the code move robot backwards and spin for an amt of time that is determined by a wait comand with a random Int inside of it | ||
We might put it in a while loop this way it runs contunuiously | ||
*/ | ||
|
||
void motorStop(){ | ||
stopMotor(portBACK); | ||
stopMotor(starboardBACK); | ||
stopMotor(starboardFWD); | ||
stopMotor(portFWD); | ||
} | ||
void backOff(){ | ||
int left_or_right; | ||
left_or_right = rand() % 2; | ||
motorStop(); | ||
wait(0.5); | ||
startMotor(portFWD, 43); | ||
startMotor(portBACK, 43); | ||
startMotor(starboardFWD, -42); | ||
startMotor(starboardFWD, -42); | ||
wait(1); | ||
motorStop(); | ||
if(left_or_right == 0){ | ||
startMotor(portFWD, -43); | ||
startMotor(portBACK, -43); | ||
startMotor(starboardFWD, -42); | ||
startMotor(starboardFWD, -42); | ||
wait(2); | ||
motorStop(); | ||
|
||
} | ||
if(left_or_right == 1){ | ||
startMotor(portFWD, 43); | ||
startMotor(portBACK, 43); | ||
startMotor(starboardFWD, 42); | ||
startMotor(starboardFWD, 42); | ||
wait(2); | ||
motorStop(); | ||
} | ||
|
||
} | ||
|
||
task main(){ | ||
wait(5); | ||
while(1 == 1){ | ||
startMotor(portFWD, -43); | ||
startMotor(portBACK, -43); | ||
startMotor(starboardFWD, 42); | ||
startMotor(starboardFWD, 42); | ||
|
||
if(SensorValue[bowBump] == 1){ | ||
backOff(); | ||
|
||
} | ||
} | ||
} |