Advertisement
MUstar

IoT 아두이노 0421 - LED_ex1

Apr 21st, 2017
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. // LED0, LED1, LED2, LED3, LED4, LED5, LED6, LED7 pin
  2. int pin_LED[8] = {22, 24, 26, 28, 30, 32, 34, 36};
  3.  
  4. void setup() {
  5.   // put your setup code here, to run once:
  6.   for(int i=0; i<8; i++)
  7.   {
  8.     pinMode(pin_LED[i], OUTPUT);  // LED pin Output setup
  9.     digitalWrite(pin_LED[i], LOW);  // LED pin LOW Output
  10.   }
  11. }
  12.  
  13. void loop() {
  14.   // put your main code here, to run repeatedly:
  15.   for(int i=0; i<256; i++)
  16.   {
  17.     LED_control(i);  // LED control
  18.     delay(500);  // wait 0.5 second
  19.   }
  20. }
  21.  
  22. // LED contorl function
  23. void LED_control(uint8_t da)
  24. {
  25.   for(int i=0; i<8; i++)
  26.   {
  27.     digitalWrite(pin_LED[i], (da >> i) & 0x1);
  28.   }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement