~(o.o)~ ..for someone else ..and at last minute (≖_≖ )
For one touch activation, it required bridging button circuits in sequence on the native controller and grounding one of the toggles required for RF connection: 1. power up --> 4.5V bridge with 2N2222 transistor 2. up (connect) --> 3.3V bridge w/ 2N2222 3. down (connect) --> mechanical relay (5V) to gnd toggle 4. lower button (level) --> 3.3V bridge w/ 2N2222 5. upper button (launch) --> 3.3V bridge w/ 2N2222 6. upper button (land)

Excuse the sloppy infrastructure.. there were technically no do-overs allotted whilst doing-over several times. The real success was having powered an Arduino Nano, a 5V relay, laser, bright white LED, 40+ Neopixels (running an aggressive flashing script) and the drone controller with a mere (3) AA batteries (4.5V).

#include <Servo.h> #include "FastLED.h"
Servo doors; int closed = 5; int openned = 40;
#define NUM_LEDS 60 CRGB leds[NUM_LEDS]; #define PIN 4
const int up = 3; // relay const int launch = 6; const int button = 7; const int level = 8; const int down = 10; const int power = 12;
int buttonstate; int flystate = 0;
void setup() { FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
doors.attach(11); doors.write(closed);
pinMode(up, OUTPUT); pinMode(launch, OUTPUT); pinMode(button, INPUT); pinMode(level, OUTPUT); pinMode(down, OUTPUT); pinMode(power, OUTPUT);
digitalWrite(up, LOW); digitalWrite(launch, LOW); digitalWrite(level, LOW); digitalWrite(down, LOW); digitalWrite(power, LOW);
delay(500); }
void loop() { buttonstate = digitalRead(button); if (buttonstate == HIGH) { if (flystate == 0) { launchit(); } else if (flystate == 1) { land(); } else { // error } } else { Sparkle(0x00, 0x00, 0xff, 0); } }
void launchit() { doors.write(openned); delay(1000); doors.write(closed); digitalWrite(power, HIGH); delay(300); digitalWrite(power, LOW); delay(300); digitalWrite(up, HIGH); delay(750); digitalWrite(up, LOW); delay(300); digitalWrite(down, HIGH); delay(300); digitalWrite(down, LOW); delay(300); digitalWrite(launch, HIGH); delay(300); digitalWrite(launch, LOW); flystate = 1; }
void land () { digitalWrite(launch, HIGH); delay(300); digitalWrite(launch, LOW); delay(300); digitalWrite(power, HIGH); delay(1500); digitalWrite(power, LOW); flystate = 0; }
void Sparkle(byte red, byte green, byte blue, int SpeedDelay) { int Pixel = random(NUM_LEDS); setPixel(Pixel, red, green, blue); showStrip(); delay(SpeedDelay); setPixel(Pixel, 0, 0, 0); }
void showStrip() { #ifdef ADAFRUIT_NEOPIXEL_H // NeoPixel strip.show(); #endif #ifndef ADAFRUIT_NEOPIXEL_H // FastLED FastLED.show(); #endif }
void setPixel(int Pixel, byte red, byte green, byte blue) { #ifdef ADAFRUIT_NEOPIXEL_H // NeoPixel strip.setPixelColor(Pixel, strip.Color(red, green, blue)); #endif #ifndef ADAFRUIT_NEOPIXEL_H // FastLED leds[Pixel].r = red; leds[Pixel].g = green; leds[Pixel].b = blue; #endif }
void setAll(byte red, byte green, byte blue) { for (int i = 0; i < NUM_LEDS; i++ ) { setPixel(i, red, green, blue); } showStrip(); }
16:46:53 228 021
|
| |
|
@pkvi
"...may not meet professional standards."
|
|
|