Smart Home Automation Forum
[Arduino source code for KC868-A256]-04 OUTPUT_256 - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KC868-A256 (https://www.kincony.com/forum/forumdisplay.php?fid=44)
+--- Thread: [Arduino source code for KC868-A256]-04 OUTPUT_256 (/showthread.php?tid=2719)



[Arduino source code for KC868-A256]-04 OUTPUT_256 - KinCony Support - 03-22-2023

Code:
/*
KC868-256  press button S2,all leds will on one by one;
            release the button,all leds will off one by one;
*/

int latchPin = 4;
int clockPin = 16;
int dataPin = 5;
int button =0;

void setup()
{
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT); 
  pinMode(clockPin, OUTPUT);
  pinMode(button, INPUT);
 
}

void loop()
{
if(digitalRead(button)==LOW){
     
     digitalWrite(dataPin,HIGH);
     delay(10);
     digitalWrite(clockPin,LOW);
     delay(10);
     digitalWrite(clockPin,HIGH);
     delay(10);
     digitalWrite(latchPin, LOW);
     delay(10);
     digitalWrite(latchPin, HIGH);
     delay(100);
}
else {
     digitalWrite(dataPin,LOW);
     delay(10);
     digitalWrite(clockPin,LOW);
     delay(10);
     digitalWrite(clockPin,HIGH);
     delay(10);
     digitalWrite(latchPin, LOW);
     delay(10);
     digitalWrite(latchPin, HIGH);
     delay(100);
  }

}