Need help programming

Ok i want to build a sumo robot with 2 DC motors 2 photoresisters and a servo/IR combo. Id like to use the duemilanove with a motor shield for it all.

I want it to do what stampy from SOR (cant post link tell i have one post) can do but when it hits a black line it stops and backs up a little.

I cant find any sumo robot arduino code all i can find is C code.
Can anyone help me find some code a can change a little to fit my needs or write a sketch? I can build anything but a can't program at all >:(

I want it to do what stampy from SOR

I have no idea what this means.

I suggest that you start with something simple. There is lots of arduino code for motor control and when you have that going you can think about adding code for various sensors.

I have the motors but i want to make shure i can get code befor i get the arduino

i have a bare bones board and getting atarted with arduino book.

With just "arduino" and "sumo" as search terms, I got over 22K hits on Google.
Surely some must be of use?

no most are a list of projects and one project uses a arduino and another is like a PIC or BASIC sumo bot. What do you think would be better a motor shild or http://www.solarbotics.com/products/k_cmd/

I don't know enough about running motors to answer the last question, but there is an Arduino Minisumo here: http://noise0.altervista.org/ (2nd or 3rd link in Google)
Look for the link on the left side of the page.

Also the code on the $50 robot http://www.societyofrobots.com/step_by_step_robot.shtml will work for Arduino. The author doesn't use the Arduino IDE, or chips that have the Arduino bootloader, but uses an ATmega8 chip (same family as Arduino). The code in the photovore.c file can be modified very slightly to run on Arduino.

that mini sumo code will not open becouse its not a .pde file. with the 50 robot i can just download the code to a atmega168 with no changes or change the code to run in Arduino IDE??

The minisumo code is a .7z file, which is a type of zip. You can download 7zip to unzip the file. There are a number of .pde files within the zip.

i can just download the code to a atmega168 with no changes or change the code to run in Arduino IDE??

Not sure on the first one, since I haven't looked at the datasheet to see if all of the pins on the 168 match the 8. If you wanted to use the code as is, you'd be better off buying a $4 ATMega8 chip (instead of a $30 Arduino) and following the example on that site.

Definitely yes to the second one; open the .c file with your favorite text editor, and you'll see that the code inside is pretty similar to what you expect in Arduino.

You'll have to get all of the libraries in place, and rearrange the code a bit. It will take some work and experimentation, but it can be done and you'll better understand the entire process in the end.

how do i unzip the .7z??? And how and what do i edit in the .c file??

You can unzip the 7z with 7zip http://www.7-zip.org/ If you are in windows, right click the file and use the 7z menu to extract it.

.c files are just text (as are .pde files). you can open them with notepad.

You will have to copy the code in the c file and add it to a new Arduino project. Some of it at the top (anything above the main routine, and the variables etc in the main routine) need to be above your loop. The parts in the initialization section need to go into your setup routine, and the parts that are in the while loop would go in your loop.

That's my best guess after looking at the file for a couple of seconds.

You are going to have to move the libraries around to make things work, and even then you will only have some base code. You're still going to have to modify it to match the pins used by the motor shield (if that's the direction you take), etc.

ok i unziped the file and i think changing this will be better then changing the C file i gtg for now but will get back and see what i can do. heres the main code

//piedinatura
int motorL0=9;
int motorL1=6;
int motorR1=10;
int motorR0=11;
int outputBuzzer=5;
int outputLedL=8;
int outputLedR=7;
int outputLed = 13;                 
int inputTeleL = 1;
int inputTeleR = 0;
int inputSirL = 3;
int inputSirR = 2;
int inputBattSens = 4;


//definizioni
int sir_stimL;
int sir_stimR;
boolean sir_warn; 
int sir_offset;  //sbilanciamento 0-1023   [R most stim  >0] [L most stim  <0]


int tele_stimL;
int tele_stimR;
boolean tele_warn; 
int tele_offset;  //sbilanciamento 0-1023  [R most stim  >0] [L most stim  <0]

char side; 






void setup() 
{
  //preset
  Serial.begin(9600);            // initialize serial communication with computer
  pinMode(outputLed, OUTPUT);    // sets the digital pin as output
  pinMode(outputLedL, OUTPUT);    // sets the digital pin as output
  pinMode(outputLedR, OUTPUT);    // sets the digital pin as output


  //motor off
  digitalWrite(motorL0, LOW);
  digitalWrite(motorL1, LOW);
  digitalWrite(motorR0, LOW);
  digitalWrite(motorR1, LOW);


} 



void loop() 
{



 
surv://SURVIVE BORDERS /////////////////////////////////////////////////////////////////////////////////////

  buzzerSet(200);
 
  if ( sir_offset>0 )  {side='L';motorSet("BB",150);yield(70);motorSet("LP",150); }
  else                 {side='R';motorSet("BB",150);yield(70);motorSet("RP",150); }  
  buzzerSet(10); 
  do{readSir();yield(0);}while(sir_warn); 
  
  do{readTele();yield(0);}while(tele_warn); 
    buzzerSet(50);
  yield(100);   
  









hunt://HUNT OPPONENT /////////////////////////////////////////////////////////////////////////////////////

  buzzerSet(0);
  
  if (side=='R'){ motorSet("RP",75); }                     //caccia nella direzione presettata 
  else {motorSet("LP",75); }                               //caccia nella direzione presettata 
    
  do{
    readSir();  if (sir_warn)  {goto surv;}
    readTele();
    yield(0); 
  }while(tele_warn==0); 
      
  if (side=='R'){ motorSet("LP",100); yield(40);}        //controrotazione
  else {motorSet("RP",100); yield(40);}                  //controrotazione
 
  yield(30);
 
  motorSet("xx",0);

goto trgt;








trgt://TARGET OPPONENT /////////////////////////////////////////////////////////////////////////////////////

 
    
  while(true){

    readSir();if (sir_warn) {goto surv;}                  //se al bordo vai a suvive
    readTele();                                           //legge telemetri
    if (tele_warn==0) {goto hunt;}                       //se perde il lock dei telemetri torna in caccia
    if (tele_warn==2) {goto attk;}                        //ok in range-> attack
    if (abs(tele_offset)<70){motorSet("FF",150); buzzerSet(30);}
    else {
       buzzerSet(0);
      if (tele_offset>0){motorSet("RP",60);side='R';}  //pivotta per centrarsi
      else {motorSet("LP",60);side='L';}               //pivotta per centrarsi
    }
    yield(0);
  
  }

 



attk://ATTACK /////////////////////////////////////////////////////////////////////////////////////

 buzzerSet(0);
 
 do{
   yield(0);
   motorSet("FF",200);
   readSir();
 }while(!sir_warn);

  
goto surv;

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  




  
}

i forgot to say thank you guys for the help so...

thank you guys for the help. :smiley: