/*
ESC-Light
*/
#include "esc_pin.h"
// Definitions of Switching Stick Positions
#define STICK_LOW 1100
#define STICK_CENTER_LOW 1400
#define STICK_CENTER 1600
#define STICK_CENTER_HIGH 1800
#define STICK_HIGH 2000
#define STICK_OVERFLOW 4000
#define DELAY_1 170
#define DELAY_2 100
#define DELAY_3 130
int STICKPOS;
void setup() {
// define Pins as in/out - DO NOT CHANGE
pinMode(IN, INPUT);
pinMode(OUT1_VCC, OUTPUT);
pinMode(OUT2_VCC, OUTPUT);
pinMode(OUT3_VCC, OUTPUT);
pinMode(OUT1_GND, OUTPUT);
pinMode(OUT2_GND, OUTPUT);
pinMode(OUT3_GND, OUTPUT);
// init outpins all off - DO NOT CHANGE
digitalWrite(OUT1_VCC , LOW);
digitalWrite(OUT2_VCC , LOW);
digitalWrite(OUT3_VCC , LOW);
digitalWrite(OUT1_GND , LOW);
digitalWrite(OUT2_GND , LOW);
digitalWrite(OUT3_GND , LOW);
}
void loop() {
// READ RC PULSE
STICKPOS = pulseIn(IN,HIGH);
// SWITCH OUT1_VCC/OUT2_VCC/OUT3_VCC as you want your blinking sequences.
// For LEDS with common Anode connected to VCC switch OUT1_GND/OUT2_GND/OUT3_GND
// NEVER!!!! set OUT1_VCC and OUT1_GND to HIGH at the same time, it will shortcut
// your Battery and your ESC will light up in flames!
if(STICKPOS < STICK_LOW){
digitalWrite(OUT1_VCC , HIGH);
digitalWrite(OUT2_VCC , HIGH);
digitalWrite(OUT3_VCC , HIGH);
} else { if(STICKPOS < STICK_CENTER_LOW){
digitalWrite(OUT1_VCC , HIGH);
digitalWrite(OUT2_VCC , HIGH);
digitalWrite(OUT3_VCC , LOW);
delay(40);
digitalWrite(OUT3_VCC , HIGH);
delay(80);
digitalWrite(OUT3_VCC , LOW);
delay(40);
digitalWrite(OUT3_VCC , HIGH);
delay(1840);
} else { if(STICKPOS < STICK_CENTER){
digitalWrite(OUT1_VCC , LOW);
digitalWrite(OUT2_VCC , LOW);
digitalWrite(OUT3_VCC , LOW);
delay(40);
digitalWrite(OUT3_VCC , HIGH);
delay(80);
digitalWrite(OUT3_VCC , LOW);
delay(40);
digitalWrite(OUT3_VCC , HIGH);
delay(300);
digitalWrite(OUT3_VCC , LOW);
delay(40);
digitalWrite(OUT3_VCC , HIGH);
delay(80);
digitalWrite(OUT3_VCC , LOW);
delay(40);
digitalWrite(OUT3_VCC , HIGH);
delay(2380);
} else { if(STICKPOS < STICK_CENTER_HIGH){
digitalWrite(OUT1_VCC , HIGH);
digitalWrite(OUT2_VCC , HIGH);
digitalWrite(OUT3_VCC , LOW);
delay(DELAY_2);
digitalWrite(OUT3_VCC , HIGH);
delay(DELAY_3);
digitalWrite(OUT3_VCC , LOW);
delay(DELAY_2);
digitalWrite(OUT3_VCC , HIGH);
delay(DELAY_1);
digitalWrite(OUT1_VCC , LOW);
delay(DELAY_2);
digitalWrite(OUT1_VCC , HIGH);
delay(DELAY_3);
digitalWrite(OUT1_VCC , LOW);
delay(DELAY_2);
digitalWrite(OUT1_VCC , HIGH);
delay(DELAY_1);
digitalWrite(OUT3_VCC , LOW);
delay(DELAY_2);
digitalWrite(OUT3_VCC , HIGH);
delay(DELAY_3);
digitalWrite(OUT3_VCC , LOW);
delay(DELAY_2);
digitalWrite(OUT3_VCC , HIGH);
delay(DELAY_1);
digitalWrite(OUT2_VCC , LOW);
delay(500);
} else {
digitalWrite(OUT1_VCC , LOW);
digitalWrite(OUT2_VCC , LOW);
digitalWrite(OUT3_VCC , HIGH);
delay(340);
digitalWrite(OUT1_VCC , HIGH);
digitalWrite(OUT2_VCC , HIGH);
digitalWrite(OUT3_VCC , LOW);
delay(40);
digitalWrite(OUT2_VCC , LOW);
digitalWrite(OUT3_VCC , HIGH);
delay(140);
digitalWrite(OUT2_VCC , HIGH);
digitalWrite(OUT3_VCC , LOW);
delay(40);
digitalWrite(OUT2_VCC , LOW);
digitalWrite(OUT3_VCC , HIGH);
delay(340);
}}}};
}