Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "PCF8574.h"
- PCF8574 pcf8574(0x20);
- byte IN1 = P3;
- byte IN2 = P2;
- byte IN3 = P1;
- byte IN4 = P0;
- byte LED = 15;
- bool stateLed = 0;
- unsigned long cur_time, old_time;
- void setup() {
- // put your setup code here, to run once:
- delay(100);
- Serial.begin(115200);
- pinMode(LED, OUTPUT);
- pcf8574.pinMode(IN1, INPUT);
- pcf8574.pinMode(IN2, INPUT);
- pcf8574.pinMode(IN3, INPUT);
- pcf8574.pinMode(IN4, INPUT);
- Serial.print("Init pcf8574...");
- if (pcf8574.begin()) {
- Serial.println("OK");
- } else {
- Serial.println("KO");
- }
- delay(100);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- cur_time = millis();
- if(cur_time - old_time >= 3000){
- stateLed = !stateLed;
- digitalWrite(LED,stateLed);
- Serial.print(pcf8574.digitalRead(IN1));
- Serial.print(pcf8574.digitalRead(IN2));
- Serial.print(pcf8574.digitalRead(IN3));
- Serial.println(pcf8574.digitalRead(IN4));
- old_time = millis();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement