Diferencia entre revisiones de «Taller de Arduino»

Sin resumen de edición
Sin resumen de edición
Línea 54: Línea 54:
   }
   }
   delay(50);
   delay(50);
}
</pre>
===Código 4===
<pre>
#define USE_TIMER_1    true
#include "TimerInterrupt.h"
unsigned int outputPin1 = LED_BUILTIN;
#define TIMER1_INTERVAL_MS    300
void TimerHandler1(unsigned int outputPin = LED_BUILTIN) {
  static bool toggle1 = false;
  static bool started = false;
  if (!started) {
    started = true;
    pinMode(outputPin, OUTPUT);
  }
 
  digitalWrite(outputPin, toggle1);
  toggle1 = !toggle1;
}
void setup() {
  ITimer1.init();
  ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS, TimerHandler1, outputPin1);
}
void loop() {
}
}
</pre>
</pre>