-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"board": "espressif:esp32:nina_w10", | ||
"configuration": "UploadSpeed=115200", | ||
"port": "/dev/ttyUSB0", | ||
"sketch": "LED-Siren.ino" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "Linux", | ||
"includePath": [ | ||
"/home/rac/Arduino/hardware/espressif/esp32/cores/esp32" | ||
], | ||
"browse": { | ||
"limitSymbolsToIncludedHeaders": false, | ||
"path": [ | ||
"/home/rac/Arduino/hardware/espressif/esp32/cores/esp32" | ||
] | ||
}, | ||
"intelliSenseMode": "clang-x64", | ||
"compilerPath": "/usr/bin/gcc", | ||
"cStandard": "c11", | ||
"cppStandard": "c++17" | ||
} | ||
], | ||
"version": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* LED siren example for MakeZurich badge 2018 | ||
*/ | ||
|
||
#include "FastLED.h" | ||
|
||
#define NUM_LEDS 2 | ||
#define DATA_PIN 27 // GPIO18 | ||
|
||
// Delays used inside siren algorithm | ||
#define SHORT_DELAY 200 | ||
#define LONG_DELAY 1000 | ||
|
||
// Define the array of leds | ||
CRGB leds[NUM_LEDS]; | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
Serial.println("\n\nSiren example"); | ||
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS); | ||
} | ||
|
||
void loop() { | ||
siren(); | ||
ledOff(); | ||
delay(1000); | ||
} | ||
|
||
void siren() { | ||
// This will flash the leds 10 times from red to blue slowly (each on its side and the other off) | ||
for(int i = 0; i <= 10; i++) { | ||
showRedBlack(LONG_DELAY); | ||
showBlackBlue(LONG_DELAY); | ||
} | ||
|
||
// This will flash each side multiple times fast but switch between the two with the same pace | ||
for(int i = 0; i <= 10; i++) { | ||
for(int j = 0; j <= 5; j++) { | ||
showRedBlack(SHORT_DELAY); | ||
} | ||
for(int j = 0; j <= 5; j++) { | ||
showBlackBlue(SHORT_DELAY); | ||
} | ||
} | ||
|
||
// This will flash quickly between both LEDs | ||
for(int i = 0; i <= 30; i++) { | ||
showRedBlack(SHORT_DELAY); | ||
showBlackBlue(SHORT_DELAY); | ||
} | ||
|
||
} | ||
|
||
void ledOff() { | ||
leds[0] = CRGB::Black; | ||
leds[1] = CRGB::Black; | ||
FastLED.show(); | ||
} | ||
|
||
|
||
void showRedBlack(int delayTime) { | ||
leds[0] = CRGB::Red; | ||
leds[1] = CRGB::Black; | ||
FastLED.show(); | ||
delay(delayTime); | ||
} | ||
|
||
void showBlackBlue(int delayTime) { | ||
leds[0] = CRGB::Blue; | ||
leds[1] = CRGB::Black; | ||
FastLED.show(); | ||
delay(delayTime); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# LED Siren example | ||
|
||
Just flashes different patterns that mimik a US police siren with red and blue on the MakeZurich badge 2018 |