Author Topic: Airsoft  (Read 3620 times)

0 Members and 1 Guest are viewing this topic.

Offline the609bluesTopic starter

  • Jr. Member
  • **
  • Posts: 20
  • Helpful? 0
Airsoft
« 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

Offline Rebelgium

  • Supreme Robot
  • *****
  • Posts: 637
  • Helpful? 0
  • It's called the future ... We like it here
    • orgcrime.net
Re: Airsoft
« Reply #1 on: February 08, 2008, 07:45:29 PM »
post your code.
To relax after some hard work on robotics: A very fun free online text based MMORPG
orgcrime.net

Offline the609bluesTopic starter

  • Jr. Member
  • **
  • Posts: 20
  • Helpful? 0
Re: Airsoft
« Reply #2 on: February 09, 2008, 02:49:13 PM »
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

Offline Trumpkin

  • Supreme Robot
  • *****
  • Posts: 1,176
  • Helpful? 5
Re: Airsoft
« Reply #3 on: February 09, 2008, 03:46:42 PM »
post the code!!!!!!!  ;D. even if it is Admins code show us how you modified it.
Robots are awesome!

Offline the609bluesTopic starter

  • Jr. Member
  • **
  • Posts: 20
  • Helpful? 0
Re: Airsoft
« Reply #4 on: February 09, 2008, 04:05:16 PM »
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.

Offline Trumpkin

  • Supreme Robot
  • *****
  • Posts: 1,176
  • Helpful? 5
Re: Airsoft
« Reply #5 on: February 09, 2008, 04:33:55 PM »
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.
Robots are awesome!

Offline ed1380

  • Supreme Robot
  • *****
  • Posts: 1,478
  • Helpful? 3
Re: Airsoft
« Reply #6 on: February 09, 2008, 07:00:25 PM »
shoulda used an ESC. wouldnt have needed to change the code
Problems making the $50 robot circuit board?
click here. http://www.societyofrobots.com/robotforum/index.php?topic=3292.msg25198#msg25198

Offline the609bluesTopic starter

  • Jr. Member
  • **
  • Posts: 20
  • Helpful? 0
Re: Airsoft
« Reply #7 on: February 09, 2008, 11:01:09 PM »
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;
   }



Offline Trumpkin

  • Supreme Robot
  • *****
  • Posts: 1,176
  • Helpful? 5
Re: Airsoft
« Reply #8 on: February 10, 2008, 09:10:24 AM »
Quote
*** 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)
« Last Edit: February 10, 2008, 09:11:21 AM by Trumpkin »
Robots are awesome!

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Airsoft
« Reply #9 on: February 17, 2008, 09:45:11 AM »
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

 


Get Your Ad Here

data_list