Zwielokrotnienie pętli
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#include <BH1750.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
#define Version "0.1.0"
|
||||
#define Version "0.1.2"
|
||||
|
||||
#define PinLED 2 // on-board LED
|
||||
#define IN1 32
|
||||
@@ -39,10 +39,17 @@ void setup() {
|
||||
pinMode(PinLED, OUTPUT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void pulsujNaprzemiennie(int czasSekundy) {
|
||||
const int steps = 400; // większa liczba = gładsze przejścia
|
||||
const int steps = 600; // większa liczba = gładsze przejścia
|
||||
const int totalMillis = czasSekundy * 1000;
|
||||
const int delayPerStep = totalMillis / steps;
|
||||
// display.clearDisplay();
|
||||
// display.setCursor(0, 20);
|
||||
// display.println("1");
|
||||
// display.display();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
|
||||
for (int i = 0; i <= steps; i++) {
|
||||
float phase = (float)i / steps;
|
||||
@@ -71,6 +78,11 @@ void pulsujNaprzemiennie(int czasSekundy) {
|
||||
}
|
||||
|
||||
// drugi półcykl: kolory zamienione miejscami (pełny cykl = 2x π)
|
||||
// display.clearDisplay();
|
||||
// display.setCursor(0, 20);
|
||||
// display.println("2");
|
||||
// display.display();
|
||||
|
||||
for (int i = 0; i <= steps; i++) {
|
||||
float phase = (float)i / steps;
|
||||
float angle = phase * PI;
|
||||
@@ -92,10 +104,11 @@ void pulsujNaprzemiennie(int czasSekundy) {
|
||||
delayMicroseconds(1000 * delayPerStep - pulse1 - pulse2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
uint16_t lux = lightMeter.readLightLevel();
|
||||
if (lux < 10) {
|
||||
if (lux < 10 || lux == -2) {
|
||||
digitalWrite(PinLED, LOW);
|
||||
pulsujNaprzemiennie(8); // pełny cykl 8 sekund
|
||||
} else {
|
||||
@@ -104,5 +117,7 @@ void loop() {
|
||||
display.println("OFF");
|
||||
delay(5000);
|
||||
}
|
||||
|
||||
|
||||
display.display();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user