DS2408 Switch
DS2408 Switch
DS2408 Switch
#include "OneWireHub.h"
#include "DS2408.h"
bool blinking(void);
void setup()
{
Serial.begin(115200);
Serial.println("OneWire-Hub DS2408 - 8CH GPIO Port Extender");
pinMode(pin_led, OUTPUT);
// Setup OneWire
hub.attach(ds2408);
Serial.println("config done");
}
void loop()
{
// following function must be called periodically
hub.poll();
// this part is just for debugging (USE_SERIAL_DEBUG in OneWire.h must be
enabled for output)
if (hub.hasError()) hub.printError();
digitalWrite(10, ds2408.getPinState(0));
digitalWrite(11, ds2408.getPinState(1));
digitalWrite(2, ds2408.getPinState(2));
digitalWrite(3, ds2408.getPinState(3));
digitalWrite(4, ds2408.getPinState(4));
digitalWrite(5, ds2408.getPinState(5));
digitalWrite(6, ds2408.getPinState(6));
digitalWrite(7, ds2408.getPinState(7));
bool blinking(void)
{
const uint32_t interval = 1000; // interval at which to blink
(milliseconds)
static uint32_t nextMillis = millis(); // will store next time LED will
updated