Intermittent diode with Arduino

Intermittent diode with Arduino

plate-LED

The electronics of the hand of microelectronics and computer science, and fruit of it is this wonder that licks Arduino. We are going to realise diverse projects with her, but previously we are going to see some that explain to us what is Arduino.

Once sights, we will begin with simple tasks as igniting a LED until complex programs but, where only the imagination will put the limits€.

 

What is arduino?

Basic concepts. The plate Arduino ONE

Simulating Arduino online

IDE the programming surroundings

Hello LED: Hello World with Arduino

 

As first practice and to take contact with this wonder from the electronics, we are going to start up a simple task that consists of putting a diode LED of intermittent form.

Important: If we have a Chinese€ arduino, we must lower us the following Driver Corresponding to the Ch341 chip. Once one lowers, we must go to administration of devices and update the controller of usb by which it is enclosed in this compressed file

In the figure that is sample imagines as it is connected next to a resistance of 220 Î©. We remembered that the resistance limit the current passage so that the diode does not spoil.

It is connected to terminal GND (of English ground) that is, the Earth or mass and port 13.

The ports are all those connections that the plate has to communicate with the outside and, like the ports of airplanes (airports), these can be of entrance or exit, that is it can read€ a tension in a port or remove€ a tension by that port.

We will see the Code of the program

First of everything it is to tell him to arduino that port 13 is going to be an exit so that it removes the tension and it can illuminate the LED. This we do it with this instruction:

pinMode (13, OUTPUT);

Once Arduino knows that it is an out port we must tell him that it removes 5 volts or zero (ignited or extinguished). For this task we used these instructions

digitalWrite (13, HIGH);  //In this case is ignited

digitalWrite (13, LOW); //Now is extinguished

When we see the program, all the commentaries that appear with two I sweep inclined (/) or * it indicates that they are commentaries and arduino does not execute it as program. It comes very well to clarify the program.

Between ignition and extinguished we needed an enough time so that a person appreciates the change, therefore the instruction delay () will say to arduino that does not do anything during the milliseconds that the parenthesis indicates.

We will see the complete program

/*
Blink is the program that is going to ignite and to extinguish a diode to us LED. This example is in the program bookstore
*
//Pin 13 is the pin or port that we are going to use. We can prove with pin 12 or the 11
//We will give a name to our pin. We will call star to him, therefore, first it is to call //to pin 13 as star
int star = 13;
//we finished putting ours forward edge of code. We follow
//the routine setup once executes when pressing itself the button resert or to ignite Arduino
void setup () \ {
//Puts port 13 as exit
pinMode (star, OUTPUT);}
//Now comes the routine from bow (loop) that when being called of bow, it is executed time and time again until arduino of the power supply becomes disconnected
void loop () \ {
digitalWrite (star, HIGH);
  //enciente the LED (HIGH is the elevated tension but)
delay (1000);
 //waits for 1000 milliseconds 1 second, that is to say,
digitalWrite (star, LOW);
 //Extinguishes to the LED when putting the exit to zero volts
delay (1000);
  //We waited for another second when being finished the instructions, returns at the home of loop and one becomes to repeat the process
}
Now moment is him for doing 1 practical.
1 Cogemos a diode LED and we welded to the positive (it starts off long) a resistance of 220 Ohms. We connect the short leg to GND and the other ends of the resistance to one of the ports that you want.
2 Copiamos the program arrives indicated and we formed it with the port that we want
3 Conectar Arduino with an USB cable of printer to the computer.
4 Using the Sofware de Arduino, to load the program
5 Comprobamos
Practice 2. Using the previous example, to create a variant that ignites the diode during a brief space of time, for example 100 ms and is dull during 1 second. Later, to add the necessary lines so that it blinks twice and soon rests during 1 second, imitating the beat of the heart.
Practice 3.Sem¡foro Veremos now as designing a system that ignites three diodes of correlative form, that is to say, 1 led1, soon goes out led1 and led2 ignites, later goes out led2 and led3 ignites and to finish the cycle, led3 goes out and led1 ignites again and so on.
4 Alarm (Simulator of presence)
 Now we are going to simulate the human presence in a house, being activated 4 elements (for example, 4 lights) in three strips (tomorrow, behind schedule and night). This project can be extended much and all suggestion is welcome. The conditions are
  1. In the morning those elements are due to activate that are susceptible to be ignitions, for example, one radio.
  2. In the afternoons, some lamps and another electric home appliance as a TV can be activated
  3. At night, mainly light bulbs must ignite.

Within the margin of time of every period, it is necessary to take a sequence determined in ignition and extinguished of elements. Supposition that the morning lasts 60 seconds, afternoon 50 and night 70.

4,1 developed Alarm but. I am going to you to put an example of a system that activates a light bulb of random form so that the thief€ does not understand that there is a routine in the house.  The program that there is to enter tinkercad.com is the following one:

long to randNumber;

void setup ()

\ {Serial.begin (9600); //We put the port active series

/*Para to avoid that noise by analogical entrance 0 is generated, we must put the instruction randomSeed () to 0. For it, the first instruction must be:

*
randomSeed (analogRead (0));
}

void loop () \ {
//We are going to remove by port series the value to see it
to randNumber = random (300);
Serial.println (to randNumber);

if (to randNumber > 120) digitalWrite (12, HIGH);
else digitalWrite (12, LOW);
delay (2000);}

Not to forget to put a LED in port 12.

We verify that when the random number is greater of 120, the diode activates and on the contrary (else) it remains dull.

This can come to us very well to practice 4. How you can incorporate it?

Materials to buy:
In order to do the following practical ones it is necessary to buy in the Web banggood (it seems that it has better prices), dealextreme or similars the following components.
a) The chassis of the car. Search it as (Smart Car Chassis)
b) Measurer by ultrasounds (Ultrasonic Module HC-SR04)
c) The plate of Arduino Uno
d) Diodes LED of 5mm (10 leave on the Euro)
e) Relays to control the motors (4 Channel Relay)
But Practical: