Skip to content

Instantly share code, notes, and snippets.

@diegocardoso93
Created October 17, 2019 01:15
Show Gist options
  • Save diegocardoso93/7fa532118c1f6d10488a71e70682593b to your computer and use it in GitHub Desktop.
Save diegocardoso93/7fa532118c1f6d10488a71e70682593b to your computer and use it in GitHub Desktop.
// ---------------------------------
// LDL - LED DESCRIPTION LANGUAGE
// Arduino Lisp-like LED Animations :D
// Diego Cardoso 2017.1
// ---------------------------------
// LED_BLINK {@PARAMS: function?, time_on, time_off, duration}
// LED_ON {@PARAMS: function?, duration, intensity}
// LED_OFF {@PARAMS: function?, int duration}
// LED_COLOR_TRANSITION {@PARAMS: function?, String color_init, String color_end, int duration}
// ---------------------------------
// @TODO: Work with RGB LEDs
// ---------------------------------
#define LED_PIN 13
#define DEBUG true
#define serialDebug(STR) \
if (DEBUG) Serial.println(STR);
bool LED_EXEC(...){
serialDebug(" -- INIT OR FINISH -- ");
return true;
}
bool LED_BLINK(int, int time_on, int time_off, int duration) {
serialDebug("HELLO FROM LED BLINK");
unsigned long init_time = millis();
while (millis() < init_time + duration){
digitalWrite(LED_PIN, HIGH);
delay(time_on);
digitalWrite(LED_PIN, LOW);
delay(time_off);
}
return true;
}
bool LED_ON(int, int duration, int intensity) {
serialDebug("HELLO FROM LED ON");
digitalWrite(LED_PIN, HIGH);
delay(duration);
return true;
}
bool LED_OFF(int, int duration) {
serialDebug("FROM LED OFF");
digitalWrite(LED_PIN, LOW);
delay(duration);
return true;
}
bool LED_COLOR_TRANSITION(int, String color_init, String color_end, int duration) {
return true;
}
void setup() {
Serial.begin(9600);
while(!Serial);
}
void loop() {
LED_EXEC(
LED_BLINK(
LED_OFF(
LED_ON(
LED_BLINK(
LED_EXEC()
,800,200,5000)
,5000,100)
,5000)
,200,800,5000)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment