Go Down

Topic: :) Help getting started with Arduino in Paintball gun :) (Read 1 time) previous topic - next topic

fspro2006

Sep 27, 2013, 10:20 pm Last Edit: Sep 28, 2013, 02:20 am by fspro2006 Reason: 1
Hey guys this is my first post, woot!  Anyway I am trying to program a Arduino Nano to operate my paintball marker.  This gun operates a 5v solenoid to fire the gun.  There is also a led and photo tranistor to detect a paintball in the breech.  If the beam of light is broken, a paintball is in the chamber and the bolt should be allowed to move forward.  If there is not a paintball in the breech then the light will hit the phototranistor and the bolt will not be allowed to move forward.  For the solenoid, It need to cycle and stay open for about 15-20 millisecond (dwell time).  I do have plans to add a LCD screen eventually and some other fun extras but for now I need help writing the basic code to get the gun to function correctly.  Some other settings will be rate of fire, semi,full auto, and ramping (3-4 shots semi then the gun shoots at a constant rate as long as I pull the trigger every second or so).  Please anyone with good advice guide me in the general direction and help me with my first Arduino project!  I am an engineering student in my 3rd year of college and soon we will build junior and senior design projects using the Arduino so learning how to programs these now will help me out greatly on my future projects.

Thanks, Kevin



timbit1985

check out the arduino paintball sentry gun on google.

fspro2006

would I have to disect the code of the sentry gun to get the controls I want?  I only need to control the solenoid with the led detectors and micro switch for the trigger.  Sentry gun does way more than that lol, it has infared trackers and 3 servo motors and more features than I need.

zoomkat

You could externally mount a servo to pull the trigger, then the gun wouldn't need to be seriously hacked.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

fspro2006

I want to hold and shoot the gun like I normally would though, I want to know how to get started on coding to control the solenoid based off what the led sensors detect when the trigger is pulled, and add some more settings for a cap on the rate of fire.  I'm not trying to build a sentry type paintball gun.

fspro2006

#5
Sep 28, 2013, 01:44 am Last Edit: Sep 28, 2013, 02:20 am by fspro2006 Reason: 1
Yes this will be my first Arduino project, very excited.  I have only typed up a handful of simple functions and scripts on matlab for engineering class.  Do not know where to start with my project.
         I am trying to put an Adruino Nano Inside my paintball gun to replace the old outdated circuit board.  The Arduino needs to control a 5v solenoid based off of if the 2 led "eye" sensors detect a paintball when the trigger is pulled.  to make everything simple and to get the gun shooting I want semi only, rate of fire, and dwell time for the solenoid.  Where do I start with typing the codes?  
           If a paintball is not all the way in the breech the led light is detected by the photo transistor and if the trigger is pulled the solenoid will NOT fire.  If a paintball is in the breech then the photo transistor will not detect light and if the trigger is pulled the gun WILL fire.

PaulS

This is the Programming forum. Where is your code?

Nick Gammon

Remove the link to "free screenshot software" or be banned for spamming.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Threads merged.

- Moderator
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

fspro2006

removed, didn't know that was a problem, or even there for that matter..just copy and pasted from the website I use to upload.  first day on this forum.. give me a chance to figure things out...my apologies 

Nick Gammon

Welcome to the forum.

Quote

Where do I start with typing the codes? 


I suggest working your way through some of the examples, trying each one out. You will then feel more confident in tackling a larger project.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

fspro2006

went through a couple of them and started tryping the code to operate the solenoid.  used boolean running to send high to solenoid pin 5 when micro switch pin 7   here is what I have so far:

int solenoidpin = 5; // initalize pin 5 for solenoid
 int triggerswitchpin = 7;  // intialize pin 7 for trigger switch
 boolean running = false;
 

void setup(){
 pinMode (solenoidpin, OUTPUT);  //output voltage to solenoid
 pinMode(triggerswitchpin,INPUT); //input voltage from trigger switch
 digitalWrite(triggerswitchpin,HIGH); //input reads high when trigger is pulled
 }

void loop()
{
 if (digitalRead(triggerswitchpin) == HIGH)
 {//trigger is puled - pullup keep pin low normally
 delay(1000);        //delay to debounce switch
 running = !running;    //toggle running variable
 digitalWrite(solenoidpin,running);   //sends signal to solenoid
 delay (14); //dwell time for solenoid
 }
}

zoomkat

Basic button "do something" code, in this case, control a servo, but could control a solenoid and such.

Code: [Select]

//zoomkat servo button test 7-30-2011

#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
Servo servo1;

void setup()
{
  pinMode(button1, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(160);
  }
  else {
    servo1.write(20);
  }
}

Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

tack

What marker are you trying to replace the board in?

fspro2006

Zoocat, thanks, would I just replace servo with solenoid in the code? could you attach some more comments?


What marker are you trying to replace the board in?

Its a 2006 ICD Freestyle Pro, spool valve controlled by solenoid

Go Up