Society of Robots - Robot Forum

Software => Software => Topic started by: amadord on March 14, 2010, 03:00:51 PM

Title: Questions about the $50 dollar robot in programming section
Post by: amadord on March 14, 2010, 03:00:51 PM
I am about to create my own photovore robot. I bought an Arduino Duemilanove instead . My question is , in the programming section of the guide it tells to download photovore source code and compile it and upload it to the microcontroller, do you think this is compatible with the Arduino Duemilanove ???   Is there a risk in breaking a microcomputer when uploading incompatible code. Im just a beginner and need guidance. thanks
Title: Re: Questions about the $50 dollar robot in programming section
Post by: Razor Concepts on March 14, 2010, 03:04:45 PM
There is no risk in breaking the microcontroller - you can't upload "wrong" code because before the computer attempts to flash the microcontroller, the compiler checks to see if the code is ok. If the code is wrong, it will stop the upload and tell you what is wrong. Of course, if you change fuses you could do something but don't worry about that now since with Arduino it is tough to change them.

See http://www.societyofrobots.com/member_tutorials/node/240 (http://www.societyofrobots.com/member_tutorials/node/240)  for arduino compatible code.
Title: Re: Questions about the $50 dollar robot in programming section
Post by: Xyver on March 14, 2010, 04:16:57 PM
I just finished my 50$ robot with my arduino as well.  Heres the code if you like:

// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>

#include <Servo.h>

Servo leftservo;  // create servo object to control a servo
Servo rightservo;

int potpin0 = 0;  // analog pin used to connect the potentiometer
int left;    // variable to read the value from the analog pin
int potpin1 = 1;
int right;
void setup()
{
  leftservo.attach(7);  
  rightservo.attach(8);
  rightservo.write(90);
  leftservo.write(90);
  delay(1000);
}

void loop()
{
  left = analogRead(potpin0);  
  right = analogRead(potpin1);
  
  if(left < right)
  { leftservo.write(75);
  rightservo.write(90);}
  
  else if (left > right)
  { leftservo.write(90);
  rightservo.write(105);}
  
  else
  {leftservo.write(75);
  rightservo.write(105);}
 
}
Title: Re: Questions about the $50 dollar robot in programming section
Post by: amadord on March 14, 2010, 08:16:00 PM
thanks guys for clearing that up and thanks for the code xyver. I let you know how it goes
Title: Re: Questions about the $50 dollar robot in programming section
Post by: amadord on March 15, 2010, 07:40:53 AM
I got another question. Since the duemilanove comes with usb connection , I can just use a usb cable to program the microcontroller right? Or do I have to use an ICSP programmer?
Title: Re: Questions about the $50 dollar robot in programming section
Post by: billhowl on March 15, 2010, 07:57:25 AM
You can use the Arduino IDE to program the microcontroller no need the ICSP programmer.
Here is the more complete code for Arduino IDE photovore robot.
http://www.societyofrobots.com/robotforum/index.php?topic=7759.msg59924#msg59924 (http://www.societyofrobots.com/robotforum/index.php?topic=7759.msg59924#msg59924)
Title: Re: Questions about the $50 dollar robot in programming section
Post by: amadord on March 15, 2010, 08:03:14 AM
You can use the Arduino IDE to program the microcontroller no need the ICSP programmer.
Here is the more complete code for Arduino IDE photovore robot.
http://www.societyofrobots.com/robotforum/index.php?topic=7759.msg59924#msg59924 (http://www.societyofrobots.com/robotforum/index.php?topic=7759.msg59924#msg59924)

thank you very much! I  will let you know how it goes