Compare commits
No commits in common. "a1de1924e7d8564a1214f11cce55f60f96ddff8d" and "f266fe6a75e51d38261b74fca00c963c7b7c4285" have entirely different histories.
a1de1924e7
...
f266fe6a75
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -1,5 +0,0 @@
|
|||
.pio
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
10
.vscode/extensions.json
vendored
10
.vscode/extensions.json
vendored
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
],
|
||||
"unwantedRecommendations": [
|
||||
"ms-vscode.cpptools-extension-pack"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
[env:d1_mini]
|
||||
platform = espressif8266
|
||||
board = d1_mini
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
adafruit/Adafruit NeoPixel @ ^1.11.0
|
||||
https://github.com/RobTillaart/PCF8575
|
||||
|
|
@ -4,5 +4,4 @@
|
|||
|
||||
#define NEOPIXEL_PIN D6
|
||||
#define BRIGHTNESS 100
|
||||
#define BLINK_INTERVAL 500 // Blink interval in milliseconds (0.5 seconds)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,15 @@
|
|||
#include <Wire.h>
|
||||
#include <PCF8575.h>
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#include "Config.ino"
|
||||
|
||||
#define AMOUNTOFPORTS 8 // currently max 16 ports are supported
|
||||
#define EXPANDER1ADDRESS 0x21 // address of expander 1
|
||||
|
||||
|
||||
PCF8575 expander1(EXPANDER1ADDRESS);
|
||||
uint8_t portStates[AMOUNTOFPORTS];
|
||||
uint8_t lastStates[AMOUNTOFPORTS] = {0};
|
||||
byte number=0;
|
||||
|
||||
extern Adafruit_NeoPixel* pixels;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("Starte 16-Port IO Erweiterung...");
|
||||
|
|
@ -47,15 +44,18 @@ void setup() {
|
|||
{
|
||||
Serial.println(" => connected!!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Setup NeoPixel
|
||||
NeoPixel_init(AMOUNTOFPORTS); // Initialisierung der NeoPixel
|
||||
for (uint8_t i = 0; i < AMOUNTOFPORTS; i++) {
|
||||
portStates[i] = 0;
|
||||
lastStates[i] = 0;
|
||||
pixels->setPixelColor(i, pixels->Color(0, 0, 0)); // aus
|
||||
NeoPixel_setState(i,1);
|
||||
delay(10);
|
||||
NeoPixel_setState(i,0);
|
||||
};
|
||||
pixels->show();
|
||||
|
||||
|
||||
Serial.println("Setup End...");
|
||||
}
|
||||
|
|
@ -66,6 +66,7 @@ void loop() {
|
|||
portStates[i] = expander1.read(i);
|
||||
}
|
||||
|
||||
static uint8_t lastStates[AMOUNTOFPORTS] = {0};
|
||||
for (uint8_t i = 0; i < AMOUNTOFPORTS; i++) {
|
||||
if (portStates[i] != lastStates[i]) {
|
||||
// Ausgabe: geänderte Ports melden
|
||||
|
|
@ -74,19 +75,10 @@ void loop() {
|
|||
Serial.print(" hat sich geändert -> ");
|
||||
Serial.println(portStates[i]);
|
||||
lastStates[i] = portStates[i];
|
||||
}
|
||||
// LED aktualisieren
|
||||
if (portStates[i] == 0) {
|
||||
pixels->setPixelColor(i, pixels->Color(0, 150, 0)); // grün
|
||||
} else {
|
||||
bool globalBlinkState = (millis() / BLINK_INTERVAL) % 2;
|
||||
if (globalBlinkState) {
|
||||
pixels->setPixelColor(i, pixels->Color(150, 0, 0)); // rot
|
||||
} else {
|
||||
pixels->setPixelColor(i, pixels->Color(0, 0, 0)); // aus
|
||||
}
|
||||
// Bei änderung LED anpassen
|
||||
NeoPixel_setState(i, portStates[i]); // Jede LED pro Pin aktualisieren
|
||||
}
|
||||
}
|
||||
pixels->show();
|
||||
|
||||
delay(50);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user