/*
Name: lengthBlinker.ino
Created: 9/28/2017 12:03:23 AM
Updated: 9/29/2017 01:27:33 AM
Author: jeet
This code will make your arduino's led blink according to the length of input you have provided ..
Yes this Code is really small and is written just for fun.
L.....O......L
*/
#define pin 13
// the setup function runs once when you press reset or power the board
void setup() {
pinMode(13, OUTPUT);
Serial.begin(250000);
}
int count = 0;
String str;
// the loop function runs over and over again until power down or reset
void loop() {
str = Serial.readString(); //getting the data from the port
count = str.length();
//finding the length
if (count == 0) {
Serial.println("Please give me some input");
}
else
{
Serial.println(str);
//for loop to execute the blinking for count number of times
for (int i = 0; i < count; i++)
{
digitalWrite(pin, HIGH);
delay(300);
digitalWrite(pin, LOW);
Serial.print("\n blink"); Serial.print(i);
delay(300);
}
delay(500);
Serial.print("Blinked for ");
Serial.print(count);
Serial.print(" Times \n");
delay(500);
}
}
Comments
Please log in or sign up to comment.