/*
Custom chip playground (PCF8574)
Instructions to RUN:
1. Open the Custom Chip Playground, go to the code editor,
press "F1" and select "Create a custom TypeScript chip (alpha)".
this will create a new file called wokwi-custom-chip.ts
2. Copy all code from wokwi-custom-chip.txt to wokwi-custom-chip.ts
3. Copy all settings from wokwi-custom-chip-json.txt to wokwi-custom-chip.json
4. Run the simulator
5. Click on rotary encoder & Enjoy PacMan! ;)
See for more info: https://link.wokwi.com/custom-chips-alpha/
*/
#include <PCF8574.h>
PCF8574 pcf20(0x20);
void setup() {
Serial.begin(115200);
Serial.print("PCF8574_LIB_VERSION:\t");
Serial.println(PCF8574_LIB_VERSION);
if (!pcf20.begin()) {
Serial.println("Chip not responding. Did you create wokwi-custom-chip.c.temp/.ts?");
}
if (!pcf20.isConnected()) {
Serial.println("could not initialize... => not connected");
while (1);
}
uint8_t value = pcf20.read8();
Serial.print("0x20 read: ");
Serial.println(value, HEX);
}
void loop() {
for (int i = 0; i < 255; i++) {
pcf20.write8(i);
delay(10);
}
pcf20.write(0, 1);
for (int i = 0; i < 7; i++) {
pcf20.shiftLeft();
delay(100);
}
for (int i = 0; i < 7; i++) {
pcf20.shiftRight();
delay(100);
}
for (int i = 0; i < 8; i++) {
pcf20.write(i, 1);
delay(100);
pcf20.write(i, 0);
delay(100);
}
for (int i = 0; i < 8; i++) {
pcf20.toggle(i);
delay(100);
pcf20.toggle(i);
delay(100);
}
// Echo the state of the lines on the other PCF
uint8_t value = pcf20.read8();
pcf20.write8(value);
delay(100);
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C
led4:A
led4:C
led5:A
led5:C
led6:A
led6:C
led7:A
led7:C
led8:A
led8:C