MUstar

IoT 아두이노 0421 - LED8개

Apr 21st, 2017
42
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int pin_LED[8] = {22,24,26,28,30,32,34,36};
  2. void setup() {
  3.   // put your setup code here, to run once:
  4.   for(int i=0; i<8; i++)
  5.   {
  6.     pinMode(pin_LED[i],OUTPUT);
  7.     digitalWrite(pin_LED[i], LOW);
  8.   }
  9. }
  10.  
  11. void loop() {
  12.   // put your main code here, to run repeatedly:
  13.   for(int i=0; i<256; i++)
  14.   {
  15.     LED_control(i);
  16.   }
  17.   delay(1000);
  18.   for(int i=0; i<1; i++)
  19.   {
  20.     LED_control(i);
  21.   }
  22.    delay(1000);
  23. }
  24.  
  25. void LED_control(uint8_t da)
  26. {
  27.   for(int i=0; i<8; i++)
  28.   {
  29.     digitalWrite(pin_LED[i], (da >> i) & 0x1);
  30.   }
  31. }
RAW Paste Data