Paul Knox North Augusta, SC

14 robots.
Join Team

About Us

Team Activity

Mission Statement:

These sumo robots will knox you out!

Created: February 2017

Members: 14

Team Captain:

@wbyu2006

Team Events

@madden

Is anybody else here?

@madden

Is that supposed to have "#"'s before the "define"? Also, do we add this to our code?

@jgore5

include <Motor.h>

define leftSensor A1

define rightSensor A2

define IREmitter 6

define echoPin A0

define pingPin 3

define IRthreshold 990

define USthreshold_cm 35 //attack if an object is within 35cm

define maxSpeed 255

define minSpeed -255

define buzzer 5

Motor motor; void setup() { Serial.begin(9600); pinMode(leftSensor, INPUT); pinMode(rightSensor, INPUT); pinMode(IREmitter, OUTPUT); pinMode(echoPin, INPUT); pinMode(pingPin, OUTPUT); pinMode(buzzer, OUTPUT); motor.setupRight (10 , 8); motor.setupLeft (9 , 4); }

void loop() {

//tone(buzzer, 1000, 250); // delay(500); // tone(buzzer,500 , 250); // delay(500); // tone(buzzer, 800, 250); // delay(500); // tone(buzzer,1000 , 250); // delay(500); // tone(buzzer,850 , 250); // delay(500); // tone(buzzer, 999, 250); // delay(500); // tone(buzzer, 500, 500);

IsCloseToOpponent(); if (IsWhite() ) { //backup and turn motor.right (-200); motor.left (-200); delay(1000); motor.right (200); delay(400); } else { //search motor.right (250); motor.left (100); if (IsCloseToOpponent() > 0) { //attack or push or full speed ahead motor.right(maxSpeed); motor.left(maxSpeed); } /else { move forward } / } }

boolean IsCloseToOpponent() { int distance = ping() / 29 / 2; Serial.println(distance); boolean closeToOpponent = distance < USthreshold_cm;

return closeToOpponent; }

boolean IsWhite() { digitalWrite(IREmitter, HIGH); int rightInput = analogRead(rightSensor); int leftInput = analogRead(leftSensor); Serial.print("Left/"); Serial.println(leftInput); Serial.print(" - Right/"); Serial.println(rightInput); delay(5); boolean whiteBoolean = rightInput < IRthreshold; return whiteBoolean; }

long ping() { long duration; digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(10); digitalWrite(pingPin, LOW); duration = pulseIn(echoPin, HIGH); return duration; }

@KnightC3

Hey

@madden

helloooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

@madden

That's my code.

@madden

Your welcome

@madden

include <Motor.h>

define button 2

boolean pressed; int lastRead;

define leftSensor A1 //left ir sensor

define rightSensor A2 //right ir sensor

define IREmitter 6

//Ultasonic

define pongPin A0 //Listen for distance

define pingPin 3 //Emit signal

Motor motor;

void setup() { // put your setup code here, to run once:

Serial.begin(9600);

pinMode(button, INPUT_PULLUP);

//load left and right color sensors pinMode(leftSensor, INPUT); pinMode(rightSensor, INPUT); pinMode(IREmitter, OUTPUT);

motor.setupRight(10, 8); motor.setupLeft(9, 4); }

const int FAST = 255, SLOW = 220; int step = 0;

void loop() { lastRead = digitalRead(button);

if (pressed && lastRead == 0) { stopMotors(); pressed = false; return; }else if (!pressed) { return; }

if (!pressed && lastRead == 1) { pressed = true; delay(3000); driveStraight(-FAST); delay(1321); stopMotors();

turnLeft(-FAST); delay(144); stopMotors();

turnRight(-FAST); delay(233); stopMotors(); } if (isWhiteRight() && isWhiteLeft()) { stopMotors();

//Backup for 2 secobds at full speed
driveStraight(-FAST);
delay(2000);
stopMotors();

//Turn left in reverse for half a second
turnLeft(-FAST);
delay(500);
stopMotors();

//Turn right forwards for 3/4's of a second
turnRight(FAST);
delay(750);
stopMotors();

//  driving straight and waiting 2 seconds and turning

} else if (isWhiteRight () && !isWhiteLeft()) { stopMotors();

//Turn left in reverse for half a second
turnLeft(-FAST);
delay(500);
stopMotors();

//Turn right forwards for 3/4's of a second
turnRight(FAST);
delay(100);
stopMotors();

} else if (!isWhiteRight () && isWhiteLeft()) { stopMotors();

//Turn left in reverse for half a second
turnLeft(-FAST);
delay(500);
stopMotors();

//Turn right forwards for 3/4's of a second
turnLeft(FAST);
delay(100);
stopMotors();

} else { //There is an object in front of us if (distanceInCentimeters() <= 12) { driveStraight(FAST); } else { driveStraight(SLOW); } }

}

void stopMotors() { driveStraight(0); }

void driveStraight(int speed) { if (speed >= -255 && speed <= 255) { motor.right(speed); motor.left(speed); } }

void driveStraight(int speed, long timeInMillis) { driveStraight(speed); delay(timeInMillis); stopMotors(); }

void turnLeft(int speed) { if (speed >= -255 && speed <= 255) { motor.right(speed); } }

void turnRight(int speed) { if (speed >= -255 && speed <= 255) { motor.left(speed); } }

//TODO boolean isWhiteRight() { digitalWrite(IREmitter, HIGH); int rightInput = analogRead(rightSensor); return (rightInput < 1000); }

//TODO boolean isWhiteLeft() { digitalWrite(IREmitter, HIGH); int leftInput = analogRead(leftSensor); return (leftInput < 1000); }

long checkPing() { digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(10); digitalWrite(pingPin, LOW); return pulseIn(pongPin, HIGH); } long distanceInCentimeters() { return checkPing() / 58; }

@madden

Hi

@Eridan

Yooooooo what up guys

@69SlimShady420

hey guys, hows it rollin bbbbboooooyyysss

@saucyBOY

boi

@price

;ljas

@T3r3z1

4y3 bo1 w4ddup 1 h4v33 4 prombl3m lol h4lp

@nein

meow