Need help with serial control of LC7821

hey i was wondering if someone can write a code that can control a LC7821 - Analog Function Switch. I just need it to switch between channels 1-4 every 2 seconds. Datasheet LC7821 pdf, LC7821 Description, LC7821 Datasheet, LC7821 view ::: ALLDATASHEET :::

Thanks

Did you have a look on the SoftSerial and SoftwareSerial - Commands ?

Connect the port from the LC7821 to an ARDUINO, redirect these ports to others (for output etc.) and switch every 2 seconds a channel up

For i = 1 to 4
 DigitalWrite Port.Channel(i) = HIGH;
 Output.Pin(i) {
...do something...
 }
 delay(2000);
next i

(native Code - not tested)

i thought i got it with spi but looking at the data sheet i think i need to hold the clock low longer when i switch ce high but i am not sure how to do this.

Here also: connect the port of the lc7821 to the ARDUINO and then set the port high or low:

#define CEport 5                // the pin 5  the port CE of the lc is connected to
digitalWrite(CEport, HIGH);
delay(170);
digitalWrite(CEport, LOW);

look in the datasheet if a specific time must be held for initializing - the time in brackets in the delay command are in Milliseconds, so delay(1000); gives you 1 second.

Also Note: check if your board sets ON if the port is LOW and reverse !
So if, then i.e. LOW turns a LED on and HIGH turns it off :wink: