added some comments
This commit is contained in:
parent
c11fc035db
commit
f41386954d
1 changed files with 16 additions and 15 deletions
|
@ -3,26 +3,26 @@
|
||||||
#include <NeoPixelAnimator.h>
|
#include <NeoPixelAnimator.h>
|
||||||
#include <NeoPixelBrightnessBus.h>
|
#include <NeoPixelBrightnessBus.h>
|
||||||
|
|
||||||
|
|
||||||
// DEV or PROD Setup
|
|
||||||
#define DEBUG
|
|
||||||
|
|
||||||
// Only for ESP8266 D1 Mini
|
// Only for ESP8266 D1 Mini
|
||||||
#define ECHO 5 // D1
|
#define ECHO 5 // D1
|
||||||
#define TRIG 16 // D0
|
#define TRIG 16 // D0
|
||||||
#define POTI_IN 17 // A0, analog In
|
#define POTI_IN 17 // A0, analog In
|
||||||
|
|
||||||
|
|
||||||
|
// Set Data pin for LED ring (we use GPIO3, which is also RX of the serial line)
|
||||||
#define DATA_PIN 3
|
#define DATA_PIN 3
|
||||||
const uint16_t PixelCount = 8;
|
const uint16_t PixelCount = 8;
|
||||||
NeoPixelBus<NeoGrbFeature, NeoEsp8266Dma800KbpsMethod> strip(PixelCount, DATA_PIN);
|
NeoPixelBus<NeoGrbFeature, NeoEsp8266Dma800KbpsMethod> strip(PixelCount, DATA_PIN);
|
||||||
|
|
||||||
long duration; // Variable um die Zeit der Ultraschall-Wellen zu speichern
|
long duration; // here we measure the time needed by the ultrasonic pulse
|
||||||
float distance; // Variable um die Entfernung zu berechnen
|
float distance; // the calculated distance
|
||||||
|
|
||||||
int poti;
|
int poti; // used to adjust the distance for yellow/red
|
||||||
int percent=0;
|
int percent=0; // will be used to calculate the current percentage of the distance reached
|
||||||
int colorSaturation=255;
|
|
||||||
|
|
||||||
|
int colorSaturation=255; // max color saturation for the colors (=brightness)
|
||||||
|
|
||||||
|
// define some colors we use later
|
||||||
RgbColor red(colorSaturation, 0, 0);
|
RgbColor red(colorSaturation, 0, 0);
|
||||||
RgbColor green(0, colorSaturation, 0);
|
RgbColor green(0, colorSaturation, 0);
|
||||||
RgbColor yellow(colorSaturation, colorSaturation, 0);
|
RgbColor yellow(colorSaturation, colorSaturation, 0);
|
||||||
|
@ -32,12 +32,13 @@ RgbColor black(0);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
|
// Setup the ultrasonic sensor PIN
|
||||||
pinMode(TRIG, OUTPUT); // TRIG-Pin: Output
|
pinMode(TRIG, OUTPUT); // TRIG-Pin: Output
|
||||||
pinMode(ECHO, INPUT); // ECHO-Pin: Input
|
pinMode(ECHO, INPUT); // ECHO-Pin: Input
|
||||||
|
|
||||||
#ifdef DEBUG
|
// Important to first initilizate Serial before the strip as
|
||||||
|
// we are useing the RX PIN to connect the strip
|
||||||
Serial.begin(9600); // Baudrate: 115200
|
Serial.begin(9600); // Baudrate: 115200
|
||||||
#endif
|
|
||||||
|
|
||||||
// this resets all the neopixels to an off state
|
// this resets all the neopixels to an off state
|
||||||
strip.Begin();
|
strip.Begin();
|
||||||
|
|
Loading…
Reference in a new issue