MUstar

IoT 아두이노 0630 - EX-01

Jun 29th, 2017
61
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <MsTimer2.h>
  2.  
  3. //int pin_STEP[8] = {8, 9, 10, 11};
  4. int pin_STEP[8] = {11, 10, 9, 8};
  5.  
  6. void setup() {
  7.   int i;
  8.   for(i=0;i<4;i++)
  9.     pinMode(pin_STEP[i], OUTPUT);
  10.     STEP_out(0xF);
  11.     MsTimer2::set(10, STEP_ISR);
  12.     MsTimer2::start();
  13. }
  14.  
  15. void loop() {
  16. }
  17. void STEP_out(uint8_t da){
  18.   for(int i=3; i>-1; i--)
  19.     digitalWrite(pin_STEP[i], (da<<i)&0x01);
  20. }
  21.  
  22. void STEP_ISR(void)
  23. {
  24.   static int i=3;
  25.   STEP_out (0x0F);
  26.   STEP_out(~(0x01>>i));
  27.   if(i == 0){i=0;}
  28.   else{i--;}
  29. }
RAW Paste Data