bambangSud

Akses watchdog timer di Arduino

Oct 20th, 2013
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. // LINE/twitter: @bambangSud #Whatsapp +62811234123
  2. #include <stdint.h>
  3. #include <avr/interrupt.h>
  4. #include <avr/wdt.h>
  5. #define LED_PIN 13
  6.  
  7. /*
  8. * The setup function.
  9. */
  10. void setup() {
  11. Serial.begin(9600);
  12. pinMode(LED_PIN, OUTPUT);
  13. wdtSetup(); // <<--------- sub routine nya ada di bawah
  14. }
  15.  
  16. /*
  17. * The main loop.
  18. */
  19. void loop()
  20. {
  21. digitalWrite(13, HIGH); // set the LED on
  22. delay(1000); // wait for a second
  23. digitalWrite(13, LOW); // set the LED off
  24. delay(1000); // wait for a second
  25. Serial.println("Background");
  26. }
  27.  
  28. /*
  29. * Setup of the watchdog timer.
  30. */
  31. void wdtSetup() {
  32. cli();
  33. MCUSR = 0;
  34. WDTCSR |= B00011000;
  35. WDTCSR = B01000111;
  36. sei();
  37. }
Add Comment
Please, Sign In to add comment