For the following program. Compiles and runs. I start the Serial Monitor (shown following code) and it asks me to input the Blink Rate. This runs in setup. Then it enters the loop and prints to the serial monitor the rate and starts the >Serial.println("the bl And it hangs! I can exit the serial monitor and restart it and it does the same thing. So the program/sketch seems to be running fine but somehow the serial communication hangs?
Code:
//Testing the Serial Port
#include <TimerOne.h>
int state = 0;
int value;
long int newtime;
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
digitalWrite(13, state);
Serial.println("Enter the Blink Rate: ");
}
void loop() {
if (Serial.available()) {
value = Serial.parseInt();
Serial.print("the blink rate is: ");
Serial.println(value);
Serial.println("Enter a new blink rate: "); //This is where the serial monitor? hangs The LED does NOT blink
//so is the code hanging here? If so the setup println should not repeat
//when the serial monitor is closed and reopened?
newtime = value * 1000000;
Timer1.initialize(newtime);
Timer1.attachInterrupt(blinkme);
}
}
void blinkme() {
state = !state;
digitalWrite(13, state);
}
Serial Monitor:
Code:
//Testing the Serial Port
#include <TimerOne.h>
int state = 0;
int value;
long int newtime;
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
digitalWrite(13, state);
Serial.println("Enter the Blink Rate: ");
}
void loop() {
if (Serial.available()) {
value = Serial.parseInt();
Serial.print("the blink rate is: ");
Serial.println(value);
Serial.println("Enter a new blink rate: "); //This is where the serial monitor? hangs The LED does NOT blink
//so is the code hanging here? If so the setup println should not repeat
//when the serial monitor is closed and reopened?
newtime = value * 1000000;
Timer1.initialize(newtime);
Timer1.attachInterrupt(blinkme);
}
}
void blinkme() {
state = !state;
digitalWrite(13, state);
}
Serial Monitor: