uwezi

20210223_1TM121_F7

Feb 23rd, 2021
566
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Arduino.h>
  2.  
  3. // Interrupt Service Routine
  4. // exekveras vid TIMER3 OVerFlow
  5. ISR(TIMER3_OVF_vect)
  6. {
  7.   if (PORTE & 0b01000000)  // är LEDn på?
  8.   {
  9.     PORTE &= 0b10111111; // släck LED PE6
  10.   }
  11.   else
  12.   {
  13.     PORTE |= 0b01000000; // tänd LED PE6
  14.   }
  15. }
  16.  
  17. void setup()
  18. {
  19.   Serial.begin(9600);
  20.   DDRE = (1 << PE6);  // sätter PE6 som utgång
  21.   TCCR3A = 0b00000000; // normal mode - räkna till 65535
  22.  
  23. //  TCCR3B = 0b00000001; // 1:1 prescaler, 8 MHz
  24. //  TCCR3B = 0b00000010; // 8:1 prescaler, 1 MHz
  25.   TCCR3B = 0b00000011; // 64:1 prescaler, 125 kHz
  26. //  TCCR3B = 0b00000100; // 256:1 prescaler, 31250 Hz
  27. //  TCCR3B = 0b00000101; // 1024:1 prescaler, 7812,5 Hz
  28.  
  29.   TIMSK3 = 0b00000001; // tillåt TOIE3 Timer Overflow Interrupt
  30. }
  31.  
  32. void loop()
  33. {
  34.   Serial.println(TCNT3);
  35.   delay(300);
  36. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×