Stack Exchange Network

Stack Exchange network consists of 174 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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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

2
votes
3answers
59 views

Is the strange problem I'm having to do with comparing floats?

I have a timer interrupt that controls a stepper motor, on an UNO board. In the interrupt handler it checks the speed of the motor and compares it to the target speed. This allows the motor to ...
1
vote
1answer
64 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 ...
3
votes
1answer
37 views

Timer interrupt triggers too often

The following question is based on the Arduino Pro Mini (8MHz, 3.3V) I'm in process of developing (yet another) LED strip driver shield. For that I wrote a simple control loop, that adjusts the ...
0
votes
0answers
43 views

Can I manually turn on and off the interrupt timers?

Can I manually control(on and off) the interrupt timers of an Atmega328p chip with a push button? If yes, can it be used in compare match mode or input capture? if someone post some examples then it ...
0
votes
1answer
43 views

ESP8266 Arduino and Rotary Encoder

I'm trying to use the sketch bellow to work with my WeMos D1 mini (ESP8266 Arduino platform) together with Rotary Encoder KY-040 or MJKDZ, and it's not working for some reason, but the same sketch is ...
1
vote
2answers
44 views

Attach Interrupt with Library

I am trying to make a library for Arduino, which requires an interruption, but the problem is that when I try the attachInterrupt function inside my library, there's a problem about attachInterrupt is ...
0
votes
1answer
29 views

Unable to send SMS from interrupt routine

I am trying to develop a burglar alert system. I am using PIR sensor, Arduino Mega and SIM800L. I have connected PIR sensor to interrupt pin. Whenever motion is dected, a function corresponding to the ...
0
votes
0answers
32 views

Simple Timer1 PWM + Interrupt Routine

At the moment I am experimenting with interrupts. With the Arduino Uno I am trying to generate a PWM Signal with the FastPWM (8-bit) Mode (Timer1). void setup() { pinMode(9,OUTPUT); pinMode(10,OUTPUT)...
4
votes
2answers
61 views

Interrupts: use of the “volatile” keyword with a structure pointer for button debounce

I've written a small sketch targeted at the Arduino Uno (ATmega328P) to debounce a mechanical pushbutton using the summing/integration technique: #include <IntegratingDebounce.h> #define ...
0
votes
2answers
49 views

Is there any version of arduino that can do something like serial interruption?

I am using an Arduino to control servo MX18A by serial, and trying to use computer to communicate with the Arduino by another serial to send commands to Arduino and change the servo control mode. Once ...
1
vote
1answer
23 views

Timer frequency calculation for UNO/Atmega328

I must be overwrought or something... I just can't get the calculation of the timer frequency right. I have a 16 MHz crystal on the Atmega328. I want 1 kHz timer interrupt rate. So I chose prescaler = ...
0
votes
1answer
35 views

Where can I find the code for Arduino's “attachInterrupt”?

Where can I find the code for Arduino's attachInterrupt function? A search on the Arduino's Github repo yielded nothing. I suspect it might be a wrapper for some avr-libc function but nothing in the ...
0
votes
0answers
50 views

what is the max frequency of external interrupt for esp8266 arduino?

i am using esp7 with AttachInterrupt() (Arduino) to count incremental encoder. I need to know what is the maximum frequency of pulses that esp7 can acquire. also, need to know what frequency atmega328 ...
0
votes
0answers
64 views

Pause and resume stepper motor using interrupt of arduino uno

I'm rotating motor using a limit switch and rotary switch. In addition, I added 2 buttons, one for stop and another for starting from the last position with different speeds and steps. Can anyone ...
0
votes
0answers
24 views

A32U4 (Pololu ASTAR ) trying to use Analog comparator -> interrupt

Sensor signal is ~0.5V (high). Need to get this detected as interrupt, timing is essential in this case. I found this library, so I dont have to start bit masking those registers (lazy, yes indeed) #...
0
votes
1answer
48 views

Float magnet switch interrupts atmega328p and RN2483 sends data

It was so easy to my mind but it is really not. I have a float switch which goes high when water is floating. So I connect the switch to INT0 pin of MCU. So when water is not floating everything is OK....
1
vote
1answer
51 views

How to add additional millisecond delay to microsecond delay generator

I am trying to make a delay generator. I already found an excellent example in Generating a short pulse after a delay that works in the range from ~5-32767 microseconds (it is limited by a 16 bit ...
1
vote
1answer
61 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
39 views

TimerOne Library - Response time

I'm trying to write a library for (rather slow) communication with visible light and have recently tried to include the TimerOne library as a timer. I want to send bits at 2kHz, so with a period of ...
0
votes
1answer
27 views

LiquidCrystal library and timers don't seem to be compatible

If I set timer2 to Compare Match mode, my LCD display stops working. If I use Overflow Interrupt it works fine. Here's my test code. I have a loop() function which does its thing, and a timer ...
0
votes
1answer
40 views

atmega88 timer2 32.768KHz and Serial problem

I am trying to use atmega88 timer2 with a 32.768KHz crystal. I'm using a slightly modified version of Nick Gammon's code. I am using Minicore. No bootloader, 1MHz clock from internal oscillator, BOD ...
0
votes
1answer
53 views

generate two phase-shifted PWM pulses triggered by frequency-divided external signal with Arduino uno?

I have a 4kHz pulse as trigger and I need two phase-shifted PWM output with divided frequency from arduino uno. Now I've managed one PWM output using the following code: int cnt = 0; void setup() { ...
0
votes
0answers
25 views

StepperLab3 library and Liquidcrystal

I want to control a stepper while displaying user menus on a freetronics style 16x2 LCD. I'm using liquidcrystal for my menus and in order to get non-blocking control of the stepper I've imported the ...
1
vote
3answers
76 views

Using attachInterrupt() to make a reset button for my code?

I have used attachInterrupt() to reset my program to the beginning. It actually interrupts while running the 3 states as shown below inside of the if statement but when I press the actual button it ...
0
votes
0answers
67 views

limit switch and external interrupt

The INT0 pin of a custom Arduino-like board based on Atmega16 is configured in INPUT_PULLUP mode and connected to a N.O contact of a limit switch, the other end of the switch is connected to GND. in ...
0
votes
1answer
41 views

attiny85: ISR not triggering for PCINT2?

I am using an attiny85 to read the fan speed reported by a pair of 4-wire fans. I had planned to attach the TACH output from the fans to pins 1 and 2, but I ran into a problem: I was able to handle ...
1
vote
1answer
119 views

how long should interrupting signal last?

I want to apply the interruption of a program with a RISING signal from a pin. How long should the signal rise to be considered as the interruption?
1
vote
2answers
32 views

Strage delay needed after Serial.read()

I'm using a RedBear Duo to read the Serial writes from a RedBear Nano v2. Basically, I use a digital pin of the Duo to raise an interrupt on the Nano. Once, the nano catches the interrupt it writes on ...
0
votes
2answers
138 views

interrupt pin of attiny85 unstable

I'm trying to learn how to program a MC, so maybe I didn't know much about a MC. I tried to test interrupt pin of ATtiny85 with this simple code #include <avr/io.h> #include <avr/interrupt.h&...
0
votes
1answer
35 views

trouble getting out of a for loop in a function and go back to a FSM with a button

I have a finite state machine that goes to a function called patternOne, I can't seam to get out of this function though once I am in it and get back to the finite state machine. When I press a button ...
0
votes
0answers
15 views

How use an interrupt function defined inside a class [duplicate]

I want to define only one interrupt function inside a class and then initialize this class with pin number. This is the Arduino sketch: #include <EnableInterrupt.h> class PinTouch { int pin;...
1
vote
1answer
109 views

Timer0 overflow interrupt not working

I try to use the Timer0 of an Arduino Leonardo (ATmega32u) to trigger an interrupt at regular intervals, using plain avr-gcc (not the arduino library). I try to blink the built-in LED as test, but it ...
1
vote
1answer
40 views

How to stop a loop when using attachInterrupt to catch the change of a button

This what the program does: There is 1 button to start/stop the engine, when the motor is running the green LED will go on, when stopped the red LED is on. The second button is used to change ...
2
votes
3answers
502 views

Can I generate 5 sec delay within an interrupt program?

void buttonPressed() { if(ledOn) { ledOn = false; digitalWrite(13,LOW); }else { ledOn = true; digitalWrite(13,HIGH); } vout=analogRead(sensor); vout=(vout*500)/1023; ...
4
votes
1answer
98 views

Interrupt fires a random number of multiple times for one pulse

This is my first time posting on this forum. I have tried to format this question properly, but let me know if I need to correct anything. I searched to see if someone else had a similar problem, but ...
0
votes
1answer
1k views

MEGA I2C and interrupts on 0,1

Looking at the pinout for the Arduino MEGA: I see that Pins 20 and 21 can be both SDA and SCL or Interrupts 0 and 1. If I'm using an Adafruit I2C 16x2 RGB LCD Shield connected to the SDA and SCL ...
0
votes
0answers
37 views

Baud rate dependency

I am currently trying to write (obtain) a code for getting raw acceleration values and yaw, pitch and roll angles using these Jeff Rowberg's examples. I have used MPU6050_DMP example to get this code: ...
0
votes
0answers
29 views

Timer Interrupt Default Settings

so I am testing out the PulseSensor code from here: https://github.com/WorldFamousElectronics/PulseSensorAmped_2_Sensors/tree/master/PulseSensorAmped_2_Sensors_1.5.0 In the interrupt.ino file, there ...
0
votes
2answers
260 views

Sleep power down mode with change interrupt

I want to use to use an IR sensor as an interrupt to wake up my Arduino Uno R3 from the deep sleep power mode and then go back to sleep after changing the state of the relay. Lets say if I press a ...
2
votes
1answer
201 views

How to set the sampling frequency in Arduino without using a delay

I am reading an ECG signal using a single lead heart rate monitor. What I know is that when I use delay(15) it means that I am getting 66.67 readings in a second which corresponds to the sampling ...
0
votes
1answer
66 views

What is better approach for non blocking pid algorithm?

I'm developing software side for 3 axes robot where are 360° continuous rotating servos used Documentation here these servos have its own feedback system so it's possible to control it's position ...
3
votes
1answer
158 views

How to delay properly inside ISR

I am currently working on a little code which needs to react fast. Here is what I am trying to accomplish: Using a sine wave phase detector I am detecting every zero crossing and feeding that pulse ...
1
vote
1answer
58 views

How to know the external interrupt origin from the ISR

I'd like to know if there is any way to know what is the origin of an external interrupt by programming inside the ISR. I know I can use a different ISR for each external interrupt and that works but ...
1
vote
1answer
24 views

other interrupts in rc channel reader

I have the sketch from James Waldby (Read RC receiver channels using Interrupt instead of PulseIn) working beautifully. I want to use a switch on my TX to start and stop a sequence of lights (...
0
votes
1answer
101 views

Trigger external interrupt on Arduino Uno R3 with an LED and a button

I want to cause the external interrupt on digital pin 2 (PD2 on ATmega328). I have chosen any logic change mode. Here is my code: void setup() { DDRD &= ~( 1 << DDD2 );//PD2 on input ...
0
votes
1answer
147 views

Interrupt crashes code when implemented

I've got a mini weather-station with a Davis Anemometer Vantage Pro that uses a reed switch to detect rotations. Using the rotations it then can convert to MPH. When using it alone, I have no problem ...
0
votes
1answer
53 views

Propane injection software compiles, uploads, doesn't work

Looking for some help here. I have written out some code to add propane injection for my forklift. It is supposed to read three analog inputs, add them together and multiply the sum by three. There is ...
0
votes
1answer
83 views

I2C Interrupting Loop? [closed]

Imagine i have a code, that loops, and at one point there is i2c request. Is loop() paused right away when there is Wire.onReceive() or loop is finished then Wire.onReceive() is called?
1
vote
1answer
135 views

Why my ISR is giving impossible values?

I have a very simple ISR: const uint32_t PATTERN_A = 0xFF00FF00; const uint32_t PATTERN_B = 0x00FF00FF; volatile uint32_t count = 0; volatile uint32_t toggle = PATTERN_A; // My ISR void callback(...
0
votes
1answer
921 views

RPM measurement using quadrature encoder

I am trying to build a RPM controller for my project. I am using a quadrature encoder (ppr=400) and Arduino Uno for this purpose. I am using the code given below inorder to caluculate the RPM of the ...