MUstar

IoT 아두이노 0421 - LED2개

Apr 21st, 2017
37
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<4; i++)
  14.   {
  15.     LED_control(i);
  16.   }
  17.   delay(1000);
  18.   for(int i=12; i<13; i++)
  19.   {
  20.     LED_control(i);
  21.   }
  22.   delay(1000);
  23.   for(int i=48; i<49; i++)
  24.   {
  25.     LED_control(i);
  26.   }
  27.   delay(1000);
  28.   for(int i=192; i<193; i++)
  29.   {
  30.     LED_control(i);
  31.   }
  32.   delay(1000);
  33. }
  34.  
  35. void LED_control(uint8_t da)
  36. {
  37.   for(int i=0; i<8; i++)
  38.   {
  39.     digitalWrite(pin_LED[i], (da >> i) & 0x1);
  40.   }
  41. }
RAW Paste Data