#include <FastLED.h>
// --- REMOVED FOR WIRED COMMUNICATION ---
// #include <SPI.h>
// #include <RF24.h>
// #define NRF_CE_PIN 7
// #define NRF_CSN_PIN 8
// RF24 radio(NRF_CE_PIN, NRF_CSN_PIN);
// const byte address[6] = "00001";
// --- END OF REMOVED CODE ---
// --- Button Pins ---
const int stack_btn = A2;
const int launch_btn = 3;
const int down_btn = A1;
const int up_btn = A0;
const int openClose_btn = A3;
const int sideToSide_btn = A4;
const int shipQD_btn = A5;
const int arm_btn = A6;
int counter = 5;
// --- FastLED Configuration ---
#define LED_PIN 9
#define NUM_LEDS 10
#define BRIGHTNESS 100
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
void setup() {
// We will use the main hardware Serial for communication
Serial.begin(9600);
while (!Serial && millis() < 5000);
Serial.println("Wired Transmitter Starting...");
// --- REMOVED NRF24 INITIALIZATION ---
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
pinMode(stack_btn, INPUT_PULLUP);
pinMode(launch_btn, INPUT_PULLUP);
pinMode(down_btn, INPUT_PULLUP);
pinMode(up_btn, INPUT_PULLUP);
pinMode(openClose_btn, INPUT_PULLUP);
pinMode(sideToSide_btn, INPUT_PULLUP);
pinMode(shipQD_btn, INPUT_PULLUP);
pinMode(arm_btn, INPUT_PULLUP);
Serial.println("Setup complete. Ready to transmit.");
}
void loop() {
if (digitalRead(arm_btn) == LOW) {
fill_solid(leds, NUM_LEDS, CRGB::Green);
FastLED.setBrightness(100);
} else {
fill_solid(leds, NUM_LEDS, CRGB::Black);
}
FastLED.show();
// Check buttons and send messages
if (digitalRead(stack_btn) == LOW) {
sendMessage("stack");
delay(200);
}
if (digitalRead(launch_btn) == LOW) {
if (digitalRead(arm_btn) == LOW) {
fill_solid(leds, NUM_LEDS, CRGB::Green);
FastLED.setBrightness(255);
FastLED.show();
sendMessage("launch");
FastLED.setBrightness(BRIGHTNESS);
fill_solid(leds, NUM_LEDS, CRGB::Green);
FastLED.show();
} else {
Serial.println("Launch attempted but NOT ARMED!");
fill_solid(leds, NUM_LEDS, CRGB::Red);
FastLED.setBrightness(100);
FastLED.show();
delay(1000);
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
}
delay(200);
}
if (digitalRead(down_btn) == LOW) {
sendMessage("down");
delay(200);
}
if (digitalRead(up_btn) == LOW) {
sendMessage("up");
delay(200);
}
if (digitalRead(openClose_btn) == LOW) {
sendMessage("openClose");
delay(200);
}
if (digitalRead(sideToSide_btn) == LOW) {
sendMessage("sideToSide");
delay(200);
}
if (digitalRead(shipQD_btn) == LOW) {
sendMessage("shipQD");
delay(200);
}
}
// --- MODIFIED sendMessage FUNCTION ---
void sendMessage(const char *message) {
//Serial.print("Sending: ");
Serial.println(message); // Use Serial.println to send the message string with a newline
}