close
videotogif_2018.05.28_15.46.54

LEDs (Light Emitting Diodesare used in all clever things,so we have included them in this kit. We start with something very simple by repeatedly switching on and off and creating pleasant flashing effect. To get started, grab the parts listed below, pin the layout sheet to your breadboard and then plug everything in.

Hardware Used:

  • 1 – 100 ohms Resistor
  • 1 – LED
  • 1 – Arduino Uno

You can buy all this Hardware at Createlabz.

Software Used:

Arduino IDE

Set-up the Hardware:

 

Code:

Code Breakdown:

If you want to put Comments, Notes you can use (/*) and it should end with (*/)

The difference of (//) and (/*,*/) is that the (//) is used for small comments just like for one line only, and the (/*,*/) is for long comments.

is a declaration to say “that we would like to create a box named ledPin and put the number 13 in that box.” Notice that int indicates that the type of box is an integer. After the declaration, you use ledPin where you had 13 before.

You can choose on whatever Pin you want to assign the led. Digital Pins has (0-13), you can also use Analog Pins (0-5) analog A0 is 14, analog A1 is 15……. Give it a try so that you will see!

any statements in this procedure will be executed once at the beginning of your program, when it is uploaded or when the Arduino wakes up after being reset.

ledPin was assigned as an output, which means that the voltage will be sent to the assign pin in order to control the LED.

any statements in this procedure will be executed over and over again forever, or at least until you turn your Arduino off or upload something new. The statements in this procedure are the core of what you want your Arduino program to do.

Write a HIGH or a LOW value to a digital pin.

If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.

If you do not set the pinMode() to OUTPUT, and connect an LED to a pin, when calling digitalWrite(), the LED may appear dim. Without explicitly setting pinMode(), digitalWrite() will have enabled the internal pull-up resistor, which acts like a large current-limiting resistor.

the number of milliseconds to wait before continuing on to the next line.

1 sec = delay(1000)

Try MORE!!!

Changing the blink time:

In the code change the lines:

Control the brightness:

Change the LED to pin 9:

Replace the code inside the { }’s of loop() with this:

Fading:

Change the LED to pin 9:

Replace all the code in the void loop with this code:

Fade

 

 

Tags : arduinoArduino Kitarduino unoblinkGuideLed

Leave a Response