test_code.txt 809 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Buck Converter test code
  2. #include <TimerOne.h>
  3. void setup()
  4. {
  5. // Initialize the digital pin as an output.
  6. // Pin 13 has an LED connected on most Arduino boards
  7. pinMode(13, OUTPUT);
  8. pinMode(9, OUTPUT);
  9. pinMode(8, OUTPUT);
  10. digitalWrite(8, HIGH);
  11. Timer1.initialize(20); // set a timer of length 8uS
  12. //Timer1.attachInterrupt( timerIsr ); // attach the service routine here
  13. //Set duty cycle
  14. //Timer1.pwm(9,256); // 25% duty cycle
  15. // Timer1.pwm(9, 512); // 50% duty cycle
  16. Timer1.pwm(9, 768); // 75% duty cycle
  17. }
  18. void loop()
  19. {
  20. // Main code loop
  21. // TODO: Put your regular (non-ISR) logic here
  22. }
  23. /// --------------------------
  24. /// Custom ISR Timer Routine
  25. /// --------------------------
  26. void timerIsr()
  27. {
  28. // Toggle LED
  29. //digitalWrite( 13, digitalRead( 13 ) ^ 1 );
  30. }