Skip to main content

Arduino Basic Tutorials - How to Control LEDs

Picture of Arduino Basic Tutorials - How to Control LEDs
This instructable shows how to control one or more LEDs with Arduino and then we will know how to use the digital and analog IO pins. Never done any work before with Arduino and don't know how to use it. Never mind, you will find that it is really easy to start a Arduino project.

Step 1: Arduino Pin Instruction

Picture of Arduino Pin Instruction
We can refer to this page to get the Arduino Pins instructions.
If you find that it is a little difficult to understand these commands, You can skip this step and only need to know which pins is the Digital Pins(0-13)and Analog Pins(0-5) and then go to next step. After you finish these projects, you will find that these commands is really easy.




Step 2: Materials

The following will be needed
Arduino X 1 We used Crowduino in the following projects and Crowduino is Arduino compatible board with Duemilanove bootloader. Any Arduino compatible board would be ok for finishing these projects.
USB cable x 1
Resisters 200R x10
Resisters 10K x1
LED x5
breadboard x1
Jumper wires
If you don't have these components yet, this component kit may help you. It includes all the components except the Arduino board. This Arduino basic kit can aslo be ok for the following projects and it include one Crowduino and printed guide book for some other projects.
You may need to download one Arduino IDE at the page if you don't have. There are several versions for different Operating System. You can refer to this page to know more.

Step 3: Control One LED

Lighting up one LED is the beginning of Arduino learning. Through this experiment, you will be able to run with Arduino world easier.
Materials used: 
Crowduino x 1
LED x 1
200R resister x 1
USB cable x 1
Jumper wires
Hardware Connection: You can connect the hardware as the upper picture. Note:the long pin of LED is positive and the short pin is negative. If you don’t know how to use the LED, you can get more details by search LED on instructable. There are a lot of great instrutables for LED. Such as LED ThrowiesLEDs for Beginners. and so on.
Program Upload:
Download the Arduino Demo Code. Open the P01_ Control_one_LED.ino with Arduino IDE as below and upload to the Crowduino or Arduino board. If you don't know how to upload the program, you can do one basic experiment following the steps at this page. After uploading the program, you will see that the LED will blink once per second.
It used function pinMode() and digitalWrite() in this program.

Step 4: Control Two LEDs

Is the experiment about lighting one LED really easy. Yes, Let's to go to light up and control two LEDs.
Materials:
Crowduino x 1
LED x 2
200R resister x 2
USB cable x 1
Jumper wire x 4
Hardware Connection: Connect the hardware following the upper picture.
Upload program: Open the Arduino Code P02_Control_two_LED.ino and upload it to Crowduino.
After the programming, the LEDs will blink once per second. You can change the delay() parameter in the program to change the interval. At the same time, you can also change the program to make the two LEDs flash alternately.

Step 5: Control LED with Button

How can light a led when I want it to light? Here we will know how to control a LED to turn on/off with button(you can change the button with other sensor when you are fimiliar with Arduino).
Materials:
  • Crowduino x 1
  • LED x 1
  • 200R resister x 2
  • Button x 1
  • USB cable x 1
  • Jumper wires

Hardware Connection: You can connect the hardware as the upper picture.
Program upload:
open the Arduino Code P03_Button_Control_LED.ino and upload it to Crowduino. When the button is pressed, the LED will turn on. Otherwise, the LED turns off.
In this program, the Arduino reads the status of the button with the functiondigitalRead() and and control the LED with digitalWrite().

Step 6: Read the Analog Value

And now, we know the how to use the 0 and 1 digital signal in Arduino. Here we will know how to input analog signal and display the analog value via serial port.
Materials:
Potentiometer x 1
Crowduino x1
USB cable x1
Jumper wires
Hardware Connection: Connect the hardware as the upper picture.
Upload the Code:
Open the P04_AnalogInOutSerial.ino,and upload it to the Crowduino. Then open the serial monitor, you can see the value printed on the serial port will change with the rotation of Potentiometer in the area 0~1023.
It used function Serial.begin(),Serial.print()Serial.println() , delay() andAnalogread() in the program.

Step 7: Running Light

From the upper projects, we do know how to do some simple project. Let's do a little complex project now. how about making a running LED which the flashing speed is changeable with the rotation of the potentiometer. this project consists of 5 LEDs in different colors and a potentiometer.
Connect the hardward following the upper picture and upload P05_FlashLED.ino code to Crowduino.
The demo result is shown as the upper picture.To get more colorful effects by adjusting the potentiometer.

Comments

Popular posts from this blog

Jio

Reliance Jio planning its own  cryptocurrency called JioCoin  elder son Akash Ambani leading the JioCoin project, Reliance Jio plans to build a 50-member team of young professionals to work on blockchain technology, which can also be used to develop applications such as smart contracts and supply chain management logistics

garbage monitoring using arduino code with gsm

#include <SoftwareSerial.h> #include <LiquidCrystal.h> //LiquidCrystal lcd(7, 6, 5, 4, 3, 2); LiquidCrystal lcd(13, 12, 11, 10, 9, 8); SoftwareSerial mySerial(0,1); #define trigPin 2 #define echoPin 3 #define PIR_sensor 4 #define m11 5 #define m12 6 void setup() {    lcd.begin(16, 2);    lcd.print("    Garbage    ");    Serial.println("garbage ");   lcd.setCursor(0,1);   lcd.print("   Open Close    ");   Serial.println(" open close");   delay(3000);   lcd.clear();   //lcd.print(" ");   delay(2000); mySerial.begin(9600); // Setting the baud rate of GSM Module Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT);  pinMode(m11, OUTPUT);   pinMode(m12, OUTPUT);   } void loop() {  readPIR();  pingDist();  SendMessage(); } void pingDist ()   {     long duration, distance;...