THIS IS PROTOTYPE!
This is mobile app code and hardware code + circuit for automatic air cannon. It was made during Sporthack 2020 to deliver small packages that would fall down from air using parachutes. The mechanical part is not included. This cannon is built like a turret and can be made to shoot at certain locations using formulas and right calculations.
App was made using Nativescript and Angular, hardware was made using Node MCU ESP32S in C.
For ESP32 I made 3 libraries for hardware control (they are in lib folder)
- Bluetooth.h
- Motor.h
- Switch.h
This library uses 3 additional ESP32 libraries, BLEDevice.h, BLEUtils.h, BLEServer.h for using Bluetooth v4 on ESP
void checkNewData()
checks if vale in BTv4 characteristic has been changedbool getNewData()
if there are new data then returns trueint getXAxis()
returns X axis valueint getYAxis()
returns Y axis valuebool getShoot()
returns bool if cannon should shootbool getReload()
returns bool if cannon needs to be reloadvoid setup()
starts Bluetooth and configures everything in objectvoid loop()
checks for new data, must be in main loop
Used for controlling stepper motors with A4988 drivers
Motor(int stepsPerRevolution, byte stepPin, byte dirPin, int step)
initialzies objectint StepsPerRevolution
how many steps should motor do to make one full rotation for stepper itself or gear attached to itbyte stepPin
goes to a4988 step pinbyte dirPin
goes to a4988 dir pinint step
how many rotations should motor to to make one step (more than 1 if gears are attached to stepper motor)
void setup()
setups motorsvoid loop()
goes to set motor positionsetPosition()
sets new position for motors (0 - 360, received from bluetooth object)
Used for turning on and off relays
Switch(byte switchPin, int delayTime)
byte switchPin
switch pinint delayTime
time in millis for how long should switch be turned on
void setup()
starts objectvoid loop()
runs switchvoid toggle()
turns on switch
For nativescript app NativeScriptUISideDrawerModule, Bluetooth was used
This repository contains code part only, not a whole build
PlatformIO was used to upload and setup the code, put lib and src folders into corresponding places and it should work.
Nativescript and Angular were used to make this app. Put the components and other files into corresponding places.
Install Nativescript Bluetooth plugin and RadSideDrawer plugin!!
To make connection with hardware go to Bluetooth page and wait for connection, if it doesn't work, press connect. After connection go to input and input how many ammunition you put in cannon. After that you can go to main page and control the turret. Hardware doesn't take two equal input, so you can't shoot twice and must reload after every time.