CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
1
MANY EASY TO SET UP AND
PROGRAM WITH ARDUINO
DUEMILANOVE - UNO – MEGA
THE PROGRAMS I USE ARE
0022—1.0.1—1.0.3-- ARDUINO
AUTOMATION AND WIRING
EXERCISES
I
MANRESA BARCELONA
CATALUNYA
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
2
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
3
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
4
Index
Titel 1
Introduction
Symbols 8
Assembled and programmed exercises
EXERCICI 1: SEQUENTIALS LEDs 10 (Leds secuenciales)
EXERCICI 2: CONTROL OF SEQUENTIAL LEDS WITH A PUSH BUTTON 12 (Control de LEDs secuenciales con un pulsador)
EXERCICI 3: TRAFFIC LIGHTS FLASHING ONLY ONE DIRECTION 14 (Semaforo con intermitente una sola dirección)
EXERCICI 4: PEAPLE SEMAPHORE 16 (Semaforo para peatones)
EXERCICI 5: A PUSHBUTTON SWITCHES ON AND OFF A LED OR A MOTOR1 18 (Un pulsador enciende o apaga un LED o un motor1)
EXERCICI 6: TWO BUTTONS ONE ACTIVATES AN LED OR MOTOR1 AND THE 21
OTHER BUTTON TURNS THEM OFF (dos pulsadores uno activa un LED o motor1 y el otro lo apaga)
EXERCICI 7: A PUSHBUTTON SWITCHES ON OR STARTS TWO LEDS OR MOTORS 24
AND THEN GOES OFF ALONE (Un pulsador enciende o pone en marcha dos LED o motores y despues se apagan solos)
EXERCICI 8: BUTTON LIGHTS UP LED1 OR MOTOR1 - LED2 OR MOTOR2 27
BUTTON TURNS OFF (Pulsador enciende LED1 o Motor1 - LED2 o Motor2 pulsador lo apaga)
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
5
INTRODUCTION
The exercises with the Arduino program are thousands of examples on the internet and are very well
explained.
The exercises we present are divided into two parts:
The programmed industrial electricity, domotica and the electronic or mechatronics.
With respect to the electrical part are almost the same circuits that are used in wiring and automation that
mount the students of middle and higher cycles and the university students who study this branch.
Here we use DC motors, but some of the practical ones are done by the students applied with AC motors
of 400 volts with all the materials that corresponds using the plate Arduino UNO.
In our case the PLC will be the Arduino (several versions) indicated in each exercise and the
corresponding program.
In the photos you see all the materials that are used and some circuits that are assembled by the need of
the exercises.
There are DC motor banks. , Servo motors and many more materials.
MANY OF THESE MATERIALS ARE RECYCLED.
Practices go from less to more we started with a circuit known to take confidence and entering the applied
industrial electricity.
Some exercises are real that are used in practice.
The exercises are well explained with few words with visual information, circuits and diagrams.
Regarding the second part that is the electronic programmed and will be given more information as it
develops.
These exercises are the basis for entering the world of industrial automatism.
I hope these little notes help them to orient themselves in this world that is wonderful interesting and very
commercial.
I thank the people who are always by my side.
Thanks to my PARENTS OLIVIA , JOSÉ AND MY WIFE CARMEN.
Los ejercicios con el programa de Arduino hay miles de ejemplos en internet y están muy bien explicados.
Los ejercicios que presentamos están divididos en dos parte:
La electricidad industrial programada, domótica y la electrónica o mecatrónica.
Con respecto a la parte eléctrica son casi los mismos circuitos que se usan en cableado y automatización que montan los estudiantes de ciclos medios y
superiores y los universitarios que estudian esta rama.
Aquí utilizamos motores de corriente continua, pero algunas practicas echas por los alumnos lo hicieron con motores de corriente alterna de 400 voltios
con todos los materiales que corresponde utilizando la placa Arduino UNO.
En nuetro caso el PLC será el Arduino (varias versiones) indicadas en cada ejercicio y el programa correspondiente.
En las fotos se ven todos los materiales que se usan y algunos circuitos que se montan por la necesidad de los ejercicios.
Hay bancos de motores de CC. , servos motores y muchos materiales más.
MUCHOS DE ESTOS MATERIALES SON RECICLADOS.
Las practicas van de menos a más comenzamos con un circuito conocido para coger confianza y entrando a la electricidad industrial aplicada.
Algunos ejercicios son reales que se usan en la practica.
Los ejercicios estan bien explicados con pocas palabras con información visual, circuitos y diagramas.
Con respecto a la segunda parte que es la electrónica programada ya se les dara mas información conforme se vaya desarrollando.
Estos ejercicios son la base para introducirse en el mundo del automatismo industrial.
Espero que estos pequeños apuntes les ayuden a orientarse en este mundo que es maravilloso interesante y muy comercial.
Agradezco a las personas que siempre están a mi lado.
Gracias a mis PADRES OLIVIA , JOSÉ Y MI ESPOSA CARMEN.
Author JAHC
Engineer: Jordi A. HUIMAN CASTILLO
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
6
SYMBOLS SENSORS ARDUINO
Ultrasonic sensor Water sensor
Temperature and humidity sensor
Color sensor
Transmitter – Receiver sensor
Motion sensor
H – Bridge
Laser sensor
Flame sensor
Humidity sensor
Sensor de sonido analogico
Sensor tracker
Light sensor – LDR
Temperature sensor LM35
Vibrating sensor
Humidity sensor
Sound sensor
Light sensor
Water flow sensor
Hall effect sensor Optical limit sensor
Sensor for camera Rain detector sensor
Alarm sensor Sensor fire detector
Capacitive touch sensor Ultrasonic sensor
Screen module sensor
Smoke sensor
Light sensor
Sharp distance sensor
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
7
Mega programmer LEDs
Push Buttons
UNO programmer
Duemilanove programmer 7 Segment Display
Power
JoyStick Breakout sensor
Microphone sound detection sensor Microphone
Sermomotors
DC Motor
Connectors
Stepper Motor-Bipolar
Rotary Potentiometer
Micro servos
Toggle Switch
Driver L - 293
Transistor
Module Display
Elevator
Robot chassis
Traffic light
Relay of 5Vcc to 240Vac
Car follower of line
USB connector
Car with panel solar
Frames for robot
Coaches
breadboard
Cars I
Dinusaur Cars II
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
8
EXERCICI 1 : SEQUENTIAL LEDs
1 Like this exercise there are many examples on the Internet with various names.
This exercise uses 8 LEDs.
The LEDs are switched on and off sequentially, one LED is lit and then another LED is turned on and
off; And so on.
The lights go from right to left and from left to right.
The LEDs are connected from pin 2 to pin 9.
The on and off time is given to 300ms, you can vary this time can make them faster or slower.
For this controller, the programmer 0022 and UNO the Arduino PLC are used.
You can use any other programmer and PLC.
2 COMPONENTS:
LEDs. Connectors. PLC UNO. Battery. Resistors 220 homs (8).
Como este ejercicio hay muchos ejemplos en internet con nombres variados.
Este ejercicio utiliza 8 LEDs.
Los LEDs se encienden y se apagan secuencialmente , se enciende un LED y se apaga a continuación se enciende otro LED y se apaga; así
susesivamente.
Las luces van de derecha a izquierda y de izquierda a derecha.
Los LEDs estan conectados desde el pin 2 hasat el pin 9.
El tiempo de encendido y apagado se les a dado de 300ms, ustedes pueden variar este tiempo pueden hacerlos más rápidos o más lentos.
Para este jercicio se a utilizado el programador 0022 y el PLC UNO de Arduino.
Ustedes pueden utilizar cualquier otro programador y PLC.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
9
Programmer
// The programmer used is 0022 and PLC is UNO Arduino
int leds[] = { 2,3,4,5,6,7,8,9};// chose pins for the LEDs
int time = 300;// Time of separation light of LEDs
int n = 0; // Accountant
void setup() { //Definition of doors entrance and exits
for(n=0; n < 8; n++){
pinMode( leds[n], OUTPUT);
}
}
void loop(){ // Programmer
for(n=0; n < 8; n++){ //Variaton of variables
digitalWrite(leds[n], HIGH); //The LEDs light up
delay(time);
digitalWrite(leds[n], LOW); //The LEDs turn off
}
for(n = 7; n >= 0; n--){
digitalWrite(leds[n], HIGH);
delay(time);
digitalWrite(leds[n], LOW);
delay(time);
}
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
10
EXERCICI 2 : CONTROL OF SEQUENTIAL LEDS WITH A PUSH BUTTON
1 The sequence is the same as in the first exercise, the difference is that in order for the LEDs to work, the
push-button must be pressed and the LEDs turn on and off according to schedule.
This is the first time a pushbutton is used and it is very important to know how to connect.
Of the connections there are two types, Pull-up (up) and Pull-down (down).
On the Internet there is a lot of information about your theory here just the connections.
For this circuit we will use the Pull-down and thus avoid that the PLC will continuously enter the
electric current.
We are many practices with pushers and switches is what are used in automatons.
2 COMPONENTS:
LEDs. Connectors. PLC UNO. Battery. Push Button. Resistors 220 Homs (8), 10K Homs (1).
Breadboard.
La secuencia es la misma que en el primer ejercicio, la diferencia es que para que funcionen los LEDs se tiene que pulsar el pulsador y los LEDs se
encienden y se apagan de acuerdo a lo programado.
Esta es la primera vez que se utiliza un pulsador y es muy importante saber como se conectan.
De las coneciones hay de dos tipos, Pull-up (hacia arriba) y Pull-down (hacia abajo).
En Internet hay muchísima información sobre su teoria aquí solo aremos las conecciones.
Para este circuito usaremos el Pull-down y así evitaremos que en el PLC le entre en forma continua la corriente electrica.
Aremos muchas practicas con pulsadores y interruptores es lo que se usan en los automatas.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
11
Programmer
// The programmer used is 0022 and PLC is UNO Arduino
int leds[] = { 2,3,4,5,6,7,8,9};// chose pins for the LEDs
int pushButton = 10;
int time = 300;// Time of separation light of LEDs
int n = 0; // Accountant
void setup() { //Definition of doors entrance and exits
for(n=0; n < 8; n++){
pinMode( leds[n], OUTPUT);
}
pinMode(pushButton, INPUT);
}
void call() { //programmer
for(n=0; n < 8; n++){ //Variaton of variables
digitalWrite(leds[n], HIGH); //The LEDs light up
delay(time);
digitalWrite(leds[n], LOW); //The LEDs turn off
delay(time);
for(n = 7; n >= 0; n--){
digitalWrite(leds[n], HIGH);
delay(time);
digitalWrite(leds[n], LOW);
delay(time);
}
}
}
void loop(){ //To call
if(digitalRead(pushButton) == HIGH) {
call();
}
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
12
EXERCICI 3 : TRAFFIC LIGHTS FLASHING ONLY ONE DIRECTION
1 It is a one-way traffic light.
The sequence is red (pin2), orange (pin3), green (pin4), orange, red and so on.
When the power is turned on, the red LED that is fixed for a while lights up and before it starts to
blink, the orange LED lights and so on.
Time can vary you.
It is mounted on a wooden base simulating a traffic light.
2 COMPONENTS:
LEDs (3). Connectors. PLC UNO. Battery. Resistors 220 Homs (3). Breadboard.
Es un semaforo de una sola dirección.
La secuencia es rojo (pin2), naranja (pin3), verde (pin4), naranja, rojo y así susesivamente.
Cuando se conecta la alimentación se enciende el LED rojo que esta fijo un tiempo y antes de apagarse comienza a parpadear, se enciende el LED
naranja y así susesivamente.
El tiempo lo pueden variar ustedes.
Esta montado en una base de madera simulando un semáforo.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
13
Programmer
//traffic light simple with intermitent
// The programmer used 1.0.1 and PLC UNO Arduino
int leds[] ={2,3,4}; //Red, Orange, Green
int time1 =3000;
int time2 = 500;
int n;
void setup() {
for(n = 0; n<3; n++) {
pinMode(leds[n], OUTPUT);
}
}
void loop(){
digitalWrite(leds[0], HIGH);
digitalWrite(leds[1], LOW);
digitalWrite(leds[2], LOW);
delay(time1);
digitalWrite(leds[0], LOW);
delay(time2);
digitalWrite(leds[0], HIGH);
delay(time2);
digitalWrite(leds[0], LOW);
delay(time2);
digitalWrite(leds[0], HIGH);
delay(time2);
digitalWrite(leds[0], LOW);
delay(time2);
digitalWrite(leds[0], HIGH);
delay(time2);
digitalWrite(leds[0], LOW);
digitalWrite(leds[1], HIGH);
digitalWrite(leds[2], LOW);
delay(time2);
digitalWrite(leds[0], LOW);
digitalWrite(leds[1], LOW);
digitalWrite(leds[2], HIGH);
delay(time1);
digitalWrite(leds[0], LOW);
digitalWrite(leds[1], HIGH);
digitalWrite(leds[2], LOW);
delay(time2);
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
14
EXERCICI 4 : PEAPLE SEMAPHORE
1 When the circuit is connected to the power supply the green light is on for cars and the red light for the
people.
When people want to cross the road they have to press the button on each street, and when they do the
green LED of the cars starts to flash indicating that it is going to be powered, when it goes off the
orange LED and the red LED Of the people are still on; When the red LED of the cars lights up the
green LED of the people is turned on for them to pass. After a programmed time the green LED of the
people begins to make intermittent indicating that the time runs out.
The orange LED lights up and then the green LED of the cars and the red LED of the people.
The weather can vary according to your taste.
2 COMPONENTS:
LEDs (5). Connectors. PLC UNO. Battery. Push Button. Resistors 220 Homs (5), 10K Homs (1).
Breadboard.
Cuando el circuito se conecta a la alimentación queda encendido la luz verde para los coches y la luz roja para los peatones.
Cuando los peatone quieren cruzar la carretra tienen que pulsar el pulsador que hay en cada calle, y cuando lo hacen el LED verde de los coches
comienza a hacer intermitente indicando que va a canviar, cuando se apaga se enciende el LED naranja y el LED rojo de los peatones todavia esta
encendido; cuando se enciende el LED rojo de los coches se enciende el LED verde de los peatones para que pasen. Despues de un tiempo programado
el LED verde de los peatones comienza a hacer intermitencias indicando que se acava el tiempo. Se enciende el LED naranja y despues el LED verde
de los coches y el LED rojo de los peatones.
El tiempo lo pueden variar su gusto.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
15
Programmer
//People Semaphore
//PLC UNO, Programmer 1.0.1.
int Red = 2; //choose Pin2
int Orange = 3; //choose Pin3
int Green = 4; //choose Pin4
int StepRed = 5; //Choose Pin5
int StepGreen = 6; //Choose Pin6
int Button = 8; //Choose Pin8
int ButtonState; //study button
void setup(){ //Definitions of doors entrances and exits
pinMode(Red, OUTPUT); //LED output
pinMode(Orange, OUTPUT); //LED output
pinMode(Green, OUTPUT); //LED output
pinMode(StepRed, OUTPUT); //LED output
pinMode(StepGreen, OUTPUT); //LED output
pinMode(Button, INPUT); //Button input
}
void loop(){ //Programmer
do{ //First cycle
ButtonState = digitalRead(Button); //Read the Button
digitalWrite(Green, HIGH);
digitalWrite(StepRed, HIGH);
}
while(ButtonState == LOW); //Button no pressed
for(int n=0; n<3; n++){ //Second cycle
digitalWrite(Green, LOW);
delay(500);
digitalWrite(Green, HIGH);
delay(500);
}
digitalWrite(Green, LOW); //
digitalWrite(Orange, HIGH);
delay(2000);
digitalWrite(Orange, LOW);
digitalWrite(Red, HIGH);
digitalWrite(StepGreen, HIGH);
digitalWrite(StepRed, LOW);
delay(5000);
digitalWrite(StepGreen, LOW);
delay(500);
digitalWrite(StepGreen, HIGH);
delay(500);
digitalWrite(StepGreen, LOW);
delay(500);
digitalWrite(StepGreen, HIGH);
delay(500);
digitalWrite(Orange, HIGH);
delay(500);
digitalWrite(Orange, LOW);
digitalWrite(Red, LOW);
digitalWrite(StepGreen, LOW);
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
16
EXERCICI 5 : A PUSHBUTTON SWITCHES ON AND OFF A LED OR A
MOTOR1
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
17
1 This exercise is to get to know a little more what we can do with a little imagination.
With a single pushbutton, we can turn on and off an LED or a motor1 of current.
We use an L-293B driver for the motor1 that is widely used and well known and there is a lot of
information on the internet.
The program is for both the LED and the motor1, all you have to do is to change the names with which
you want to work.
When the power is connected to the circuit the LED or motor1 are not activated, if we press the
pushbutton these will activate and work as long as one wants; And if we press the same button a second
time, these switches off.
In this circuit we will continue to use the Pull-down that is low consumption or save energy.
The L-293B Driver Connection: The pins 1 and 8 are shorted and connected to the positive side of the
batteries which is 5 volts. Pins 4 and 5 that indicate driver grounding are shorted with pin 2 and
connected to the negative side of the battery.
Pins 3 and 6 of the driver are connected to DC motor 1.
The pin 2 of the Arduino UNO connects to pin 7 of the L-293B driver that gives the direction of the
motor movement.
Connect the ground of the Arduino to the negative part of the batteries.
As a practice you can short out pins 4, 5, and 7 of the L-293B driver and connect pin 2 of the Arduino
to pin 2 of the driver and look in the direction of the motor1.
2 COMPONENTS:
LEDs (1). Connectors. PLC UNO. Programmer 1.0.1. Battery. Push Button. Resistors 220 Homs (1)
10K Homs (1). Breadboard. IC – L293B Driver. Motor CC..
Este ejercicio es para ir conociendo un poco más lo que podemos hacer con un poco de imaginación.
Con un solo pulsador podemos encender y apagar un LED o un Motor1 de corriente cintínua.
Utilizamos un driver L-293B para el motor1 que es muy usado y conocido y hay mucha información en internet.
El progama sirve tanto para el LED como para el motor1, lo único que se tiene que hacer es canviar los nombres con el que se quiera trabajar.
Cuando se conecta la alimentación al circuito el LED o el motor1 no estan activados, si pulsamos el pulsador estos se activan y trabajan todo el tiempo
que uno quiera; y si pulsamos por segunda vez el mismo pulsador estos se apagan.
En este circuito seguiremos utilizando el Pull-down que es de baja consumición o ahorra de energia.
La coneción del Driver L-293B: Se cortocircuitan los pines 1 y 8 y se conectan a la parte positiva de las pilas que es de 5 voltios. Los pines 4 y 5 que
indican coneción a tierra del driver se cortocircuitan con el pin 2 y se conectan a la parte negativa de la pila.
Los pines 3 y 6 del driver se conectan al motor1 de corriente continua.
Del pin 2 del Arduino UNO se conecta al pin 7 del driver L-293B es quien le da la dirección del movimiento del motor.
Conectar el tierra del arduino a la parte negativa de las pilas.
Como practica ustedes pueden cortocircuitar los pines 4, 5, y 7 del driver L-293B y conectar el pin 2 del Arduino al pin 2 del driver y mirar en que
direción va el motor1.
Driver L-293B Pull-down
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
18
Programmer
// PushButton On LED, Motor1, Pushbutton Off LED, Motor1
// PLC UNO, programmer 1.0.1
int PushButton= 4; //Choose pin 4 for pushButton
int Motor1= 2; //Choose pin 2 for LED or Motor1
int StatePushButton= LOW; //State of pushbutton
void setup() { //definitions of doors entrances and exits
pinMode(PushButton, INPUT);
pinMode(Motor1, OUTPUT); //Motor1 or LED OUTPUT
digitalWrite(Motor1, LOW); //Motor1 Off
}
void loop() { //Progammer
while(digitalRead(PushButton)==LOW);
StatePushButton= digitalRead(Motor1);
digitalWrite(Motor1, !StatePushButton); //Motor1 change state
while(digitalRead(PushButton)== HIGH);
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
19
EXERCICI 6 : TWO BUTTONS ONE ACTIVATES AN LED OR MOTOR1
AND THE OTHER BUTTON TURNS THEM OFF
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
20
1 This exercise is another example used in automation and robotics, two pushbuttons are used, the first
one is to lock an LED or to start a motor1 and the second is to turn them off.
We continue using the L293B driver where you can connect the DC motors or stepper motors that we
will use later.
As shown on the next page the program is very small.
The circuit works as follows:
Once the circuit is mounted it is an LED or motor1, it is connected to the power supply; The circuit is
inactive it means that it does not work, you have to press the first button that in our case is in the pin 3
and the LED is turned on or the motor is started up, and these can be turned on with respect to the LED
or in If it is the engine1 as long as you like.
To stop them you have to press the second button that in our exercise is connected to pin 4.
Driver Contention L293B is:
In this circuit we will continue to use the Pull-down that is low consumption or saves energy.
The pins 1 and 8 are short circuited and connected to the positive side of the batteries which is 5 volts.
Pins 4 and 5 that indicate driver grounding are shorted with pin 2 and connected to the negative side of
the battery.
Pins 3 and 6 of the driver are connected to DC motor 1.
The pin 2 of the Arduino UNO connects to pin 7 of the L-293B driver that gives the direction of the
motor movement.
Connect the ground of the Arduino to the negative part of the batteries.
As a practice you can short out pins 4, 5, and 7 of the L-293B driver and connect pin 2 of the Arduino
to pin 2 of the driver and look at which direction is the motor1.
2 COMPONENTS:
LEDs (1). Connectors. PLC UNO. Programmer 0022. Battery. Push Button(2). Resistors 220 Homs(1)
10K Homs (1). Breadboard. IC – L293B Driver. Motor CC..
Este ejercicio es otro de los ejemplos que se usan en automatismo y robótica, se utilizan dos pulsadores el primero es para encerder un LED o poner en
marcha un motor1 y el segundo es para apagarlos.
Se continua utilizando el driver L293B donde se pueden conectar los motores de corriente contínua o motores paso a paso que mas adelante lo
utilizaremos.
Como se ve en la página siguiente el programa es muy pequeño.
El circuito funciona de la siguiente manera:
Una vez montado el circuito sea un LED o motor1, se conecta a la alimentación; el circuito esta inactivo quiere decir que no funciona, se tiene que
pulsar el primer pulsador que en nuestro caso esta en el pin 3 y se enciente el LED o se pone en marcha el motor1, y estos pueden estar encendido con
respecto al LED o en marcha si es el motor1 todo el tiempo que se quiera.
Para paralos se tiene que pulsar el segundo pulsador que en nuestro ejercicio esta conectado en el pin 4.
Coneción del driver L293B es:
En este circuito seguiremos utilizando el Pull-down que es de baja consumición o ahorra de energia.
Se cortocircuitan los pines 1 y 8 y se conectan a la parte positiva de las pilas que es de 5 voltios. Los pines 4 y 5 que indican coneción a tierra del driver
se cortocircuitan con el pin 2 y se conectan a la parte negativa de la pila.
Los pines 3 y 6 del driver se conectan al motor1 de corriente continua.
Del pin 2 del Arduino UNO se conecta al pin 7 del driver L-293B es quien le da la dirección del movimiento del motor.
Conectar el tierra del arduino a la parte negativa de las pilas.
Como practica ustedes pueden cortocircuitar los pines 4, 5, y 7 del driver L-293B y conectar el pin 2 del Arduino al pin 2 del driver y mirar en que
direción va el motor1.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
21
Programmer
//1) PushButton1 On LED or Motor, PusButton2 Off LED or Motor
//It runs the program Arduino 0022 and PLC UNO
#include <AFMotor.h>
int Motor1 = 2; //Choose pin 2 for Motor1
int PushButton1 = 3;//Choose pin 3 On Motor
int PushButton2 = 4;//choose pin 4 Off Motor
void setup(){ //Definition of doors entrances and exits
pinMode(Motor1, OUTPUT);
pinMode(PushButton1, INPUT);
pinMode(PushButton2, INPUT);
}
void loop(){ //Programmer
if(digitalRead(PushButton1) == HIGH){//On LED or Motor
digitalWrite(Motor1, HIGH);
}
else if(digitalRead(PushButton2) == HIGH){//Off LED or Motor
digitalWrite(Motor1, LOW);
}
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
22
EXERCICI 7 : A PUSHBUTTON SWITCHES ON OR STARTS TWO LEDS OR
MOTORS AND THEN GOES OFF ALONE
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
23
1 The exercise is that when the button is pressed the LED1 is activated or the motor
starts1 and after a set time (the time can vary) the first timer turns on the LED2 or
starts the motor2, another time passes and automatically they go out The LEDs or the
motors.
Connections of the elements are seen on the top or bottom page.
Driver Contention L293B is:
In this circuit we will continue to use the Pull-down that is low consumption or saves
energy.
The pins 1, 8, 9 and 16 are short circuited, connected to the positive side of the
batteries which is 5 volts. The pins 4, 5, 12 and 13 that indicate driver earth
connection are short circuited with pin 2 and pin 15, are connected to the negative
part of the battery.
The driver pins 3 and 6 are connected to the motor1 and the pins 11 and 14 to the DC
motor2.
The pins 2 and 3 of the Arduino UNO are connected to pins 7 and 10 of the L-293B
driver that give the direction of movement of the motors.
Connect the ground of the Arduino to the negative part of the batteries.
As a practice you can short out the L-293B pins 4, 5, 7, 10, 12,13 and connect the
Arduino pin 2 and 3 to pin 2 and 15 of the driver and look at which direction the
motor is going. 2 COMPONENTS:
LEDs (2). Connectors. PLC UNO. Programmer 0022. Battery. Push Button(1). Resistors 220 Homs(2)
10K Homs (1). Breadboard. IC – L293B Driver. Motor1 and Motor2 CC..
El ejercico es que cuando se pulsa el pulsador se activa el LED1 o arranca el motor1 y despues de un tiempo programado (el tiempo lo pueden variar)
el primer temporizador enciende el LED2 o arranca el motor2, pasa otro tiempo y en forma automática se apagan los LEDs o los motores.
Las coneciones de los elementos se ven en la página superior o en la inferior.
Coneción del driver L293B es:
En este circuito seguiremos utilizando el Pull-down que es de baja consumición o ahorra de energia.
Se cortocircuitan los pines 1, 8, 9 y 16, se conectan a la parte positiva de las pilas que es de 5 voltios. Los pines 4, 5, 12 y 13 que indican coneción a
tierra del driver se cortocircuitan con el pin 2 y pin 15, se conectan a la parte negativa de la pila.
Los pines 3 y 6 del driver se conectan al motor1 y los pines 11 y 14 al motor2 de corriente continua.
Los pines 2 y 3 del Arduino UNO se conecta a los pines 7 y 10 del driver L-293B son quienes le dan la dirección de movimientos de los motores.
Conectar el tierra del arduino a la parte negativa de las pilas.
Como practica ustedes pueden cortocircuitar los pines 4, 5, 7, 10, 12,13 del driver L-293B y conectar el pin 2 y 3 del Arduino al pin 2 y 15 del driver y
mirar en que direción va el motor1.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
24
Programmer
/* 3) Press the button to switch on an LED or start the first motor, the first timer turns on the second LED
or starts the second motor. A second timer will turn them off
It runs the program arduino and PLC UNO
*/
#include <AFMotor.h>
int Motor1= 2; //Choose pin 2 for Motor1
int Motor2= 3; //Choose pin 3 for Motor2
int pushButton= 4; //Choose pin 4 for pushButton
int StatePush= LOW;
void setup() { //Definitions of doors entrances and exits
pinMode(pushButton, INPUT);
pinMode(Motor1, OUTPUT);
pinMode(Motor2, OUTPUT);
digitalWrite(Motor1, LOW);
digitalWrite(Motor2, LOW);
}
void loop() { //Programmer
while(digitalRead(pushButton)==LOW);
StatePush= digitalRead(Motor1);
digitalWrite(Motor1, !StatePush); //Motor1 ON
StatePush= digitalRead(Motor2);//Motor2 OFF
digitalWrite(Motor2, LOW);
delay(6000); //Timer
digitalWrite(Motor2, HIGH);
digitalWrite(Motor2, !StatePush);
delay(6000);
digitalWrite(Motor1, LOW); //Motor1 OFF
digitalWrite(Motor2, LOW); //Motor2 OFF
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
25
EXERCICI 8 : BUTTON LIGHTS UP LED1 OR MOTOR1 - LED2 OR
MOTOR2 BUTTON TURNS OFF
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
26
1 When the pushbutton is pressed, the LED1 is activated or the motor is started1 and after a set time (the
time may vary), the first timer switches on LED2 or starts motor2, press the button again and the LEDs
or motors are switched off.
Connections of the elements are seen on the top or bottom page.
Driver Contention L293B is:
In this circuit we will continue to use the Pull-down that is low consumption or saves energy.
The pins 1, 8, 9 and 16 are short circuited, connected to the positive side of the batteries which is 5
volts.
The pins 4, 5, 12 and 13 that indicate driver earth connection are short circuited with pin 2 and pin 15,
are connected to the negative part of the battery.
The driver pins 3 and 6 are connected to the motor 1 and the pins 11 and 14 to the DC motor 2.
The pins 2 and 3 of the Arduino UNO are connected to pins 7 and 10 of the L-293B driver that give the
direction of movement of the motors.
Connect the ground of the Arduino to the negative part of the batteries.
As a practice you can short out the L-293B pins 4, 5, 7, 10, 12,13 and connect the Arduino pin 2 and 3
to pin 2 and 15 of the driver and look at which direction the motor is going.
2 COMPONENTS:
LEDs (2). Connectors. PLC UNO. Programmer 0022. Battery. Push Button(1). Resistors 220 Homs(2)
10K Homs (1). Breadboard. IC – L293B Driver. Motor1 and Motor2 CC..
Cuando pulsamos el pulsador se activa el LED1 o arranca el motor1 y despues de un tiempo programado (el tiempo lo pueden variar) el primer
temporizador enciende el LED2 o arranca el motor2, pulsamos otra vez el pulsador y se apagan los LEDs o los motores.
Las coneciones de los elementos se ven en la página superior o en la inferior.
Coneción del driver L293B es:
En este circuito seguiremos utilizando el Pull-down que es de baja consumición o ahorra de energia.
Se cortocircuitan los pines 1, 8, 9 y 16, se conectan a la parte positiva de las pilas que es de 5 voltios. Los pines 4, 5, 12 y 13 que indican coneción a
tierra del driver se cortocircuitan con el pin 2 y pin 15, se conectan a la parte negativa de la pila.
Los pines 3 y 6 del driver se conectan al motor1 y los pines 11 y 14 al motor2 de corriente continua.
Los pines 2 y 3 del Arduino UNO se conecta a los pines 7 y 10 del driver L-293B son quienes le dan la dirección de movimientos de los motores.
Conectar el tierra del arduino a la parte negativa de las pilas.
Como practica ustedes pueden cortocircuitar los pines 4, 5, 7, 10, 12,13 del driver L-293B y conectar el pin 2 y 3 del Arduino al pin 2 y 15 del driver y
mirar en que direción va el motor1.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
27
Programmer
/* 4)Press the button, LED1 or Motor1 will light, timer will light
LED2 or start Motor2 press the button and everything will be off.
programmer 0022 and PLC UNO
*/
#include <AFMotor.h>
int Motor1= 2; //Choose pin 2 for Motor1
int Motor2= 3; //Choose pin 3 for Motor2
int pushButton= 4; //Choose pin 3 for Motor2
int StatePush= LOW;
void setup() { //Definitions of doors entrances and exits
pinMode(pushButton, INPUT);
pinMode(Motor1, OUTPUT);
pinMode(Motor2, OUTPUT);
digitalWrite(Motor1, LOW);
digitalWrite(Motor2, LOW);
}
void loop() { //Program
while(digitalRead(pushButton)==LOW);
StatePush= digitalRead(Motor1);
digitalWrite(Motor1, !StatePush);//Motor1 On
StatePush= digitalRead(Motor2);
digitalWrite(Motor2, LOW);
delay(4000);
digitalWrite(Motor2, HIGH);
digitalWrite(Motor2, !StatePush);//Motor2 On
while(digitalRead(pushButton)== HIGH);//Stop Motor1 and Motor2
}