Skip to main content

Arduino Beginner Experiments: The Blink!!!

HELLO THERE!!!!

     What a beautiful day today, I hope anybody reading this article is fine and happy always. I would like to share one of the most simple experiments that I actually did while tinkering with arduino. The main aim of this experiment will be to:

1. Familiarize with the Arduino IDE environment
2. To light up an LED by coding in Arduino

Ok, now lets go to the hardwares/softwares needed for this experiment.

Hardware:

1. Arduino UNO
2. LED
3. Resistor (330 ohms should be fine)


The LED and the resistor is optional. This is because the Arduino has a LED at pin 13 which can be used in this experiment.















Software:

1.Arduino IDE

You can download the IDE here: https://www.arduino.cc/en/Main/Software



 Alright, now that the hardware and software requirements are done, let's go to the circuit assembly. If you do not have any LED and resistor, just plug in the arduino into your computer/laptop.There is a LED right off the pin 13 if you see closely labeled L. We'll use it to blink in this experiment. If you are using the LED and resistor, the image below visualizes the assembly of the circuit:

The Arduino blink circuit. The circuit was made using fritzing. Go ahead and try download it, it will come in handy for circuit building 

Precaution: Inverting the polarity of the LED may burn the LED. Long leg goes to the output pin while the short leg goes to the GND.



       Now for the code. You can find the arduino blink code easily on the web. I'll also post the code here with explanation. Before that, lets see the blank arduino IDE sketch:


You can see the blank sketch on the image left. It has few things in it, mainly the void setup and the void loop. Ok before we write the code, we need to need where and when to write the code.

1. All variable initialization will go before the void setup. For an example, in this experiment, we are using a LED in pin 13 of arduino. To initialize it, we will write this before void setup:

    int LED = 13;

the name LED can be customized according to your preference. The number 13 represents the position of the LED on the Arduino board. If you use pin 12, then, the number will be 12 and so on.


    Next, the void setup. This is where you initialize your input and output of the program. In this case, our LED is going to be our output. So we need to write this in our void setup:

pinMode(LED, OUTPUT);

The line above is shows that the mode of the LED pin (which is pin 13) is going to be output.

      Next, void loop. This is where all the "magic" happens. This is where you will write the process of the program. In our experiment, we want our LED on and off with the time delay of 5 seconds. So in void loop we will write this:

digitalWrite (LED,  HIGH);
delay(5000);
digitalWrite(LED, LOW);
delay(5000);
       
Ok, the first line of the code turns on the LED. The second line of the code gives delay for about 5 seconds. This means that the LED will be turned on for about 5 seconds. The third line turns off the LED while the fourth line gives delay for about 5 seconds.  The LED will turn on for five seconds and turn off for five seconds and on and off again. You can try decreasing the delay to 1000(1 second), 500(0.5 second) and other values to see what happens.


Now that the code is completed, compile, save and upload the code to the Arduino board and see the LED turns on and off according to the written code. It is that simple!!! For next experiment, I might show on how to turn on and off multiple LED's by using arduino. Until then, I hope you guys could take benefit from this experiment and have fun!!!













Comments

Popular posts from this blog

Arduino and Multi Function Shield: Pots,LEDs and buzzers

HELLO THERE!!!!!    How are you guys? I hope everyone is fine and in good mood always. This week, I continue my tinkerings with the Multi Function Shield. In this experiment, I used the potentiometer in the shield to control the LEDs in the shield. Without further wasting time, let's jump in straight to the experiment!! HARDWARE 1.ARDUINO UNO  2.MULTI-FUNCTION SHIELD SOFTWARE: 1. ARDUINO IDE CIRCUIT ASSEMBLY    The circuit assembly is fairly simple. Just attach the multi function shield on top of Arduino properly. Please attach the shield properly as failure to do so would cause the shield  not to function as intended. CODING THE ARDUINO: Let's refer to the multi-function shield image below: Referring to the image of the shield, it can be seen that the potentiometer (blue object near buttons) is connected to pin A0 (analog 0)     int pot = A0; //declaring the pot and led pins int l1 = 13; int l2

Arduino Beginner Experiments: Arduino and Light Blocking Sensor

HELLO THERE!!!     How are you guys? I hope everyone is fine and in a good mood always. This week, I would like to share with you guys my experiment on Arduino and Light Blocking Sensor. The objective of this experiment is to receive feedback from the sensor ( Digital and Analog) What is Light Blocking Sensor?      A linear hall sensor is a type of sensor which responds when the sensor is blocked out from light. The sensor is different for LDR's as LDR's responds to the amount of light it received while the light blocking sensor responds if the light is blocked out or not from the sensor.It can be used for both digital and analog measurements. HARDWARE: 1.Arduino UNO 2. Light Blocking Sensor SOFTWARE: 1.Arduino IDE CIRCUIT ASSEMBLY   Let's refer to the image of the blocking sensor below: The Connection of the Sensor to the Arduino is shown below: SENSOR  ----->       ARDUINO Signal      ------>     Any Analog/Digital pin

Arduino Tinkering : Controlling multiple LED with multiple potentiometers

HELLO THERE!!!!            How are you guys? I hope everyone is fine and well always. For this week's post, I would like to share with you guys a simple tinkering on Arduino, LED, and potentiometers. The objective of the experiment is to light up different amount of LED's with different intensity by controlling two potentiometers. Before starting, of course, we need to know what items are needed. The items needed are: 1. Arduino UNO   2. 4 to 5 LEDs 3. 2 Potentiometers The software used in this experiment is: 1. Arduino IDE. Now that all the hardware and software are obtained, let's go to the schematics of the circuit. The circuit is quite simple actually. The long legs of the LED's were connected to PWM pins while the shorter legs were connected to ground. The potentiometers however have three legs. The middle leg is connected to the analog pins (A0, A1) while the other two legs were connected to 5V and GND respectively. Don't w