Roboduino question

I am using the roboduino and Im programming it through the Arduino software but I cant seem to write the code. Im just building a basic photovore. I just have two servos and two photoresistors. I was following a tutorial at society of robots but the programming isnt working out the way they have it so I was just going to use the arduino software instead. Does anyone know of or have a source code for a basic photovore that I can use in arduino and modify if needed? Please help! Ill help others in whatever way that I can. Robotics is new to me but Im a kinetic sculptor who does work with everything from metal work to ceramics to electrical etc. I can help in those ways. I just need help programming this! haha

Can you post what you've got? Some idea of the layout of your invention?

What would you like posted? Im working off of this tutorial: http://www.societyofrobots.com/member_tutorials/node/240 which is a modification of the original tutorial but im only using this for the programming and curcuit section. My chassis is totally different and actually uses a walking mechanism inspired by theo jansens work that is powered by two servos. The two servos plug into the roboduino at pins 5 and 6 and the photoresistors plug into the analog pins 0 and 1. I followed their programming section in that tutorial and used their source code using AVR studio but it simply moves in circles. When I did the test for the servos using arduino everything worked fine. So I was hoping someone had a basic photovore source code that I could use in Arduino. Does that answer your question?

Something like this: http://www.youtube.com/watch?v=-GgOn66knqA ?

OK, so yours goes around in circles, which suggests that one of the motors isn't rotating.

Have you tried disabling the software that makes movement conditional upon the inputs from the photo sensors?

I.e. just trying to get the bot to walk in a straight line?

Yeah I used that leg design and constructed two separate leg units (six legs per unit) and each unit has its own servo.

Well what happens when I finish programming it is that one motor spins fast and the other spins in the same direction but spins much slower. The motors work fine because I can switch them and they still work. Which ever motor is in pin 5 goes faster. The other thing is, the photocells dont seems to have any effect on the movement. I can cover them up or expose them to light, i can even remove them and the servos continue moving in the same manner. (one faster than the other) No variation at all. Thats why I was wondering if anyone has or knows of a code that can be used in the arduino software because it worked the first time when I tested the servo in arduino with the sweep code.
Have you ever seen the problem that Im having? I wouldnt mind continuing use of AVR studio if I could just figure out why its messing up in the first place.

What are the motors? You mentioned servos earlier - are these continuous rotation-modified servos? Or just DC motors? How are you driving them?

I really, really do suggest that you don't try to get everything to work all in one step. Write a simple sketch to test the values you're getting back from the photocells. A simple loop should do, that prints a pair of values per loop, then you can cover or illuminate a cell and test the effect.

Im using parallax continuous rotation servos. I didnt modify servos, I just got those servos that were already modified for continuous rotation. Those servos are direct drive to my axle which is stepped for the legs. Its all powered by a 6v tenergy 2300mah battery pack.

sigh that stuff mostly just goes over my head. I understand the concept, just not how to do it. Im too new to all of this.

You try this codeā€¦

/****************************************************************************
*

  • Copyright (c) 2007 www.societyofrobots.com
  • (please link back if you use this code!)
  • This program is free software; you can redistribute it and/or modify
  • it under the terms of the GNU General Public License version 2 as
  • published by the Free Software Foundation.
  • Alternatively, this software may be distributed under the terms of BSD
  • license.
  • Photovore v1.01, April 27th, 2009
  • Simple case-based method for a robot that chases light.
  • modified to run in Arduino IDE
  • http://www.arduino.cc/

****************************************************************************/

#include <Servo.h>

Servo servo_left; // create servo object to control a servo
// a maximum of eight servo objects can be created
Servo servo_right; // create servo object to control a servo

int ledPin = 13; // LED connected to digital pin 13

void setup() // run once, when the sketch starts
{

servo_left.attach(9); // attaches the servo on pin 9 to the servo object
servo_right.attach(10); // attaches the servo on pin 10 to the servo object
pinMode(ledPin, OUTPUT); // sets the digital pin as output

}

int sensor_left=0;//left photoresistor
int sensor_right=0;//right photoresistor
int threshold=8;//the larger this number, the more likely your robot will drive straight

void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
//store sensor data
sensor_left = analogRead(0); // reads the value of the left photoresistor (value between 0 and 1023)
sensor_left = map(sensor_left, 0, 1023, 0, 255); // scale it to use it with the 8bits (value between 0 and 255)
sensor_right = analogRead(1); // reads the value of the right photoresistor (value between 0 and 1023)
sensor_right = map(sensor_right, 0, 1023, 0, 255); // scale it to use it with the 8bits (value between 0 and 255)

//detects more light on left side of robot
if(sensor_left > sensor_right && (sensor_left - sensor_right) > threshold)
{//go left
servo_left.write(0);
servo_right.write(150);
}

//detects more light on right side of robot
else if(sensor_right > sensor_left && (sensor_right - sensor_left) > threshold)
{//go right
servo_left.write(150);
servo_right.write(0);
}

//light is about equal on both sides
else
{//go straight
servo_left.write(150);
servo_right.write(150);
}
delay(25); // waits 25ms for a small delay to prevent crazy oscillations
digitalWrite(ledPin, LOW); // sets the LED off
}

hope this can help :slight_smile: