Skip to content

Instantly share code, notes, and snippets.

@Doviebear Doviebear/ nerfturret.ino Secret
Created Aug 3, 2017

Embed
What would you like to do?
int pwmFire = A5;
int shutdown = A1;
int fireMotorP = D0;
int fireMotorN = D1;
int pwmAccel = A2;
int accelMotorP = D2;
int accelMotorN = D3;
//for flywheels, P LOW, N HIGH
//for fire motor, P HIGH, N LOW
void setup() {
pinMode(pwmFire,OUTPUT);
pinMode(shutdown,OUTPUT);
pinMode(fireMotorP,OUTPUT);
pinMode(fireMotorN,OUTPUT);
pinMode(accelMotorP,OUTPUT);
pinMode(accelMotorN,OUTPUT);
pinMode(pwmAccel,OUTPUT);
Particle.function("fire",fireAmount);
digitalWrite(shutdown,HIGH);
digitalWrite(pwmFire,LOW);
digitalWrite(pwmAccel,LOW);
digitalWrite(accelMotorP,LOW);
digitalWrite(accelMotorN,HIGH);
digitalWrite(fireMotorP,LOW);
digitalWrite(fireMotorN,HIGH);
}
void loop() {
}
int fireAmount (String command){
if(command == "fireOne"){
digitalWrite(pwmAccel,HIGH);
delay(1000);
digitalWrite(pwmFire,HIGH);
delay(500);
digitalWrite(pwmAccel,LOW);
digitalWrite(pwmFire,LOW);
}
else if(command == "fireThree"){
digitalWrite(pwmAccel,HIGH);
delay(1000);
digitalWrite(pwmFire,HIGH);
delay(1500);
digitalWrite(pwmFire,LOW);
digitalWrite(pwmAccel,LOW);
}
else if(command == "fireTwentyFive"){
digitalWrite(pwmAccel,HIGH);
delay(1000);
digitalWrite(pwmFire,HIGH);
delay(14000);
digitalWrite(pwmFire,LOW);
digitalWrite(pwmAccel,LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.