Dodanie czujnika światła BH1750
OBsługa Red/White LED TANK Próa z fotorezystorem
This commit is contained in:
@@ -4,8 +4,9 @@
|
||||
#include <Adafruit_SSD1306.h>
|
||||
#include "DHT.h"
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#include <BH1750.h>
|
||||
|
||||
#define Version "0.1.0"
|
||||
#define Version "0.2.0"
|
||||
|
||||
|
||||
|
||||
@@ -41,6 +42,7 @@
|
||||
|
||||
#define NEOPIXEL 27 //GPIO04 D27
|
||||
|
||||
#define IN_PHOTOTRA 12
|
||||
|
||||
|
||||
//NEO PIXEL ARDESES:
|
||||
@@ -61,6 +63,7 @@
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
Adafruit_NeoPixel pixels(NUMPIXELS, NEOPIXEL, NEO_GRB + NEO_KHZ800);
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
BH1750 lightMeter;
|
||||
|
||||
|
||||
|
||||
@@ -101,12 +104,15 @@ void IRAM_ATTR dimmButtonFcn() {
|
||||
if (dimmVal >= 11) {
|
||||
dimmVal = 1;
|
||||
}
|
||||
digitalWrite(LED_WHT_TANK, HIGH);
|
||||
}
|
||||
void IRAM_ATTR speedButtonFcn() {
|
||||
fanSpeedVal ++;
|
||||
if (fanSpeedVal >= 3) {
|
||||
fanSpeedVal = 0;
|
||||
}
|
||||
digitalWrite(LED_RED_TANK, HIGH);
|
||||
|
||||
}
|
||||
void IRAM_ATTR hygrostatButtonFcn() {
|
||||
hygrostatVal = hygrostatVal + 10;
|
||||
@@ -138,15 +144,31 @@ void setup() {
|
||||
pinMode(BTN_HYGRSTT, INPUT);
|
||||
pinMode(PIN_SPEED_1, OUTPUT);
|
||||
pinMode(PIN_SPEED_2, OUTPUT);
|
||||
pinMode(LED_RED_TANK, OUTPUT);
|
||||
pinMode(LED_WHT_TANK, OUTPUT);
|
||||
pinMode(IN_PHOTOTRA, INPUT);
|
||||
|
||||
|
||||
|
||||
|
||||
attachInterrupt(digitalPinToInterrupt(BTN_DIMM), dimmButtonFcn, FALLING);
|
||||
attachInterrupt(digitalPinToInterrupt(BTN_SPEED), speedButtonFcn, FALLING);
|
||||
attachInterrupt(digitalPinToInterrupt(BTN_HYGRSTT), hygrostatButtonFcn, FALLING);
|
||||
Wire.begin();
|
||||
lightMeter.begin();
|
||||
dht.begin();
|
||||
pixels.begin();
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
float lux = lightMeter.readLightLevel();
|
||||
Serial.print("Light: ");
|
||||
Serial.print(lux);
|
||||
Serial.println(" lx");
|
||||
delay(1000);
|
||||
|
||||
|
||||
display.clearDisplay();
|
||||
display.setCursor(90, 0);
|
||||
display.println(Version);
|
||||
@@ -170,10 +192,16 @@ void loop() {
|
||||
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.println("Hum:");
|
||||
display.println("Ph:");
|
||||
display.setCursor(28, 20);
|
||||
display.println(hum);
|
||||
display.println(photoVal);
|
||||
|
||||
display.setCursor(70, 20);
|
||||
display.println("Dimm:");
|
||||
@@ -224,7 +252,10 @@ void loop() {
|
||||
}
|
||||
}
|
||||
|
||||
delay(50);
|
||||
delay(500);
|
||||
|
||||
digitalWrite(LED_WHT_TANK, LOW);
|
||||
digitalWrite(LED_RED_TANK, LOW);
|
||||
// digitalWrite(PIN_SPEED_1, LOW);
|
||||
// digitalWrite(PIN_SPEED_2, LOW);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user