So, I'm writing a thing I want to use to monitor incoming messages (yes, terribly exciting, I know!) Problem is, when I hit the button (which is hooked up to an interrupt that runs a function designed to shut off the LEDs) it just temporarily interrupts the blinking. What's going on here?
const int ledPinSkype = 8;
const int ledPinIRC = 4;
const int swiPinIRQ = 0;
const int blkFrq = 100;
int signal;
long blinkers = 0;
void setup() {
Serial.begin(9600);
pinMode(ledPinSkype, OUTPUT);
pinMode(ledPinIRC, OUTPUT);
pinMode(swiPinIRQ, INPUT);
attachInterrupt(swiPinIRQ, resetBlink, RISING);
}
void loop() {
SerialMonitor();
}
void SerialMonitor() { // if there's something from the serial, blink the appropriate lights
int incoming = 0;
if (Serial.available() > 0) {
incoming = Serial.read();
Serial.println(incoming);
blinkLight(incoming);
}
}
void blinkLight(int signal) { // controls the blinking of the lights
if (signal == 48) {
while (blinkers < 10000){
digitalWrite(ledPinSkype, HIGH);
delay(blkFrq);
digitalWrite(ledPinSkype, LOW);
delay(blkFrq);
blinkers++;
}
}
if (signal == 49) {
while (blinkers < 10000) {
digitalWrite(ledPinIRC, HIGH);
delay(blkFrq);
digitalWrite(ledPinIRC, LOW);
delay(blkFrq);
}
}
}
void resetBlink() { // this SHOULD be resetting the blinking. Right now, it just... temporarily interrupts it. Harhar.
digitalWrite(ledPinSkype, LOW);
digitalWrite(ledPinIRC, LOW);
Serial.end();
Serial.begin(9600);
loop();
}
Any help would be appreciated!