Arduino Beginner Series: Project 5: Using Serial Monitor to tell LED the number of times it has to blink

Hello everyone!! Welcome to this post on Arduino Projects!!
Need a short introduction to what the Arduino is then click on LINK
Check out the breadboard intro right HERE

So here we’ll start with using Serial monitor to tell LED the number of times it has to blink

Demo:

Here is what my project looks like:

Things Required:

  1. Arduino UNO
  2. USB AB cable
  3. LED (any color)
  4. Breadboard
  5. 220 ohm resistor
  6. Arduino IDE on computer
  7. jumper wires

Functions used:

  1. digitalWrite()
  2. delay()

Video Tutorial:

Here’s the video I used for reference: (LINK)

Code:

String msg="How many blinks?";
int blinks;
int led=8;
int dt=500;


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(led, OUTPUT);
}


void loop() {
  // put your main code here, to run repeatedly:
  Serial.println(msg);
  while(Serial.available()==0){
    
  }
  blinks=Serial.parseInt();

  for(int i=1; i<=blinks; i++){
    digitalWrite(led, HIGH);
    delay(dt);
    digitalWrite(led, LOW);
    delay(dt);
  }
  

}

Stay Tuned for upcoming posts on Arduino Projects! We’re on the basic newbie projects right now and slowly, gradually move on to those cool, ultra techy projects!! Want to be the first to know when a new and amazing post comes up?? Then feel free to subscribe!

Happy Learning!!

Leave a Reply

PHP JS HTML CSS BASH PYTHON CODE

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: