/*****************************************************/
/**************** ESC-Light **************************/
/*****************************************************/
/* Type of Board Layout */
#define TGY //
//#define BS //
//#define TGY //
//#define RB50A //
//#define RB70A //
/******************************************************/
/* Selection of switched FET */
/* default is common anode (low-side-FET used) */
/* to use other direction, uncomment related line */
#define CH1_GND
#define CH2_GND
#define CH3_GND
/******************************************************/
/*****************************************************/
//
// *** TP ***
//
/*****************************************************/
// insert tested ESC here
//
// HK RedBrick 20A [url]http://www.hobbyking.com/hobbyking/store/__25112__HobbyKing_Red_Brick_20A_ESC.html[/url] // tested by Overtuner 11-2013
// Robbe Roxxy BLControl 720 // tested by Overtuner 11-2013
// HK SS Series 25-30A ESC [url]http://www.hobbyking.com/hobbyking/store/__6460__Hobbyking_SS_Series_25_30A_ESC.html[/url] // tested by Overtuner 11-2013
/*****************************************************/
#ifdef TP
//define input pin for the RC Channel#
#define IN1 8
//Define the Pins at which channel 1, 2 and 3 are placed
#define OUT1_VCC 2 //Ap
#define OUT2_VCC 10 //Bp
#define OUT3_VCC 9 //Cp
#define OUT1_GND 3 //An
#define OUT2_GND 4 //Bn
#define OUT3_GND 5 //Cn
#endif
/*****************************************************/
//
// *** BS ***
//
/*****************************************************/
// insert tested ESC here
//
// Turnigy TY-P1 [url]http://www.hobbyking.com/hobbyking/store/__17135__Turnigy_TY_P1_25Amp_HEXFET_Brushless_Speed_Controller.html[/url] // tested by Overtuner 11-2013
//
/*****************************************************/
#ifdef BS
//define input pin for the RC Channel#
#define IN1 2
//Define the Pins at which channel 1,2 and 3 are placed
#define OUT1_VCC 4 //Ap
#define OUT2_VCC A5 //Bp
#define OUT3_VCC A3 //Cp
#define OUT1_GND 5 //An
#define OUT2_GND A4 //Bn
#define OUT3_GND 8 //Cn
#endif
/*****************************************************/
/*
*** TGY ***
*/
/*****************************************************/
#ifdef TGY
//define input pin for the RC Channel#
#define IN1 8
//Define the Pins at which channel 1,2 and 3 are placed
#define OUT1_VCC 2 //Ap
#define OUT2_VCC 10 //Bp
#define OUT3_VCC 9 //Cp
#define OUT1_GND 3 //An
#define OUT2_GND 4 //Bn
#define OUT3_GND 5 //Cn
#endif
/*****************************************************/
/*
*** RB50A ***
*/
/*****************************************************/
#ifdef RB50A
//define input pin for the RC Channel#
#define IN1 2
//Define the Pins at which channel 1,2 and 3 are placed
#define OUT1_VCC 0 //Ap
#define OUT2_VCC 4 //Bp
#define OUT3_VCC 5 //Cp
#define OUT1_GND 1 //An
#define OUT2_GND 3 //Bn
#define OUT3_GND 7 //Cn
#endif
/*****************************************************/
/*
*** RB70A ***
*/
/*****************************************************/
#ifdef RB70A
//define input pin for the RC Channel#
#define IN1 2
//Define the Pins at which channel 1,2 and 3 are placed
#define OUT1_VCC 1 //Ap
#define OUT2_VCC 4 //Bp
#define OUT3_VCC 5 //Cp
#define OUT1_GND 0 //An
#define OUT2_GND 3 //Bn
#define OUT3_GND 7 //Cn
#endif
/*****************************************************************************************************************/
// select FET to switch - NEVER EVER CHANGE THIS, except you want to blow up your FET's or have some funny fire ;-)
/*****************************************************************************************************************/
#ifdef CH1_GND
#define OUT1 OUT1_GND
#else
#define OUT1 OUT1_VCC
#endif
#ifdef CH2_GND
#define OUT2 OUT2_GND
#else
#define OUT2 OUT2_VCC
#endif
#ifdef CH3_GND
#define OUT3 OUT3_GND
#else
#define OUT3 OUT3_VCC
#endif
/*****************************************************************************************************************/
/************************************************** ***************************
*
* Copyright (c) 2013 Peter Blos
*
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
************************************************** ***************************
* Version 1.0
*
* ESC Light
* Uses an Brushless ESC as light switch. For compatible ESCs see config.h.
* switches the different lights on dependent to the RC-Channel Position.
*
* Thanks to:
* der Frickler for having the Idea and writing the Basic Code in AVR-GCC
* Overtuner for testing working ESCs and writing most of the config.h
*
*
*
************************************************** ***************************/
#include "config.h"
// Definitions of Switching Stick Positions
#define STICK_LOW 1000 //define the maximum Time in microseconds of the RC-Pulse,
#define STICK_CENTER 1500 //to be recocnised as LOW or Center,
#define STICK_HIGH 2000 //everything above is considered HIGH
#define STICK_OVERFLOW 4000
// Definition of Blinking Delays
#define STROBE_DIST 500 //timing for the Blink patterns
#define STROBE_TIME 20
#define STROBE_REPEAT 300
#define ACL_DIST 600
#define ACL_TIME 20
int STICKPOS;
void setup() {
// define Pins as in/out - DO NOT CHANGE
pinMode(IN1, 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(IN1,HIGH);
// SWITCH OUT1/OUT2/OUT3 as you want your blinking sequences.
if(STICKPOS < STICK_LOW){ //RC-Channel is in HIGH Position and default pattern when signal loss
digitalWrite(OUT1 , LOW);
digitalWrite(OUT2 , LOW);
digitalWrite(OUT3 , LOW);
}
else {
if(STICKPOS < STICK_CENTER){ //RC-Channel is in Mid Position
digitalWrite(OUT3 , LOW);
digitalWrite(OUT1 , HIGH);
delay(STROBE_TIME);
digitalWrite(OUT1 , LOW);
delay(STROBE_REPEAT);
digitalWrite(OUT1 , HIGH);
delay(STROBE_TIME);
digitalWrite(OUT1 , LOW);
delay(ACL_DIST);
digitalWrite(OUT2 , HIGH);
delay(ACL_TIME);
digitalWrite(OUT2 , LOW);
delay(ACL_DIST);
}
else{ //RC-Channel is in High Position
digitalWrite(OUT3 , HIGH);
digitalWrite(OUT1 , HIGH);
delay(STROBE_TIME);
digitalWrite(OUT1 , LOW);
delay(STROBE_REPEAT);
digitalWrite(OUT1 , HIGH);
delay(STROBE_TIME);
digitalWrite(OUT1 , LOW);
delay(ACL_DIST);
digitalWrite(OUT2 , HIGH);
delay(ACL_TIME);
digitalWrite(OUT2 , LOW);
delay(ACL_DIST);
}
};