Wstepnie działająca wersja - z problemem resetu przy sterowaniu wentylatorem
This commit is contained in:
@@ -5,8 +5,8 @@
|
|||||||
#include "DHT.h"
|
#include "DHT.h"
|
||||||
#include <Adafruit_NeoPixel.h>
|
#include <Adafruit_NeoPixel.h>
|
||||||
#include <BH1750.h>
|
#include <BH1750.h>
|
||||||
|
// #include <analogWrite.h>
|
||||||
#define Version "0.2.2"
|
#define Version "0.3.0"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -34,35 +34,30 @@ const uint8_t ledMap[LED_COUNT] = {3, 0, 1, 8, 2, 5, 4, 7, 6};
|
|||||||
#define BTN_RST 35 //GPIO35 D35
|
#define BTN_RST 35 //GPIO35 D35
|
||||||
#define BTN_HYGRSTT 36 //GPIO36 VP
|
#define BTN_HYGRSTT 36 //GPIO36 VP
|
||||||
#define BTN_SPEED 39 //GPIO35 VN
|
#define BTN_SPEED 39 //GPIO35 VN
|
||||||
|
|
||||||
#define PIN_SPEED_1 32 //GPIO32 D32
|
#define PIN_SPEED_1 32 //GPIO32 D32
|
||||||
#define PIN_SPEED_2 14 //GPIO36 D14
|
#define PIN_SPEED_2 14 //GPIO36 D14
|
||||||
|
|
||||||
#define DHTPIN 4 //GPIO04 D4
|
#define DHTPIN 4 //GPIO04 D4
|
||||||
|
#define LED_WHT_TANK 25 //GPIO26 D26
|
||||||
#define LED_WHT_TANK 26 //GPIO26 D26
|
#define LED_RED_TANK 26 //GPIO25 D25
|
||||||
#define LED_RED_TANK 25 //GPIO25 D25
|
|
||||||
|
|
||||||
#define NEOPIXEL 27 //GPIO04 D27
|
#define NEOPIXEL 27 //GPIO04 D27
|
||||||
|
|
||||||
#define IN_PHOTOTRA 12
|
#define IN_PHOTOTRA 12
|
||||||
|
|
||||||
#define WTR_LVL 33 //GPIO04 D27
|
#define WTR_LVL 33 //GPIO04 D27
|
||||||
|
|
||||||
|
#define DIMM_MAX_VALUE 4
|
||||||
|
|
||||||
//NEO PIXEL ARDESES:
|
//NEO PIXEL ARDESES:
|
||||||
#define NEOPXL_MULTIPLIER 25
|
#define NEOPXL_MULTIPLIER 25
|
||||||
// ARDESES:
|
// ARDESES:
|
||||||
#define ADR_NEOPXL_SPEED_2 0
|
|
||||||
#define ADR_NEOPXL_SPEED_1 1
|
#define ADR_NEOPXL_SPEED_1 1
|
||||||
#define ADR_NEOPXL_FILTER 2
|
#define ADR_NEOPXL_SPEED_2 0
|
||||||
#define ADR_NEOPXL_L1 3
|
#define ADR_NEOPXL_FILTER 3
|
||||||
#define ADR_NEOPXL_L2 4
|
#define ADR_NEOPXL_L1 2
|
||||||
#define ADR_NEOPXL_L3 5
|
#define ADR_NEOPXL_L2 5
|
||||||
#define ADR_NEOPXL_L4 6
|
#define ADR_NEOPXL_L3 4
|
||||||
#define ADR_NEOPXL_L5 7
|
#define ADR_NEOPXL_L4 7
|
||||||
|
#define ADR_NEOPXL_L5 6
|
||||||
#define ADR_NEOPXL_WATERLVL 8
|
#define ADR_NEOPXL_WATERLVL 8
|
||||||
#define ADR_NEOPXL_TANK 9
|
#define ADR_NEOPXL_TANK
|
||||||
|
|
||||||
|
|
||||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||||
@@ -74,20 +69,21 @@ BH1750 lightMeter;
|
|||||||
|
|
||||||
//MAIN VALUES VARIABLES
|
//MAIN VALUES VARIABLES
|
||||||
int8_t resetVal = 0;
|
int8_t resetVal = 0;
|
||||||
int8_t fanSpeedVal = 0;
|
int8_t fanSpeedVal = 1;
|
||||||
int8_t hygrostatVal = 55;
|
int8_t hygrostatVal = 55;
|
||||||
int8_t dimmVal = 10;
|
int8_t dimmStep = 1;
|
||||||
|
int8_t dimmVal = 1;
|
||||||
int8_t waterLvlVal = 0;
|
int8_t waterLvlVal = 0;
|
||||||
|
int8_t photoVal = 0;
|
||||||
float temp = 0.0;
|
float temp = 0.0;
|
||||||
float hum = 0.0;
|
float hum = 0.0;
|
||||||
|
float lux = 0.0;
|
||||||
|
|
||||||
//NEOPIXELS VARIABLES
|
//NEOPIXELS VARIABLES
|
||||||
int8_t neoPixelSwitch = 1;
|
int8_t neoPixelSwitch = 1;
|
||||||
int8_t neoPixelRed = 5;
|
int8_t neoPixelRed = 10;
|
||||||
int8_t neoPixelGreen = 5;
|
int8_t neoPixelGreen = 10;
|
||||||
int8_t neoPixelBlue = 5;
|
int8_t neoPixelBlue = 10;
|
||||||
|
|
||||||
int8_t neoPixelSpeed_1 = 1;
|
int8_t neoPixelSpeed_1 = 1;
|
||||||
int8_t neoPixelSpeed_2 = 1;
|
int8_t neoPixelSpeed_2 = 1;
|
||||||
@@ -97,35 +93,45 @@ int8_t neoPixelLvl_2 = 1;
|
|||||||
int8_t neoPixelLvl_3 = 1;
|
int8_t neoPixelLvl_3 = 1;
|
||||||
int8_t neoPixelLvl_4 = 1;
|
int8_t neoPixelLvl_4 = 1;
|
||||||
int8_t neoPixelLvl_5 = 1;
|
int8_t neoPixelLvl_5 = 1;
|
||||||
int8_t neoPixelWaterLvl = 1;
|
int8_t neoPixelWaterLvlR = 1;
|
||||||
|
int8_t neoPixelWaterLvlG = 1;
|
||||||
int8_t neoPixelTank = 1;
|
int8_t neoPixelTank = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void IRAM_ATTR dimmButtonFcn() {
|
void IRAM_ATTR dimmButtonFcn() {
|
||||||
dimmVal ++;
|
dimmStep ++;
|
||||||
if (dimmVal >= 11) {
|
if (dimmStep > DIMM_MAX_VALUE) {
|
||||||
dimmVal = 1;
|
dimmStep = 0;
|
||||||
}
|
}
|
||||||
digitalWrite(LED_WHT_TANK, HIGH);
|
|
||||||
}
|
}
|
||||||
void IRAM_ATTR speedButtonFcn() {
|
void IRAM_ATTR speedButtonFcn() {
|
||||||
fanSpeedVal ++;
|
fanSpeedVal ++;
|
||||||
if (fanSpeedVal >= 3) {
|
if (fanSpeedVal >= 3) {
|
||||||
fanSpeedVal = 0;
|
fanSpeedVal = 1;
|
||||||
}
|
}
|
||||||
digitalWrite(LED_RED_TANK, HIGH);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void IRAM_ATTR hygrostatButtonFcn() {
|
void IRAM_ATTR hygrostatButtonFcn() {
|
||||||
hygrostatVal = hygrostatVal + 10;
|
hygrostatVal = hygrostatVal + 5;
|
||||||
if (hygrostatVal >= 75) {
|
if (hygrostatVal > 65) {
|
||||||
hygrostatVal = 35;
|
hygrostatVal = 45;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setFanSpeed (uint8_t spdInpt){
|
||||||
|
if (spdInpt == 1) {
|
||||||
|
digitalWrite(PIN_SPEED_2, LOW);
|
||||||
|
digitalWrite(PIN_SPEED_1, HIGH);
|
||||||
|
} else if (spdInpt == 2) {
|
||||||
|
digitalWrite(PIN_SPEED_1, LOW);
|
||||||
|
digitalWrite(PIN_SPEED_2, HIGH);
|
||||||
|
} else {
|
||||||
|
digitalWrite(PIN_SPEED_1, LOW);
|
||||||
|
digitalWrite(PIN_SPEED_2, LOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void rainbowCycle(uint8_t wait) {
|
void rainbowCycle(uint8_t wait) {
|
||||||
uint16_t i, j;
|
uint16_t i, j;
|
||||||
@@ -141,7 +147,6 @@ void rainbowCycle(uint8_t wait) {
|
|||||||
uint32_t Wheel(byte pos) {
|
uint32_t Wheel(byte pos) {
|
||||||
pos = 255 - pos;
|
pos = 255 - pos;
|
||||||
uint8_t r, g, b;
|
uint8_t r, g, b;
|
||||||
|
|
||||||
if (pos < 85) {
|
if (pos < 85) {
|
||||||
r = 255 - pos * 3;
|
r = 255 - pos * 3;
|
||||||
g = 0;
|
g = 0;
|
||||||
@@ -157,12 +162,9 @@ uint32_t Wheel(byte pos) {
|
|||||||
g = 255 - pos * 3;
|
g = 255 - pos * 3;
|
||||||
b = 0;
|
b = 0;
|
||||||
}
|
}
|
||||||
|
r = r * 30 / 100; // Ogranicz jasność do 30%
|
||||||
// Ogranicz jasność do 30%
|
|
||||||
r = r * 30 / 100;
|
|
||||||
g = g * 30 / 100;
|
g = g * 30 / 100;
|
||||||
b = b * 30 / 100;
|
b = b * 30 / 100;
|
||||||
|
|
||||||
return pixels.Color(r, g, b);
|
return pixels.Color(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,8 +195,6 @@ void setup() {
|
|||||||
pinMode(IN_PHOTOTRA, INPUT_PULLDOWN);
|
pinMode(IN_PHOTOTRA, INPUT_PULLDOWN);
|
||||||
pinMode(WTR_LVL, INPUT);
|
pinMode(WTR_LVL, INPUT);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
attachInterrupt(digitalPinToInterrupt(BTN_DIMM), dimmButtonFcn, FALLING);
|
attachInterrupt(digitalPinToInterrupt(BTN_DIMM), dimmButtonFcn, FALLING);
|
||||||
attachInterrupt(digitalPinToInterrupt(BTN_SPEED), speedButtonFcn, FALLING);
|
attachInterrupt(digitalPinToInterrupt(BTN_SPEED), speedButtonFcn, FALLING);
|
||||||
attachInterrupt(digitalPinToInterrupt(BTN_HYGRSTT), hygrostatButtonFcn, FALLING);
|
attachInterrupt(digitalPinToInterrupt(BTN_HYGRSTT), hygrostatButtonFcn, FALLING);
|
||||||
@@ -202,42 +202,44 @@ void setup() {
|
|||||||
lightMeter.begin();
|
lightMeter.begin();
|
||||||
dht.begin();
|
dht.begin();
|
||||||
pixels.begin();
|
pixels.begin();
|
||||||
|
if (dimmStep == 0) {
|
||||||
|
dimmVal = 0;
|
||||||
|
} else if (dimmStep == 1) {
|
||||||
|
dimmVal = 1;
|
||||||
|
} else if (dimmStep == 2) {
|
||||||
|
dimmVal = 6;
|
||||||
|
} else if (dimmStep == 3) {
|
||||||
|
dimmVal = 12;
|
||||||
|
} else {
|
||||||
|
dimmVal = 24;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
delay(50);
|
// ###################################################
|
||||||
|
// WYŚWIETLACZ
|
||||||
|
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setCursor(90, 0);
|
display.setCursor(90, 0);
|
||||||
display.println(Version);
|
display.println(Version);
|
||||||
|
|
||||||
|
|
||||||
display.setCursor(0, 0);
|
display.setCursor(0, 0);
|
||||||
display.println("RST:");
|
display.println("RST:");
|
||||||
display.setCursor(25, 0);
|
display.setCursor(25, 0);
|
||||||
display.println(resetVal);
|
display.println(resetVal);
|
||||||
|
|
||||||
|
|
||||||
display.setCursor(35, 0);
|
display.setCursor(35, 0);
|
||||||
display.println("L:");
|
display.println("L:");
|
||||||
display.setCursor(47, 0);
|
display.setCursor(47, 0);
|
||||||
float lux = lightMeter.readLightLevel();
|
|
||||||
display.println(lux);
|
display.println(lux);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int waterLvlVal = touchRead(WTR_LVL);
|
|
||||||
display.setCursor(0, 10);
|
display.setCursor(0, 10);
|
||||||
display.println("WtrLvl:");
|
display.println("WtrLvl:");
|
||||||
display.setCursor(50, 10);
|
display.setCursor(50, 10);
|
||||||
display.println(waterLvlVal);
|
display.println(waterLvlVal);
|
||||||
// waterLvlVal > 45 znnaczy bez wiody
|
display.setCursor(70, 10);
|
||||||
|
display.println("FanSpd:");
|
||||||
// display.setCursor(0, 10);
|
display.setCursor(115, 10);
|
||||||
// display.println("FanSpd:");
|
display.println(fanSpeedVal);
|
||||||
// display.setCursor(50, 10);
|
|
||||||
// display.println(fanSpeedVal);
|
|
||||||
|
|
||||||
// display.setCursor(0, 10);
|
// display.setCursor(0, 10);
|
||||||
// display.println("FanSpd:");
|
// display.println("FanSpd:");
|
||||||
@@ -249,61 +251,32 @@ void loop() {
|
|||||||
// display.setCursor(115, 10);
|
// display.setCursor(115, 10);
|
||||||
// display.println(hygrostatVal);
|
// display.println(hygrostatVal);
|
||||||
|
|
||||||
hum = (dht.readHumidity());
|
|
||||||
// display.setCursor(0, 20);
|
|
||||||
// display.println("Hum:");
|
|
||||||
// display.setCursor(28, 20);
|
|
||||||
// display.println(hum);
|
|
||||||
|
|
||||||
int photoVal = analogRead(IN_PHOTOTRA);
|
|
||||||
display.setCursor(0, 20);
|
display.setCursor(0, 20);
|
||||||
display.println("Ph:");
|
display.println("Hum:");
|
||||||
display.setCursor(28, 20);
|
display.setCursor(28, 20);
|
||||||
display.println(photoVal);
|
display.println(hum);
|
||||||
|
|
||||||
|
// display.setCursor(0, 20);
|
||||||
|
// display.println("Ph:");
|
||||||
|
// display.setCursor(28, 20);
|
||||||
|
// display.println(photoVal);
|
||||||
|
|
||||||
display.setCursor(70, 20);
|
display.setCursor(70, 20);
|
||||||
display.println("Dimm:");
|
display.println("Dimm:");
|
||||||
display.setCursor(115, 20);
|
display.setCursor(115, 20);
|
||||||
display.println(dimmVal);
|
display.println(dimmStep);
|
||||||
|
|
||||||
delay(50);
|
|
||||||
display.display();
|
display.display();
|
||||||
|
|
||||||
|
// DATA HAVEREST
|
||||||
|
lux = lightMeter.readLightLevel();
|
||||||
|
waterLvlVal = touchRead(WTR_LVL);
|
||||||
|
hum = (dht.readHumidity());
|
||||||
|
photoVal = analogRead(IN_PHOTOTRA);
|
||||||
// #################################################################
|
// #################################################################
|
||||||
|
|
||||||
// #################################################################
|
// #################################################################
|
||||||
//NEOPIXELS
|
// LOGIKA
|
||||||
// #################################################################
|
|
||||||
// #################################################################
|
|
||||||
pixels.clear();
|
|
||||||
|
|
||||||
// pixels.setPixelColor(ADR_NEOPXL_SPEED_2, pixels.Color(0, 50, 0));
|
|
||||||
// pixels.setPixelColor(ADR_NEOPXL_SPEED_1, pixels.Color(50, 0, 0));
|
|
||||||
// pixels.setPixelColor(2, pixels.Color(50, 0, 0));
|
|
||||||
// pixels.setPixelColor(3, pixels.Color(50, 0, 0));
|
|
||||||
// pixels.setPixelColor(4, pixels.Color(50, 0, 0));
|
|
||||||
// pixels.setPixelColor(5, pixels.Color(50, 0, 0));
|
|
||||||
// pixels.setPixelColor(6, pixels.Color(50, 0, 0));
|
|
||||||
// pixels.setPixelColor(7, pixels.Color(50, 0, 0));
|
|
||||||
// pixels.setPixelColor(8, pixels.Color(50, 0, 0));
|
|
||||||
|
|
||||||
|
|
||||||
rainbowCycle(10); // im mniejsza liczba, tym szybsza animacja
|
|
||||||
|
|
||||||
|
|
||||||
// pixels.setPixelColor(ADR_NEOPXL_SPEED_1, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelSpeed_1, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelSpeed_1, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelSpeed_1));
|
|
||||||
// pixels.setPixelColor(ADR_NEOPXL_SPEED_2, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelSpeed_2, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelSpeed_2, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelSpeed_2));
|
|
||||||
// pixels.setPixelColor(ADR_NEOPXL_FILTER, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelFilter, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelFilter, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelFilter));
|
|
||||||
// pixels.setPixelColor(ADR_NEOPXL_L1, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelLvl_1, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelLvl_1, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelLvl_1));
|
|
||||||
// pixels.setPixelColor(ADR_NEOPXL_L2, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelLvl_2, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelLvl_2, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelLvl_2));
|
|
||||||
// pixels.setPixelColor(ADR_NEOPXL_L3, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelLvl_3, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelLvl_3, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelLvl_3));
|
|
||||||
// pixels.setPixelColor(ADR_NEOPXL_L4, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelLvl_4, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelLvl_4, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelLvl_4));
|
|
||||||
// pixels.setPixelColor(ADR_NEOPXL_L5, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelLvl_5, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelLvl_5, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelLvl_5));
|
|
||||||
|
|
||||||
// pixels.setPixelColor(ADR_NEOPXL_WATERLVL, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelWaterLvl, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelWaterLvl, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelWaterLvl));
|
|
||||||
// pixels.setPixelColor(ADR_NEOPXL_TANK, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelTank, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelTank, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelTank));
|
|
||||||
// pixels.show();
|
|
||||||
|
|
||||||
|
|
||||||
if (digitalRead(BTN_RST) == HIGH) {
|
if (digitalRead(BTN_RST) == HIGH) {
|
||||||
unsigned long startTime = millis();
|
unsigned long startTime = millis();
|
||||||
while (digitalRead(BTN_RST) == HIGH && millis() - startTime < 4000) {
|
while (digitalRead(BTN_RST) == HIGH && millis() - startTime < 4000) {
|
||||||
@@ -323,10 +296,115 @@ void loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(500);
|
if (hum > hygrostatVal) {
|
||||||
|
setFanSpeed (0);
|
||||||
// digitalWrite(LED_WHT_TANK, LOW);
|
neoPixelSpeed_1 = 1;
|
||||||
// digitalWrite(LED_RED_TANK, LOW);
|
neoPixelSpeed_2 = 1;
|
||||||
// digitalWrite(PIN_SPEED_1, LOW);
|
} else if (hum >= (hygrostatVal - 5) and fanSpeedVal == 2) {
|
||||||
// digitalWrite(PIN_SPEED_2, LOW);
|
setFanSpeed (1); //ustaw predkość 1 zbliża sie do docelowej wartości
|
||||||
|
neoPixelSpeed_1 = 4;
|
||||||
|
neoPixelSpeed_2 = 1;
|
||||||
|
} else if (hum < hygrostatVal) {
|
||||||
|
setFanSpeed (fanSpeedVal);
|
||||||
|
neoPixelSpeed_1 = 4;
|
||||||
|
if (fanSpeedVal == 1){
|
||||||
|
neoPixelSpeed_2 = 0;
|
||||||
|
} else {
|
||||||
|
neoPixelSpeed_2 = 4;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dimmStep == 0) {
|
||||||
|
dimmVal = 0;
|
||||||
|
} else if (dimmStep == 1) {
|
||||||
|
dimmVal = 1;
|
||||||
|
} else if (dimmStep == 2) {
|
||||||
|
dimmVal = 6;
|
||||||
|
} else if (dimmStep == 3) {
|
||||||
|
dimmVal = 12;
|
||||||
|
} else {
|
||||||
|
dimmVal = 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hygrostatVal >= 65) {
|
||||||
|
neoPixelLvl_1 = 1;
|
||||||
|
neoPixelLvl_2 = 1;
|
||||||
|
neoPixelLvl_3 = 1;
|
||||||
|
neoPixelLvl_4 = 1;
|
||||||
|
neoPixelLvl_5 = 1;
|
||||||
|
|
||||||
|
} else if (hygrostatVal == 60) {
|
||||||
|
neoPixelLvl_1 = 1;
|
||||||
|
neoPixelLvl_2 = 1;
|
||||||
|
neoPixelLvl_3 = 1;
|
||||||
|
neoPixelLvl_4 = 1;
|
||||||
|
neoPixelLvl_5 = 0;
|
||||||
|
} else if (hygrostatVal == 55) {
|
||||||
|
neoPixelLvl_1 = 1;
|
||||||
|
neoPixelLvl_2 = 1;
|
||||||
|
neoPixelLvl_3 = 1;
|
||||||
|
neoPixelLvl_4 = 0;
|
||||||
|
neoPixelLvl_5 = 0;
|
||||||
|
} else if (hygrostatVal == 50) {
|
||||||
|
neoPixelLvl_1 = 1;
|
||||||
|
neoPixelLvl_2 = 1;
|
||||||
|
neoPixelLvl_3 = 0;
|
||||||
|
neoPixelLvl_4 = 0;
|
||||||
|
neoPixelLvl_5 = 0;
|
||||||
|
} else if (hygrostatVal == 45) {
|
||||||
|
neoPixelLvl_1 = 1;
|
||||||
|
neoPixelLvl_2 = 0;
|
||||||
|
neoPixelLvl_3 = 0;
|
||||||
|
neoPixelLvl_4 = 0;
|
||||||
|
neoPixelLvl_5 = 0;
|
||||||
|
} else if (hygrostatVal <= 40) {
|
||||||
|
neoPixelLvl_1 = 0;
|
||||||
|
neoPixelLvl_2 = 0;
|
||||||
|
neoPixelLvl_3 = 0;
|
||||||
|
neoPixelLvl_4 = 0;
|
||||||
|
neoPixelLvl_5 = 0;
|
||||||
|
} else {
|
||||||
|
neoPixelLvl_1 = 1;
|
||||||
|
neoPixelLvl_2 = 0;
|
||||||
|
neoPixelLvl_3 = 1;
|
||||||
|
neoPixelLvl_4 = 0;
|
||||||
|
neoPixelLvl_5 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dimmStep == 0 ){
|
||||||
|
analogWrite(LED_WHT_TANK, 0);
|
||||||
|
analogWrite(LED_RED_TANK, 0);
|
||||||
|
} else {
|
||||||
|
if (waterLvlVal >= 45 ) { // waterLvlVal > 45 znnaczy bez wiody
|
||||||
|
neoPixelWaterLvlR = 1;
|
||||||
|
neoPixelWaterLvlG = 0; //Przygotowanie pod żółty kolor jak mało wody
|
||||||
|
analogWrite(LED_WHT_TANK, 0);
|
||||||
|
analogWrite(LED_RED_TANK, dimmVal*4);
|
||||||
|
} else {
|
||||||
|
neoPixelWaterLvlR = 0;
|
||||||
|
neoPixelWaterLvlG = 1;
|
||||||
|
analogWrite(LED_WHT_TANK, dimmVal*4);
|
||||||
|
analogWrite(LED_RED_TANK, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
delay(100);
|
||||||
|
//NEOPIXELS
|
||||||
|
// #################################################################
|
||||||
|
// #################################################################
|
||||||
|
pixels.clear();
|
||||||
|
pixels.setPixelColor(ADR_NEOPXL_SPEED_1, pixels.Color(int((neoPixelRed*dimmVal*neoPixelSwitch*neoPixelSpeed_1)/4), int((neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelSpeed_1)/4), int((neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelSpeed_1)/4)));
|
||||||
|
pixels.setPixelColor(ADR_NEOPXL_SPEED_2, pixels.Color(int((neoPixelRed*dimmVal*neoPixelSwitch*neoPixelSpeed_2)/4), int((neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelSpeed_2)/4), int((neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelSpeed_2)/4)));
|
||||||
|
pixels.setPixelColor(ADR_NEOPXL_FILTER, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelFilter, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelFilter, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelFilter));
|
||||||
|
pixels.setPixelColor(ADR_NEOPXL_L1, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelLvl_1, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelLvl_1, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelLvl_1));
|
||||||
|
pixels.setPixelColor(ADR_NEOPXL_L2, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelLvl_2, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelLvl_2, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelLvl_2));
|
||||||
|
pixels.setPixelColor(ADR_NEOPXL_L3, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelLvl_3, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelLvl_3, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelLvl_3));
|
||||||
|
pixels.setPixelColor(ADR_NEOPXL_L4, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelLvl_4, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelLvl_4, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelLvl_4));
|
||||||
|
pixels.setPixelColor(ADR_NEOPXL_L5, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelLvl_5, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelLvl_5, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelLvl_5));
|
||||||
|
pixels.setPixelColor(ADR_NEOPXL_WATERLVL, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelWaterLvlR, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelWaterLvlG, 0));
|
||||||
|
// pixels.setPixelColor(ADR_NEOPXL_TANK, pixels.Color(neoPixelRed*dimmVal*neoPixelSwitch*neoPixelTank, neoPixelGreen*dimmVal*neoPixelSwitch*neoPixelTank, neoPixelBlue*dimmVal*neoPixelSwitch*neoPixelTank));
|
||||||
|
pixels.show();
|
||||||
|
// rainbowCycle(10); // im mniejsza liczba, tym szybsza animacja
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user