Pages: [1]   Go Down
Author Topic: Need help programming  (Read 1841 times)
0 Members and 1 Guest are viewing this topic.
ohio
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino==sweet
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 >smiley-sad
Logged

Need help building something pm me.
Need help programming DON'T pm me.

Im the one that needs the help.

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I want it to do what stampy from SOR

I have no idea what this means.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

ohio
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino==sweet
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.societyofrobots.com/robot_sumo.shtml

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

Need help building something pm me.
Need help programming DON'T pm me.

Im the one that needs the help.

ohio
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino==sweet
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Need help building something pm me.
Need help programming DON'T pm me.

Im the one that needs the help.

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

ohio
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino==sweet
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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/
Logged

Need help building something pm me.
Need help programming DON'T pm me.

Im the one that needs the help.

Offline Offline
Full Member
***
Karma: 0
Posts: 138
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

ohio
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino==sweet
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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??
Logged

Need help building something pm me.
Need help programming DON'T pm me.

Im the one that needs the help.

Offline Offline
Full Member
***
Karma: 0
Posts: 138
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Quote
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.
Logged

ohio
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino==sweet
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Need help building something pm me.
Need help programming DON'T pm me.

Im the one that needs the help.

Offline Offline
Full Member
***
Karma: 0
Posts: 138
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

ohio
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino==sweet
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
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;

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  




  
}
« Last Edit: June 27, 2009, 08:55:10 am by robochan » Logged

Need help building something pm me.
Need help programming DON'T pm me.

Im the one that needs the help.

ohio
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino==sweet
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

thank you guys for the help. smiley-grin
Logged

Need help building something pm me.
Need help programming DON'T pm me.

Im the one that needs the help.

Pages: [1]   Go Up
Jump to: