just as the subject states I kind of need help
the device is for a rocket launch base panel for my kid brother "don't worry I practice safety hence this forum plus I plan on using led's before launching rockets"anyway as I was checking the code I hit a snag you see this code is for a wireless launcher which is cool
but I want it to be a "wired base" mainly because I cannot afford the X-bee set used for this project
so here's what I wanted to do using pushbuttons that can be used to control these functions
for example I have a cover switch which can be the launcher button and perhaps remove the armed command because of this and as for the servos have seprate buttons to set the pad in place or simply go 180 when pressed once and go to zero when pressed again
I would attempt this my self but 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
#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);
}