I kind of need help
the device is for a rocket launch base panel for my kid brother
I would attempt this myself but I'm not that great using the arduino plus a personal matter has came up and I would like to finish this project by the time he returns from the hospital any and all help is welcomed.
The hardware is an arduino uno and assorted push buttons.
What I'm attempting with this project is to be operated by push buttons, because I cannot afford the X-bee wireless system. What I mean by operation by push buttons is this:
When I press the launch button I can launch a rocket, repeated presses launches remaining rockets four in total.
The code also has commands for operating servos (two) which I want to operate each with a push button as well.
How so, when I press the servo button the servo rotates 180 Degrees, when pressed again the servo returns to 0 degrees.
#include <Servo.h>
Servo pan, tilt;
byte data[4];
byte armed=0, pitch=0, rotation=0;
unsigned long cache;
void setup()
{
pan.attach(6); //servos here
tilt.attach(7);
Serial.begin(9600);
pinMode(8, OUTPUT); //output leds
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
rotation = 90;
}
void loop() {
if(cache=Serial.available() > 0){
data[3] = data[2]; data[2] = data[1]; data[1] = data[0]; data[0] = Serial.read();
if(data[3] == '<' && (data[1] == data[0]) ){
switch(data[2]){
case 'f': armed = data[1]; break;
case 'p': pitch = data[1]; break;
case 'r': rotation = data[1]; break;
}
}
if(cache > 100){
Serial.flush();
data[0] = 0; data[1] = 0; data[2] = 0; data[3] = 0;
}
}
tilt.write(pitch);
pan.write(rotation);
if(armed & 0x01) digitalWrite(8, HIGH);
else digitalWrite(8, LOW);
if(armed & 0x02) digitalWrite(9, HIGH);
else digitalWrite(9, LOW);
if(armed & 0x04) digitalWrite(10, HIGH);
else digitalWrite(10, LOW);
if(armed & 0x08) digitalWrite(11, HIGH);
else digitalWrite(11, LOW);
}