New answers tagged

0

Your interrupt code looks reasonable, except that once you set flag to true you never set it back to false again. You need a way to identify the the IR sensor is no longer active. Perhaps change your interrupt to fire on a change of state and set the flag to true when it switches to LOW (like it does no) and false when it switches back to high? I'd need to ...


1

You can use the TeensyTimerTool for this. It provides a generic interface to the hardware timers (TMR, GPT, PIT) and 20 software timers. Since the coupling of the timer peripherals to the ARM core is rather inefficient, the software timers might be a better fit for sub micro second interrupts. If you prefer the hardware timers I suggest to use a GPT timer (...


0

I often use a timer loop to read sensors. I've attached some code, which compiles, however I don't have the sensor. BTW. I am assuming it is a single shot IR sensor that returns 0 if something is detected. int out1 = 5; //motor int IRSensor = 3; // connect ir sensor to arduino pin 6 int LED = 6; // conect Led to arduino pin 9 int Switch = 2; int ...


2

What I am assuming is that the reason there is jitter is that there are other interrupts going on in the background This seems like a reasonable assumption. Since you are not doing serial communication, the Timer 0 interrupt is likely the only one triggering in the background. You can disable it with: TIMSK0 = 0; but then all the Arduino timing ...


3

The problem is here: ISR(TIMER3_COMPB_vect) { TCNT3 = 0; ... If you want to get anything that vaguely looks like accurate timings, you should never reset the timer. The MCU needs time to process an interrupt: it has to save the program counter to the stack, load the address of the interrupt vector, execute it (it's typically a jump), save all the ...


2

When analogWrite writes 0 or 255 value, it actually disables PWM output and sets the output to 0 or 1 correspondingly (maybe just one of them). That's because there is just 256 values, but with both fully off and fully on PWM you'll need 257 values to archieve it. If you're using direct access into OCRx, you have to make a choice if you want to have not ...


3

Is there any way to wake up after a precise amount of time in the POWER_DOWN or STAND_BY modes? I'm afraid not. You will have to use a timer. Since the ATtiny84 does not have an asynchronous timer, you will have to keep your timer clocked. This means the clkIO clock domain has to stay active. Now, take a look at the table “Active Clock Domains and Wake-up ...


Top 50 recent answers are included