Advertisement
MUstar

IoT 아두이노 0428 - LED_ex1

Apr 27th, 2017
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. int pin_LED[8] = {22,24,26,28,30,32,34,36};
  2. int pin_SWITCH[5] = {38,40,42,44,46};
  3. void setup() {
  4.   // put your setup code here, to run once:
  5.   for(int i=0; i<8; i++)
  6.   {
  7.     pinMode(pin_LED[i],OUTPUT);
  8.     digitalWrite(pin_LED[i], LOW);
  9.   }
  10.    for(int i=0; i<5; i++)
  11.   {
  12.     pinMode(pin_SWITCH[i],INPUT);
  13.   }
  14. }
  15.  
  16. void loop() {
  17.   // put your main code here, to run repeatedly:
  18.   for(int i=0; i<5; i++)
  19.   {
  20.     digitalWrite(pin_LED[i], digitalRead(pin_SWITCH[i]));
  21.   }
  22.   delay(100);
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement