UCN5821A BiMOS II 8 BIT Serial-Input, Latched Drivers

Used Products:

1. Arduino UNO
2. UCN5821A

Code:

#define latchPin 8 #define clkPin 10 #define daiPin 11 int counter = 0; int del = 1000; void setup() { Serial.begin(9600); pinMode(latchPin, OUTPUT); pinMode(clkPin, OUTPUT); pinMode(daiPin, OUTPUT); digitalWrite(latchPin, LOW); digitalWrite(daiPin, LOW); digitalWrite(clkPin, LOW); } void loop() { for (int i = 0; i < 8; i++) { doLow(); } for (int i = 0; i < 4; i++) { if (counter%2==0) { doLow(); doHigh(); } else { doHigh(); doLow(); } } counter++; digitalWrite(latchPin, HIGH); digitalWrite(latchPin, LOW); Serial.print(", counter: "); Serial.print(counter); Serial.println(); delay(del); } void doLow() { digitalWrite(daiPin, LOW); digitalWrite(clkPin, HIGH); digitalWrite(clkPin, LOW); } void doHigh() { digitalWrite(daiPin, HIGH); digitalWrite(clkPin, HIGH); digitalWrite(clkPin, LOW); digitalWrite(daiPin, LOW); }