float blinks;
int dt=200;
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600); // Initialize serial communication at 9600 baud rate
Serial.println("Enter Number of blinks: "); // Prompt for the first time
}
void loop() {
// Check if there is any data available to read
if (Serial.available() > 0) {
String input = Serial.readStringUntil('\n'); // Read the input until a newline character
blinks = input.toFloat(); // Convert the input string to an integer
for(int i=0;i<blinks;i++)
{
digitalWrite(13, HIGH);
delay(dt);
digitalWrite(13, LOW);
delay(dt);
}
Serial.print("We have blinked LED for ");
Serial.print(blinks);// Print the received number
Serial.println(" number of times");
Serial.println("Enter your Number: "); // Prompt for the next number
}
}
// int mynum;
// void setup() {
// // put your setup code here, to run once:
// Serial.begin(9600);
// }
// void loop() {
// // put your main code here, to run repeatedly:
// Serial.println("Enter your Number: ");
// while(Serial.available()==0){
// }
// mynum=Serial.parseInt();
// Serial.print("Your Number is ");
// Serial.println(mynum);
// }
//int mynum;
// void setup() {
// Serial.begin(9600); // Initialize serial communication at 9600 baud rate
// Serial.println("Enter your Number: "); // Prompt for the first time
// }
// void loop() {
// // Check if there is any data available to read
// if (Serial.available() > 0) {
// mynum = Serial.parseInt(); // Read the incoming number
// Serial.print("Your Number is ");
// Serial.println(mynum); // Print the received number
// Serial.println("Enter your Number: "); // Prompt for the next number
// }
// }