Society of Robots - Robot Forum
Software => Software => Topic started by: the609blues on February 08, 2008, 05:41:00 PM
-
Hi im making a robotic airsoft gun and im having trouble with the code
1. I have hitec 475-hb servo
2. two parralax pir sensors
3.and a dc motor
i need the code so that if pir detects left not right then move left and so on if pir left and right = then motor shoot
im trying to use the 50 robot code but it is not working
any help
I need it asap
-
post your code.
-
Ive tried to program it using the 50$ robot but i cant and i have no idea how to program it can somebody help?
i need it so that the servo moves the gun into the direction based on the pir sensors and if they are equal then turn on the motor with a switch
psuedo
if pir left >pir right then servo move left
else if pir left< pir right then servo move left
if pir left = pir right then motor on
please help asap
-
post the code!!!!!!! ;D. even if it is Admins code show us how you modified it.
-
post the code!!!!!!! ;D. even if it is Admins code show us how you modified it.
I cant modify it. i have no idea what to do. I cant find anything online.
-
well you can't just use Admins photovore code and expect it to work. you'll have to make a whole new program although you could probably keep the makefile and stuff. You'll have to modify the makefile and the .h file.....i think.
-
shoulda used an ESC. wouldnt have needed to change the code
-
alright heres my code but i get this make:
*** No rule to make target `Photovore_v1.elf', needed by `elf'. Stop.
Build failed with 1 errors and 0 warnings...
i have a sensor in front to read body temp and a sensor on top for room temp and if ther is a difference then a servo triggers a switch
i dont know if i put all of this together or have it seperate
#include <avr/io.h>
#include <avr/interrupt.h>
#include "global.h"
#define PORT_ON( port_letter, number ) port_letter |= (1<<number)
#define PORT_OFF( port_letter, number ) port_letter &= ~(1<<number)
#define PORT_ALL_ON( port_letter, number ) port_letter |= (number)
#define PORT_ALL_OFF( port_letter, number ) port_letter &= ~(number)
#define FLIP_PORT( port_letter, number ) port_letter ^= (1<<number)
#define PORT_IS_ON( port_letter, number ) ( port_letter & (1<<number) )
#define PORT_IS_OFF( port_letter, number ) !( port_letter & (1<<number) )
void configure_ports(void)
{
DDRC = 0x00;
PORTC = 0x00;
DDRD = 0xFF;
DDRB = 0xC7;
}
void delay_cycles(unsigned long int cycles)
{
while(cycles > 0)
cycles--;
}
void LED_on(void)
{
PORT_OFF(PORTD, 4);
}
void LED_off(void)
{
PORT_ON(PORTD, 4);
}
void servo_left(signed long int speed)
{
PORT_ON(PORTD, 0);
delay_cycles(speed);
PORT_OFF(PORTD, 0);
delay_cycles(200);
}
#include "SoR_Utils.h"
int main(void)
{
int sensor_left=0;
int sensor_right=0;
int threshold=8;
configure_ports();
a2dInit();
a2dSetPrescaler(ADC_PRESCALE_DIV32);
a2dSetReference(ADC_REFERENCE_AVCC);
LED_off();
while(1)
{
sensor_left=a2dConvert8bit(5);
sensor_right=a2dConvert8bit(4);
if(sensor_left > sensor_right && (sensor_left - sensor_right) > threshold)
{servo_left(44);
}
i=250;
while(i>0)
{
servo_left(40);
i--;
}
i=250;
while(i>0)
{
servo_left(24);
i--;
}
delay_cycles(500);
}
return 0;
}
-
*** No rule to make target `Photovore_v1.elf'
i got the same problem but than i tried downloading all the code and stuff exactly like Admin says and it worked. you can not change the name of the project with out changing the makefile. just follow Admins instructions.
(for the file names and stuff atleast)
-
Is the DC motor the actuator that rotates the gun?
Check this post on how to wire/program a motor driver with the $50 Robot:
http://www.societyofrobots.com/robotforum/index.php?topic=3151.0