I'm trying to create an ISR which operates for 15 seconds when a particular button is pressed. I'm attempting to use the AVR functions on my Arduino Uno to start counting when it enters the ISR, then quit the loop when it reaches 15 seconds.
I'm having difficulty reasoning out where the counter is actually stored that I want to use for my while loop.
Here is my code so far:
#define button_pin 2
#define duration 15
#define osc_in 0
#include <avr/io.h>
#include <avr/interrupt.h>
const float convert = 5.0/1023.0;
void setup() {
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
attachInterrupt(digitalPinToInterrupt(button_pin), button_interrupt, CHANGE);
sei();
pinMode(button_pin, INPUT);
Serial.begin(9600);
}
void loop() {
//int channel1 = analogRead(osc_in);
//while (millis() < 10000)
//Serial.println(millis());
//Serial.println(channel1 * convert);
//channel2 = channel1;
}
void button_interrupt(){
//(# timer counts + 1) = (target time) / (timer resolution)
//int timer_counts = duration/(pow(6.4, -5));
//int dur = 234374;
OCR1A = 234374;
TCCR1B |= (1 << CS10);
while (????????){
int channel1 = analogRead(osc_in);
Serial.println(channel1 * convert);
}
}