(Photo from the Robotics Society of S. California.)
Build a Sumobot? But what is it? A Sumobot is a robot that competes in a sumobot contest. A sumobot contest is like a human sumo competition except done with robots, usually robots on wheels. The goal is to push the other sumobot out of the sumobot arena.
Sample Sumobot Program (sketch) for Arduino Uno
// Arduino Sumobot
/*
The idea is to run your sumobot slowly so that it does not leave the ring. It helps if it makes small circles in the ring. Once your bump detector hits another sumobot, your sumobot should push the other robot out with full power. When you build a sumobot, this is important.
*/
#include <Servo.h>
Servo myservo1; // create servo variable to control servo 1
Servo myservo2; // create servo variable to control servo 2
void setup() // Code that runs once goes here.
{
Serial.begin(9600);
myservo1.attach(3); // servo 1 on DIGITAL pin 3
myservo2.attach(4); // servo 2 on DIGITAL pin 4
pinMode(2, INPUT_PULLUP); // bump switch on pin 2
}
void loop() // Code that runs "forever" goes here.
{
int LightSensorValue = analogRead(A0); // read the light sensor on analog pin 0:
Serial.println(LightSensorValue); // // print out the value of the light sensor that you read
pinMode(6, OUTPUT); // Tell the Arduino that we will want 5 volts on pin 6 to turn on an LED. (output mode)
digitalWrite(6, HIGH); // turn the LED on (HIGH is the voltage level)
// If we are outside of the ring (in the white area) BACKUP
if (LightSensorValue < 850) // this number will probably need to be adjusted based on your LED. If you are very clever, you might try adjusting it automatically before your Sumobot moves. This is also important when you build a sumobot.
{
myservo1.write(85); // BACK UP!
myservo2.write(180); // BACK UP!
delay (1000); // keep backing up for a bit.
}
// otherwise keep looking for other sumobots:
myservo1.write(97); // Turn LEFT servo drive wheel on: slow (93 is stopped
myservo2.write(85); // Turn RIGHT servo drive wheel on: slow (94 is stopped)
int sensorVal = digitalRead(2); // Check to see if we hit something
if (sensorVal == LOW) // if we bumped into something FULL SPEED AHEAD!
{
myservo1.write(180); // FULL SPEED AHEAD!
myservo2.write(0); // FULL SPEED AHEAD!
delay (1000); // run the motors for a bit.
} // end of "if"
} // end of "loop"