Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [interrupt]

Interrupts allow the processor to suspend normal operation temporarily so that a high-priority software or hardware event can be handled instead.

4
votes
2answers
5k views

Read RC receiver channels using Interrupt instead of PulseIn

I am designing my own quadcopter control algorithm, whereby I currently read 4 RC receiver channels using PulseIn on each loop in the following manner: ch1_raw = pulseIn(rcPin1, HIGH, 25000); In ...
9
votes
1answer
13k views

How do interrupts work on the Arduino Uno and similar boards?

Please explain how interrupts work on the Arduino Uno and related boards using the ATmega328P processor. Boards such as the: Uno Mini Nano Pro Mini Lilypad In particular please discuss: What to use ...
1
vote
1answer
586 views

Can external interrupts be OR'd together on the '328 (Uno)?

I'm thinking about how to handle a rotary encoder. I'm planning on using interrupts and would like to use both the 'A' and 'B' phase transitions to generate interrupts. I'm wondering if there is any ...
3
votes
2answers
5k views

IR Receiver interrupt and arduino sleep mode

I need to put my arduino into the sleep mode in order to consume less power. My arduino receives IR data and do some work with it, but I need to make it sleep until there is no data. If the data has ...
2
votes
4answers
9k views

How to read data from a rotary encoder with ATmega328

I'm using a home made "bare bones" Arduino, made with the ATmega328, and I need to read angle data from a geared DC drill motor, turning at speeds between 0 and 450 RPM. This is so I can use it as ...
7
votes
2answers
2k views

How to update a variable in an ISR using Timers

I'm trying to check the frequency of Timer3 using a counter. The value of the counter, declared as volatile, is incremented in the ISR and every second the sum is shown in the main loop and the value ...
10
votes
3answers
28k views

Using millis() and micros() inside an interrupt routine

The documentation for attachInterrupt() says: ... millis() relies on interrupts to count, so it will never increment inside an ISR. Since delay() requires interrupts to work, it will not work if ...
4
votes
1answer
214 views

Waking up async the Arduino while it is sleeping periodically

I´m using LowPower.h and PinChangeInt.h libraries to put my Arduino into the sleep mode every 8 seconds and then it wakes up, modifies a counter and it goes to sleep again, but also I need to wake it ...
1
vote
2answers
358 views

Why PJ0 and PJ1 are not reporting as PCINT pins

When the sketch shown at end-of-question is compiled and uploaded to an Arduino board, it is supposed to Serial-print a list of available digital pins, showing for each pin whether it supports PWM or ...
1
vote
2answers
273 views

Attiny85 Timer 1 comparator B doesn't work properly (while A does)

I'm writing a simple program that is using Timer 1 comparator B to generate a square wave on DEBUG_PIN. So my code at first turns on timer 1 with prescaler 8192 so that one tick is approximately 1ms....
21
votes
3answers
5k views

Can a function be called automatically when an input changes?

Currently, my sketch is checking an input pin every time round the main loop. If it detects a change, it calls a custom function to respond to it. Here's the code (trimmed down to the essentials): ...
14
votes
2answers
25k views

How many interrupt pins can an Uno handle?

I am looking at using a 7 channel RC receiver with the Arduino Uno R3. In the documentation, there are mentions of a maximum of 2 interrupt pins, whereas on certain other blogs I have seen mentions of ...
5
votes
2answers
9k views

Why the need to use the volatile keyword on global variables when handling interrupts in Arduino?

I am familiar with the keyword Volatile being used to declare variables that are shared among multiple threads on a software application (basically on a multithreaded application). But why do I need ...
3
votes
1answer
636 views

Setting the frequency of a timer interrupt

The concept: Play a sine wave saved as a character array in PROGMEM through an 8-bit DAC connected to the PORTC pins on the Arduino Mega. This works: // File just defines an array and a size #...
2
votes
2answers
7k views

Why is my interrupt code not working?

Background I'm trying to write code to read signals from a six-channel RC receiver on an Arduino Mega 2560. Currently I am keeping the code to just read one channel to make things easy to ...
6
votes
2answers
487 views

Why is that any sensor signal need to be hooked up to the interrupt pins on Andruino boards?

I have come across some Andruino Sensors like Motion, Light and all recommend to be connected to pin 2 or 3 on Andruino Uno board which are interrupt pins. This is especially true if you are looking ...
3
votes
1answer
9k views

digitalPinToInterrupt() doesn't work

I am working on a protection circuit with 2 raindrop sensors which would be hooked onto the arduinos 2 interrupt pins and as soon as they detect water they shut some relays off, turn a red led on and ...
2
votes
2answers
818 views

Problem with tachometer using attachInterrupt and servo

So I am creating a tachometer using black/white detector sensor. Here's the code. unsigned long WaktuOLD; unsigned long WaktuNOW; int Detection = HIGH; int Counter = HIGH; float HitungWaktu; float ...
2
votes
4answers
4k views

Interrupt fires multiple times

I have a Photo Interrupter which I am using to count the RPM of a motor. I am incrementing an integer to show the amount of interrupts there have been. The issue is that there can be several ...
2
votes
1answer
313 views

Interrupts Problem with Flow sensor

#include <Wire.h> //I2C lib #include <LCD.h> #include <LiquidCrystal_I2C.h> // LCD lib LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); const int pot_pin = A0; const ...
2
votes
1answer
61 views

Cannot set MOSI pin low even after ending SPI

I'm building a battery operated device and must shutoff MOSI pin during sleep because it leaks current through the SD card if I don't (about 400 µA). Problem is, it won't stay off. I've looked at ...
1
vote
0answers
98 views

Interference in readings

I have an project which control a heat exchanger. I read 4 temperature sensors DS18B20, a distance with HC-SR04 Ultrasonic Sensor, and a flow with YF-S201 (with attach interrupt). I can turn on and ...
1
vote
1answer
761 views

Measuring LPO (Low-Pulse Occupancy)

I'm using an Arduino clone (Seeeduino Lotus) together with a Shinyei PPD42NS sensor to measure air quality. The sensor reports its measurement as Low-Pulse occupancy. What would be the best way how to ...
1
vote
1answer
417 views

Timer2 Compare Interrupt not working as expected

To get this out of the way first: I have already looked at "Timer2 does not work as it should" and "Timer2 “Clear OC2B on Compare Match” not working as expected in CTC mode" but have not found the ...
1
vote
1answer
854 views

ISR not working as it is supposed to

For a battery charging project, i am using an ARDUINO UNO which is driving a buck converter to provide the battery with the charging current. I am using external ADCs to measure the battery's charging ...
1
vote
1answer
316 views

Why does enabling TIMSK1 mess up serial?

I am intending to write a code where a user will send lines through serial to affect timer interrupts. I am noticing a problem with serial where as soon as I enable the timer interrupts, the serial ...
0
votes
1answer
620 views

Is PulseIn fast enough for Quadcopter?

I've been trying to use interrupts to control a quadrotor with a tx/rx to no success. I'm using an arduino mega as my control board. I have successfully read a singe channel using attach interrupt and ...
0
votes
3answers
97 views

Can Serial be safely used in an SPI interrupt routine

I have anecdotal experience that using Serial.print inside a slave's SPI interrupt routine (ISR) causes issues with transmission. It also seems that interrupts may be called more than once before the ...
0
votes
1answer
330 views

LCD library and timer2 CTC interrupt not working together

I want to set up real time counter along with lcd functions from LiquidCrystal library. But they don't work together. However, they work fine separately. The code is working by itself, but by ...
0
votes
2answers
5k views

Where is documentation on Arduino's Internal Interrupts?

First time arduino programmer here...however I have programmed the TI MSP430 in the past... I am trying to figure out how to configure internal Interrupt Vectors on this Arduino Uno. In the Arduino ...