diff --git a/GyverGun/README.md b/GyverGun/README.md new file mode 100644 index 0000000..b389804 --- /dev/null +++ b/GyverGun/README.md @@ -0,0 +1,20 @@ +# DIY full auto pneumatic rifle with Arduino +[![MadGyver YouTube](http://alexgyver.ru/git_banner2.jpg)](https://www.youtube.com/channel/UCNEOyqhGzutj-YS-d5ckYdg?sub_confirmation=1) + +## Project description +Full-auto BB pneumatic rifle on Arduino +- 2 shots per second +- Servo powered reload +- Shoots BB 4.5mm airsoft balls +- About 70 balls in magazine +- Muzzle energy 3 Joules +- [Quick start with Arduino](https://learn.sparkfun.com/tutorials/installing-arduino-ide) + +## Download last release +[**Click me**](https://github.com/AlexGyver/EnglishProjects/releases/download/GyverGun/GyverGun.rar) + +## Schemes +![GyverGun](https://github.com/AlexGyver/EnglishProjects/blob/master/GyverGun/drawings/GyverGun_bb.jpg) + +## Components +* Arduino NANO http://ali.pub/2sq5d4 \ No newline at end of file diff --git a/GyverGun/drawings/GyverGun.fzz b/GyverGun/drawings/GyverGun.fzz new file mode 100644 index 0000000..22d89e2 Binary files /dev/null and b/GyverGun/drawings/GyverGun.fzz differ diff --git a/GyverGun/drawings/GyverGun_bb.jpg b/GyverGun/drawings/GyverGun_bb.jpg new file mode 100644 index 0000000..bf984d2 Binary files /dev/null and b/GyverGun/drawings/GyverGun_bb.jpg differ diff --git a/GyverGun/firmware/valve_servo_automatic/valve_servo_automatic.ino b/GyverGun/firmware/valve_servo_automatic/valve_servo_automatic.ino new file mode 100644 index 0000000..109c1e0 --- /dev/null +++ b/GyverGun/firmware/valve_servo_automatic/valve_servo_automatic.ino @@ -0,0 +1,62 @@ +/* + Created 2016 + by AlexGyver + AlexGyver Technologies + for MadGyver YouTube channel +*/ + +#define MODE 5 +#define TRIGGER 3 +#define VALVE 2 +#define SERVO 4 + +#define STARTPOS 145 // bolt is open +#define STOPPOS 51 // bolt is closed +#define VALVE_DELAY 20 // valve open delay in ms + +#include +Servo servo; + +byte flag = 0; +byte trigger = 0; +byte set = 0; + +void setup() +{ + pinMode(VALVE, OUTPUT); + pinMode(TRIGGER, INPUT_PULLUP); + pinMode(MODE, INPUT_PULLUP); + + servo.attach(SERVO); + servo.write(STOPPOS); +} + +void shot() { + digitalWrite(VALVE, HIGH); // open valve + delay(VALVE_DELAY); // wait + digitalWrite(VALVE, LOW); // close valve + delay(20); // wait for ball to go away + servo.write(STOPPOS); // open bolt + delay(272); // wait for new ball + servo.write(STOPPOS); // close bolt + delay(272); // wait ball to settle +} + +void loop() { + set = !digitalRead(MODE); + trigger = !digitalRead(TRIGGER); + + if (trigger && !set && !flag) { + shot(); + flag = 1; + } + + if (!trigger && !set && flag) { + flag = 0; + } + + if (trigger && set && !flag) { + shot(); + } + delay(5); +}