catalonia-spain - ningapi.ning.com/files/r585xy1-ccby9qcj226q05... · los ejercicios con el...
TRANSCRIPT
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
II
MANRESA BARCELONA
CATALUNYA
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
2
Index
Titel 1
Introduction
Symbols 8
Assembled and programmed exercises
EXERCICI 9: A SINGLE BUTTON STARTS AND STOPS TWO MOTORS 30 (Un solo pulor arranca y para dos motores)
EXERCICI 10: INTERMITTENT MOTORS 32 (Motores intermitentes)
EXERCICI 11: INDUSTRIAL GARAGE DOORS 34 (Puertas de garage industrial)
EXERCICI 12: WRITE ON A 7 SEGMENT DISPLAY A.C. 36 (Escribir en un display A.C. de 7 segmentos)
EXERCICI 13: LIQUID CRYSTAL OLIVIA “LCD” 39 (LCD OLIVIA)
EXERCICI 14: AUTOMATIC BLINDS WITH MANUAL KEY 41 (Persianas automaticas-manual con llave)
EXERCICI 15: CRANE CONTROL MANUALLY I 43 (Control de grua manual)
EXERCICI 16: CRANE CONTROL AUTOMATIC II 45 (Control de grua automática)
EXERCICI 17: CONTROL LIGHTING AND EXTRACTION OF A BATH 47 (Controlar la iluminación y la extracción de un baño)
EXERCICI 18: ESCALATOR IN ONE DIRECTION 48 (Escalera mecánica una dirección)
EXERCICI 19: AUTOMATIC STAIRCASE IN TWO DIRECTIONS 50 (Escalera automatica en dos direciones)
EXERCICI 20: AUTOMATIC FILLING OF A TANK WITH TWO PUMPS 52 (Llenado automatico de un tanque con dos bombas)
EXERCICI 21: AUTOMATIC DOOR OF A SUPERMERCAT 54 (Puerta doble automatica de un sepermercado)
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
3
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
.
4
EXERCICI 9 : A SINGLE BUTTON STARTS AND STOPS TWO MOTORS
1 This exercise is very practiced by the students who study training cycles and the University of the area
of Electricity and Electronics.
With a single button you have to start two motors and stop them.
When the button is pressed for the first time, it starts motor1, it is pressed for a second time the button
starts motor2 and if it is pressed for the third time the button stops the motors.
The circuit connection is explained in Exercises 7 and 8.
2 COMPONENTS:
Connectors. PLC UNO. Programmer 0022. Battery. Push Button(1). Resistors 220 Homs(2)
10K Homs (1). Breadboard. IC – L293B Driver. Motor1 and Motor2 CC.. Este ejercicio es muy practicado por los alumnos que esdudian ciclos formativos y los Universitarios del area de Electricidad y Electrónica.
Con un solo pulsador se tiene que arrancar dos motores y pararlos.
Cuando se pulsa por primera vez el pulsador arranca motor1, se pulsa por segunda vez el pulsador arranca motor2 y si se pulsa por tercera vez el
pulsador se paran los motores.
La conecció del circuito estan explicados en los ejercicios 7 y 8.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
5
Programmer
//First pressed stars Motor1, Second pressed stars Motor2
//Third pulsed stopped engines. PLC UNO. Program 0022
#include <AFMotor.h>
int Motor1=2;//Choose pin 2
int Motor2=3;//Choose pin 3
int PushButton=4;//Choose pin 4
int n=2;//Counter
boolean y= true; //State Y
void setup() { //Definitions of doors entrances and exits
pinMode(Motor1, OUTPUT);
pinMode(Motor2, OUTPUT);
pinMode(PushButton, INPUT);
}
void loop(){ //program
//condition of the pushButton
if (digitalRead(PushButton)==HIGH && y==false){
n++;
y = true;
delay(30);
}
else if (digitalRead(PushButton)!=HIGH) {
y = false;
delay(30);
}
if ( n > 2){n=0;}
switch(n){
case 0:
digitalWrite(Motor1, HIGH); //Motor1 On
break;
case 1:
digitalWrite(Motor2, HIGH); //Motor2 On
break;
case 2:
digitalWrite(Motor1, LOW); //Motor1 Stop
digitalWrite(Motor2, LOW); //Motor2 stop
break;
}
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
6
EXERCICI 10 : INTERMITTENT MOTORS
1 It is another of the exercises that program and assemble students of electricity and electronics.
Functioning:
When the button is pressed for the first time, Motor1 starts a time (the time may vary), then the Motor2
is stopped and started and so on.
This type of operation in the industry is widely used.
To stop the motors, press the button again.
The connection of the motors with the L-293B driver is explained in section 9.
2 COMPONENTS:
Connectors. PLC UNO. Programmer 0022. Battery. Push Button(1). Resistors 220 Homs(2)
10K Homs (1). Breadboard. IC – L293B Driver. Motor1 and Motor2 CC.. Es otro de los ejercicios que programan y montan los alumnos de electricidad y elctrónica.
Funcionamiento:
Cuando se pulsa por primera vez el pulsador arranca Motor1 un tiempo (el tiempo lo pueden variar) despues se para y arranca el Motor2 y así
sucesivamente.
Este tipo de funcionameinto en la industria es muy utilizado.
Para parar los motores se pulsa otra vez el pulsador.
La conección de los motores con el driver L-293B esta explicado en el jercicio 9.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
7
Programmer
/*First press of the pushbutton starts Motor1 after a time the
engine is turned off1 and starts Motor2 and so on. Press the
button a second time and the Motors are stopped.
*/
#include <AFMotor.h>
int Motor1=2;//Choose pin 2
int Motor2=3;//Choose pin 3
int PushButton=4;//Choose pin 4
int n=1;//Counter
boolean y= true;//Variable
void setup() { //Definitions of doors entrances and exits
pinMode(Motor1, OUTPUT);
pinMode(Motor2, OUTPUT);
pinMode(PushButton, INPUT);
}
void loop(){ //Program
if (digitalRead(PushButton)==HIGH && y==false){//control structure
n++;
y = true;
delay(30);
}
else if (digitalRead(PushButton)!=HIGH) {
y = false;
delay(30);
}
if ( n > 1){n=0;}
switch(n){
case 0:{
digitalWrite(Motor1, HIGH);
digitalWrite(Motor2, LOW);
delay(5000);
digitalWrite(Motor1, LOW);
digitalWrite(Motor2, HIGH);
delay(5000);
digitalWrite(Motor1, HIGH);
digitalWrite(Motor2, LOW);
delay(5000);
digitalWrite(Motor2, HIGH);
digitalWrite(Motor1, LOW);
delay(5000);
break;
}
case 1:{
digitalWrite(Motor1, LOW);
digitalWrite(Motor2, LOW);
break;
}
}
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
8
EXERCICI 11 : INDUSTRIAL GARAGE DOORS
1 This is one of the many applications that can be done with this PLC and we can say that it is good, nice
and cheap and very easy to program.
The Industrial garage door has two pushbuttons one to open and the other to close it, two limit
switches, when the door is open one of them disconnects from the power and when the door is closed
the other disconnects it from the system. Two flashing LEDs that operate when the door is opened or
closed.
With respect to the connections you can see in the drawing below and if you have mounted or read the
previous exercises with the L-293B and the Motors are more than capable to make the connections.
You can put an infrared sensor that gives the order to open the door when it is clossing if a person is
passing or car. The circuit and the photo are at the top.
Regarding the photo is a miniature Industrial door but it works like a real one.
2 COMPONENTS:
LEDs (2). Connectors. PLC UNO. Programmer 0022. Battery. Push Button(2). Resistors 220 Homs(2)
10K Homs (4). Breadboard. IC – L293B Driver. Motor1 CC.. End of Race (2).
Este es una de las tantas aplicaciones que se pueden hacer con este PLC y podemos decir que es bueno, bonito y barato y muy facil de programar.
La puerta de garage Industrial tiene dos pulsadores una para abrirla y la otra para cerrarla, dos finales de carrera, cuando la puerta esta abierta una de
ellas las desconecta de la alimentación y cuando la puerta esta cerrada la otra la desconecta del sistema. Dos LEDs Intermitentes que funcionan cuando
se abre o cierra la puerta.
Con respecto a las conecciones se puede ver en el dibujo inferior y si ustedes si han montado o leido los ejercicios anteriores con el L-293B y los
Motores estan más que capacitados para hacer la conecciónes.
Se puede poner un sensor infrarojo que da la orden que se abra la puerta si esta se esta cerrando cuando esta pasando una persona o coche. El circuito
esta en la parte superior y la foto.
Con respecto a la foto es una puerta Industrial en miniatura pero funciona como una real.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
9
5V
5V
LED
Tx
R1
120ohm
R2
1.0kohm
R3
220ohm
R4
5.6kohm
BC548
Rx
Transmitter
Receiver
INPUT
Programmer
//Through rotation inverter stop, with two buttons and Two Limit
//Switch. (Upper limit switch--Lower limit switch) this program
//can be used for automatic doors.
//PLC UNO. Programmer 0022
#include <AFMotor.h>
int LeftMotor = 2; //Motor1
int RightMotor = 3; //Motor1
int PushButton1 = 4;//Choose pin 4 for PushButton2
int RightLimitSwitch = 5;
int PushButton2 = 6;
int LeftLimitSwitch = 7;//choose pin 7 for Leftlimitswitch
void setup() { ////Definitions of doors entrances and exits
pinMode(PushButton1, INPUT);
pinMode(RightLimitSwitch, INPUT);
pinMode(PushButton2, INPUT);
pinMode(LeftLimitSwitch, INPUT);
pinMode(RightMotor, OUTPUT);
pinMode(LeftMotor, OUTPUT);
}
void loop(){ //Programmer
if(digitalRead(PushButton1)== HIGH){
digitalWrite(RightMotor, HIGH);//Turn right engine
}
if(digitalRead(RightLimitSwitch)== HIGH){
digitalWrite(RightMotor, LOW);//Engine stop
}
if(digitalRead(PushButton2) == HIGH){
digitalWrite(LeftMotor, HIGH);//Turn left engine
}
if(digitalRead(LeftLimitSwitch) == HIGH){
digitalWrite(LeftMotor, LOW);//Engine stop
}
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
10
EXERCICI 12 : WRITE ON A 7 SEGMENT DISPLAY A.C.
1 7-segment display, there are two types of common anode and common cathode. There is a lot of
information about the theory and how they connect to Google.
We use one of common anode (AC). And the screen will leave some letters that in my case is the
congratulations I made to my students.
Google has meter information from 0 to 9 and from 0 to 99 and how they connect.
As you can see the programming is very easy to do.
2 COMPONENTS:
Display (1). Connectors. PLC DUEMILANOVE. Programmer 0022. Battery. Resistors 220 Homs(7)
Display de 7 segmentos, hay de dos tipos los de anodo comun y los de catodo comun. Hay mucha información de la teoria y como se conectan en
Google.
Usamos uno de anodo comun (AC). y en la pantalla saldran algunas letras que en mi caso es la felicitación que les hice a mis alumnos.
En Google hay información de contadores de 0 a 9 y de 0 hasta 99 y como se conectan.
Como se ve la programación es muy facil de hacerla.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
11
Programmer
//WRITE ON A 7 SEGMENT DISPLAY A.C display (0,0,0,0,0,0,1); //Write O
//PLC Duemilanove Program 0022. Display A.C. delay(time);
int time=1000;//Variable that defines the common display (1,1,1,1,1,1,1); //Write nothing
// anode time interval between each digit. display (time);
void setup() { display (1,1,1,1,1,1,1); //Write nothing
pinMode(2, OUTPUT); //Digital doors inputs and outputs. delay(time);
pinMode(3, OUTPUT); display (0,1,0,0,1,0,0); //Write S
pinMode(4, OUTPUT); delay(time);
pinMode(5, OUTPUT); display (1,0,0,0,0,0,1); //Write U
pinMode(6, OUTPUT); delay(time);
pinMode(7, OUTPUT); display (0,1,1,0,0,0,1); //Write C
pinMode(8, OUTPUT); delay(time);
} display (0,1,1,0,0,0,1); //Write C
void display (int a, int b, int c, int d, int e, int f, int g){ delay(time);
// Display function display (0,1,1,0,0,0,0); //Write E
digitalWrite (2,a); //Each variable is assigned an output delay(time);
digitalWrite (3,b); display (0,1,1,0,0,0,0); //Write E
digitalWrite (4,c); delay(time);
digitalWrite (5,d); display (1,0,0,0,0,1,0); //Write d
digitalWrite (6,e); delay (time);
digitalWrite (7,f); display(1,1,1,1,1,1,1); //Write nothing
digitalWrite (8,g); delay(time);
} display(1,1,1,1,1,1,1); //Write nothing
void loop() { //Programmer delay(time);
// Depending on each digit the states (0 and 1) are sent to display (1,0,0,1,1,1,1); //Write I
// the display function to each of the elements. delay(time);
display (1,0,0,1,0,0,0); //Write H display(1,1,1,1,1,1,1); //Write nothing
delay(time); delay(time);
display (0,1,1,0,0,0,0); //Write E display(1,1,1,1,1,1,1); //Write nothing
delay(time); delay(time);
display (1,1,1,0,0,0,0); //Write L display (0,1,1,1,0,0,1); //Write t
delay(time); delay(time);
display (1,1,1,0,0,0,0); //Write L display (1,1,0,1,1,1,0); //Write r
delay(time); delay(time);
display (0,0,0,0,0,0,1); //Write O display (1,0,0,0,0,0,1); //Write U
delay(time); delay(time);
display (1,1,1,1,1,1,1); //Write nothing display (0,1,0,0,1,0,0); //Write S
delay(time); delay(time);
display (1,1,1,1,1,1,1); //Write nothing display (0,1,1,1,0,0,1); //Write t
delay(time); delay(time);
display (1,1,0,0,0,0,0); //Write b display(1,1,1,1,1,1,1); //Write nothing
delay(time); delay(time);
display (0,0,0,0,0,0,1); //Write O display(1,1,1,1,1,1,1); //Write nothing
delay(time); delay(time);
display (1,0,0,0,1,0,0); //Write Y
delay(time);
display (0,1,0,0,1,0,0); //Write S
delay(time);
display (1,1,1,1,1,1,1); //Write nothing
delay(time);
display (1,1,1,1,1,1,1); //Write nothing
delay(time);
display (0,1,1,1,0,0,1); //Write t
delay(time);
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
12
display (1,0,0,1,1,1,1); //Write I
delay(time);
display (1,1,0,1,0,1,0); //Write n
delay(time);
display (1,1,1,1,1,1,1); //Write nothing
delay(time);
display (1,1,1,1,1,1,1); //Write nothing
delay(time);
display (1,0,0,0,1,0,0); //Write Y
delay(time);
display (0,0,0,0,0,0,1); //escribe O
delay(time);
display (1,0,0,0,0,0,1); //Write U
delay(time);
display (1,1,1,1,1,1,1); //Write nothing
delay(time);
display (1,1,1,1,1,1,1); //Write nothing
delay(time);
display (0,1,0,0,0,0,0); //Write G
delay(time);
display (0,1,1,0,0,0,0); //Write E
delay(time);
display (0,0,0,0,0,0,1); //Write O
delay(time);
display (1,1,1,1,0,1,0); //Write r
delay(time);
display (0,1,0,0,0,0,0); //Write G
delay(time);
display (0,1,1,0,0,0,0); //Write E
delay(time);
display (1,1,1,1,1,1,1); //Write nothing
delay(time);
display (1,1,1,1,1,1,1); //Write nothing
delay(time);
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
13
EXERCICI 13 : LIQUID CRYSTAL OLIVIA “LCD”
1 As seen in the program is very easy to operate a LCD liquid crystal.
It is 16x2. There is a lot of information on Google about your programming and connection.
This exercise exits the information in the two lines. Sometimes when you put the program on the PLC
in our case the Duemilanove on the screen shows things that are not understood, what they have to do
is a simple reset that there is in the PLC that is a pushbutton.
2 COMPONENTS:
LCD (1). Connectors. PLC DUEMILANOVE. Programmer 0022. Battery. Potenciometer 10K (1)
Proto-Board (1).
Como se ve en el programa es muy facil de hacer funcionar un LCD de cristal líquido.
Es de 16x2. Hay mucha información en Google respecto a su programación y coneción.
Este ejercicio sale la informacion en las dos linias. A veces cuando se pone el programa en el PLC en nuestro caso el Duemilanove en la pantalla se
muestras cosas que no se entienden, lo que tienen que hacer es un simple reset que hay en el PLC que es un pulsador.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
14
Programmer
//Program 0022. PLC DUEMILANOVE. lcd.print("OLIVIA CASTILLO");
//Liquid Crystal OLIVIA lcd.setCursor(0,1);
#include <LiquidCrystal.h> lcd.print("JOSE HUIMAN");
LiquidCrystal lcd(12,11,5,4,3,2); delay(3000);
void setup() { lcd.clear();
lcd.begin(16,2); lcd.display();
lcd.clear(); delay(3000);
} }
void loop(){
lcd.print("Hello my friends"); //fierts line
lcd.setCursor(0,1);
lcd.print("Hola amigos"); //Second line
delay(3000);
lcd.clear();
lcd.print("How are you"); //Fierts line
lcd.setCursor(0,1);
lcd.print("Como estan Ustedes"); //Second line
delay(3000);
lcd.clear();
lcd.print("Very easy"); //Fierts line
lcd.setCursor(0,1);
lcd.print("Muy facil");
delay(3000);
lcd.clear();
lcd.print("To programs"); //Fierts line
lcd.setCursor(0,1);
lcd.print("De programar");
delay(3000);
lcd.clear();
lcd.print("There is a lot"); //Fierts line
lcd.setCursor(0,1);
lcd.print("Hay mucha");
delay(3000);
lcd.clear();
lcd.print("Information"); //Fierts line
lcd.setCursor(0,1);
lcd.print("Informacion");
delay(3000);
lcd.clear();
lcd.print("In Google"); //Fierts line
lcd.setCursor(0,1);
lcd.print("En Google");
delay(3000);
lcd.clear();
lcd.print("Thank you"); //Fierts line
lcd.setCursor(0,1);
lcd.print("Gracias");
delay(3000);
lcd.clear();
delay(3000);
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
15
R2
120ohm
LDR1
LED1
Q1
BC547BP
V1
5V
SW1
108A
BD135-137
BC547-548
PIN5
DAYSENSOR
R1
120ohm
R3
10kohm
LDR2
LED2
Q2
BC547BP
V2
5V
SW2
108A
BD135-137
BC547-548
PIN8
NIGHTSENSOR
EXERCICI 14 : AUTOMATIC BLINDS MANUAL
1 It works in automatic and manual with key for the automatic, when it works in automatic form it has
two sensore of day when it receives the light of the sun gives the order to the blind to be opened and at
night when everything is dark gives the order to the blind To close. The manual is switched off
manually and has two pushbuttons to raise and lower the blind.
2 COMPONENTS:
Connectors. PLC DUEMILANOVE. Programmer 0022. Battery. Proto-Board (1). Day Sensor. Night
Sensor. Transistors (2). LDR (2) (). LEDs (2). Resistors 120 Ohms (2). Resistor (1) 10K. Motor (1).
IC 293B. PushButton (2). LimitSwitch (2).
Funciona en automatico y manual con llave para el automatico, cuando trabaja en forma automatica tiene dos sensore de dia cuando recibe la luz del
sol da la orden a la persiana para que se abra y de noche cuando todo esta oscuro da la orden a la persiana para que se cierre. En forma manual se
desconecta el automatico y tiene dos pulsadores para subir y bajar la persiana.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
16
Programmer
//It works in automatic and manual with key for the automatic, when it works in automatic form it has two
//sensore of day when it receives the light of the sun and at night when everything is dark. The automatic
//is switched off manually and has two pushbuttons to raise and lower the blind.
#include <AFMotor.h>
int RightMotor1 = 2;
int LeftMotor1 = 3;
int UpButton1 = 4;//On right motor1
int UpSensor = 5; //Day sensor
int UpLimitSwitch1 = 6; //OFF RightMotor1
int LowButton2 = 7; //On LeftMotor1
int LowSensor = 8; //Night sensor
int LowLimitSwitch2 = 9; //OFF Leftmotor1
void setup(){ //Definitions of doors entrances and exits
pinMode(RightMotor1, OUTPUT);
pinMode(LeftMotor1, OUTPUT);
pinMode(UpButton1, INPUT);
pinMode(UpSensor, INPUT);
pinMode(UpLimitSwitch1, INPUT);
pinMode(LowButton2, INPUT);
pinMode(LowSensor, INPUT);
pinMode(LowLimitSwitch2, INPUT);
}
void loop(){ //program
if(digitalRead(UpButton1) == HIGH){
digitalWrite(RightMotor1, HIGH);
}
if(digitalRead(UpSensor) == HIGH){
digitalWrite(RightMotor1, HIGH);
}
else if(digitalRead(UpLimitSwitch1) == HIGH){
digitalWrite(RightMotor1, LOW);
}
if(digitalRead(LowButton2) == HIGH){
digitalWrite(LeftMotor1, HIGH);
}
if(digitalRead(LowSensor) == HIGH){
digitalWrite(LeftMotor1, HIGH);
}
else if(digitalRead(LowLimitSwitch2) == HIGH){
digitalWrite(LeftMotor1, LOW);
}
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
17
EXERCICI 15: CRANE CONTROL MANUALLY I
1 Manual control cranes are widely used in industrias to carry packages or loads from side to side. It has
two universal mortors or cage of cudila, one works vertically and the other horizontal; has four push
buttons that do different functions or rise, down, right and left and a stop button in any sistem at any
time.
With the button Up we climbed M1, witch the down descended M1, with the right goes to the right
M2 and with the left the M2.
2 COMPONENTS:
Connectors. PLC DUEMILANOVE. Programmer 0022. Battery. Proto-Board (1). Resistor (4) 10K.
Motors (2). IC 293B. PushButton (4).
Las gruas de control manual son muy utilizadas en las industrias para transportar paquetes o cargas de un lado a otro. Tiene dos motores
universales o jaula de ardilla, uno trabaja en forma vertical y el otro horizontal, tiene cuatro pulsadores que hacen funciones diferentes de
subida, bajada a la derecha y a la izquierda y un boton que para el sistema en cualquier momento.
Con el boton Up subimos M1, con el Down bajamos M1, con el Right va a la derecha M2 y con el Left va a la izquierda M2.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
18
Programmer
//Crane Control Manually I. PLC DUEMILANOVE. Program 0022
#include <AFMotor.h>
int UpMotor1 = 2;
int DownMotor1 = 3;
int RightMotor2 = 4;
int LeftMotor2 = 5;
int UpButton1 = 6;
int DownButton2 = 7;
int RightButton3 = 8;
int LeftButton4 = 9;
int StopButton5 = 11;
void setup () {
pinMode(UpMotor1, OUTPUT);
pinMode(DownMotor1, OUTPUT);
pinMode(RightMotor2, OUTPUT);
pinMode(LeftMotor2, OUTPUT);
pinMode(UpButton1, INPUT);
pinMode(DownButton2, INPUT);
pinMode(RightButton3, INPUT);
pinMode(LeftButton4, INPUT);
pinMode(StopButton5, INPUT);
digitalWrite(UpMotor1, LOW);
digitalWrite(DownMotor1, LOW);
digitalWrite(RightMotor2, LOW);
digitalWrite(LeftMotor2, LOW);
}
void loop () {
if(digitalRead(UpButton1) == HIGH && digitalRead(DownButton2) == LOW){
digitalWrite(UpMotor1 , HIGH);//M1 Up
}
else if(digitalRead(StopButton5) == HIGH){
digitalWrite(UpMotor1, LOW);//Z-Stop
}
if(digitalRead(DownButton2) == HIGH && digitalRead(UpButton1) == LOW){
digitalWrite(DownMotor1, HIGH);//M1 Low
}
else if(digitalRead(StopButton5) == HIGH){
digitalWrite(DownMotor1, LOW);//Z-Stop
}
if(digitalRead(RightButton3) == HIGH && digitalRead(LeftButton4) == LOW){
digitalWrite(RightMotor2, HIGH);//M2 Right
}
else if(digitalRead(StopButton5) == HIGH){
digitalWrite(RightMotor2, LOW);//Z-Stop
}
if(digitalRead(LeftButton4) == HIGH && digitalRead(RightButton3) == LOW){
digitalWrite(LeftMotor2, HIGH);//M2 Left
}
else if(digitalRead(StopButton5) == HIGH){
digitalWrite(LeftMotor2, LOW);
}
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
19
EXERCICI 16: CRANE CONTROL AUTOMATIC II
1 This circuit operates in two stages.
First stage:
The operator loads the crane, presses the travel button and the UpMotor1 rises and is switched off by
the upper limit switch. The left-hand limit switch starts the RightMotor2 that goes to the right and is
switched off by the right-hand limit switch and activates the DownMotor1 that goes down and is
switched off by the lower limit switch, waits for the corresponding time while Discharge the load.
All these stages can be stopped with the stop button.
Second stage:
The return is automatic through the same stages, the UpMotor1 rises and is disconnected, the
Leftmotor2 goes to the left and is disconnected, the motor 1 goes down and is left unoccupied waiting
for the new cycle.
2 COMPONENTS:
Connectors. PLC DUEMILANOVE. Programmer 0022. Battery. Proto-Board (1). Resistor (4) 10K.
Motors (2). IC 293B. PushButton (4).
Este circuito funciona en dos etapas.
Primera etapa:
el operario carga la grua, pulsa el pulsador de marcha y el motor 1 sube y es desconectado por el final de carrera superior. el final de carrera izquierda
pone en marcha el motor 2 que va a la derecha y es desconectado por el final de carrera de la derecha y este activa al motor 1 que baja y es
desconectado por el final de carrera inferior, espera el tiempo correspondiente mientras descarga la carga.
todas estas etapas se pueden parar con el pulsador de paro.
Segunda etapa:
el retorno es automatico pasando por las mismas etapas, el motor 1 sube y queda desconectado, el motor 2 va a la izquierda y queda desconectado, el
motor 1 baja y queda desconctado esperando el nuevo ciclo.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
20
Programmer
//Crane Control II. PLC DUEMILANOVE. Progran 0022
#include <AFMotor.h>
int UpMotor1 = 2; if(digitalRead(DownLimitSwitch) == HIGH){
int DownMotor1 = 3; digitalWrite(DownMotor1, LOW);
int RightMotor2 = 4; delay(8000);
int LeftMotor2 = 5; digitalWrite(UpMotor1, HIGH);
int StartButton = 6; delay(6000);
int DownLimitSwitch = 7; digitalWrite(UpMotor1, LOW);
int UpLimitSwitch = 8; digitalWrite(LeftMotor2, HIGH);
int LeftLimitSwitch = 9; delay(6000);
int RightLimitSwitch = 10; digitalWrite(LeftMotor2, LOW);
int StopButton = 11; delay(2000);
void setup () { digitalWrite(DownMotor1, HIGH);
pinMode(UpMotor1, OUTPUT); delay(6000);
pinMode(DownMotor1, OUTPUT); digitalWrite(DownMotor1, LOW);
pinMode(RightMotor2, OUTPUT); }
pinMode(LeftMotor2, OUTPUT); else if(digitalRead(StopButton) == HIGH){
pinMode(StartButton, INPUT); digitalWrite(DownMotor1, LOW);
pinMode(DownLimitSwitch, INPUT); digitalWrite(UpMotor1, LOW);
pinMode(UpLimitSwitch, INPUT); digitalWrite(RightMotor2, LOW);
pinMode(LeftLimitSwitch, INPUT); digitalWrite(LeftMotor2, LOW);
pinMode(RightLimitSwitch, INPUT); }
pinMode(StopButton, INPUT); }
digitalWrite(UpMotor1, LOW);
digitalWrite(DownMotor1, LOW);
digitalWrite(RightMotor2, LOW);
digitalWrite(LeftMotor2, LOW);
}
void loop () {
if(digitalRead(StartButton) == HIGH){
digitalWrite(UpMotor1 , HIGH);//M1 Up
}
if(digitalRead(UpLimitSwitch) == HIGH){
digitalWrite(UpMotor1, LOW);//M1 Off
}
else if(digitalRead(StopButton) == HIGH){
digitalWrite(UpMotor1, LOW);//Z-Stop
}
if(digitalRead(LeftLimitSwitch) == HIGH){
digitalWrite(RightMotor2, HIGH);//M2 On
}
if(digitalRead(RightLimitSwitch) == HIGH){
digitalWrite(RightMotor2, LOW);//M2 Off
}
else if(digitalRead(StopButton) == HIGH){
digitalWrite(RightMotor2, LOW);//Z-Stop
}
if(digitalRead(RightLimitSwitch) == HIGH){
digitalWrite(DownMotor1, HIGH);
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
21
EXERCICI 17: CONTROL LIGHTING AND EXTRACTION OF A BATH
1 We have a pushbutton at the entrance of a bathroom, inside the one lamp and a gas extractor that turns
on whenever the pushbutton is activated; The extractor will remain in operation ten seconds after the
bath light has been turned off.
2 COMPONENTS:
PushButton. Led (1). Gas Extractor Engine Guard.Resistor (1) 230 Ohms. Resistor 10K (1). PLC
DUEMILANOVE (1). Conectors. Driver L293B. Tenemos unpulsador en la entrada de un baño, dentro de el hay una lampara y un extractor de gases que se encenderan siempre que se active el
pulsador; el extractor se mantendra en funcionamiento diez segundos despues que se haya apagado la luz del baño.
Programmer
//Control Lighting and Extraction of Bath. Program 0022 PLC DUEMILANOVE
#include <AFMotor.h>
int Led1 = 2;
int Motor1 = 3;
int PushButton = 4;
void setup() {
pinMode(Led1, OUTPUT);
pinMode(Motor1, OUTPUT);
pinMode(PushButton, INPUT);
}
void loop() {
if(digitalRead(PushButton) == HIGH){
digitalWrite(Led1, HIGH);
digitalWrite(Motor1, HIGH);
delay (6000);
}
if(digitalRead(PushButton) == HIGH){
delay(1000);
digitalWrite(Led1, LOW);
delay(10000);
digitalWrite(Motor1, LOW);
delay(1000);
}
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
22
EXERCICI 18 : ESCALATOR IN ONE DIRECTION
1 The program is of a mechanical ladder in one direction only. A motor to operate the ladder that goes
from the ground floor to the upper.
All the circuitry is on a panel for maintenance.
The push button is under a ground level carpet, which every time you step on it runs the engine that
lasts three minutes and then it will stop, but the carpet continues to run on the internal timer that has the
program restarted again And start counting from scratch.
There are two stop buttons or emergencies that are at the beginning and end of the stairs.
2 COMPONENTS:
PushButton (2). Motor (1). Resistor 10K (2). PLC DUEMILANOVE (1). Conectors. Driver L293B.
Battery (2) ) 9 Vcc and 5Vcc.
El programa es de una escalera mecanica en una sola direción. Un motor ara funcionar la escalera que va desde la planta baja a la superior.
Toda la circuiteriaestaesta en un panel para que se haga mantenimiento.
El pulsador de marcha esta debajo de una alfombra a nivel de tierra, que cada vez que se pisa hace funcionar el motor que dura tres minutos y despues
se parará, pero se sigue pisando la alfombra el temporizador interno que tiene el programa se reinicia de nuevo y comienza a contar desde cero.
Hay dos pulsadores de paro o emergencias que estan al inicio y final de las escaleras.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
23
Programmer
//ESCALATOR AUTOMATIC IN ONE DIRECTION
//PLC DUEMILANOVE, Program 0022.
#include <AFMotor.h>
int Motor1 = 2;
int PushButton = 3;
int StopButton = 4;
void setup() {
pinMode(Motor1, OUTPUT);
pinMode(PushButton, INPUT);
pinMode(StopButton, INPUT);
}
void loop() {
if(digitalRead(PushButton) == HIGH){
digitalWrite(Motor1, HIGH);
delay(4000);
digitalWrite(Motor1, LOW);
}
else if(digitalRead(StopButton) == HIGH){
digitalWrite(Motor1, LOW);
}
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
24
EXERCICI 19 : AUTOMATIC STAIRCASE IN TWO DIRECTIONS
1 Programming of the escalator automatic dual direction, a motor squirrel cage that works in both
directions for work.
There is a control panel for maintenance and only the maintenance personnel are available and they
will be the only ones that will put the system into operation.
The circuit is formed by two push buttons, each time you press one of them indicates the direction in
which the engine moves (opposite directions).
The pushbuttons will be underneath carpets that are at ground level and at the entrances to the stairs,
one on the lower floor and the other on the upper one. In each floor there are two-color green and red
light indicators that are in parallel.
As an example, if they are going up from the ground floor to the upper floor, the lights in the lower
green and red upper lights; These are in parallel they work at the same time, the same happens when
they go down.
Every time you step on the carpet you start counting the time that lasts three minutes, if you are already
climbing and you step on the carpet you start counting from scratch.
There is a stop or emergency button that is in the entrances of the escalator automatic.
If the engine goes in one direction and the opposite direction button is pressed, the engine will not shift
direction until the operating time has elapsed.
2 COMPONENTS:
PushButton (3). Motor (1). Resistor 10K (3). PLC DUEMILANOVE (1). Conectors. Driver L293B.
Battery (2) 9 Vcc and 5Vcc. LEDs (2).
Programacion de la escalera mecanica automatica de doble direcion, un motor jaula de ardilla que funciona en las dos direciones ara el trabajo.
Hay un panel de control para hacer mantenimiento y solo acedera el personal de mantenimiento y seran los unicos que pondran en funcionamiento el
sistema.
El circuito esta formado por dos pulsadores de marcha, cada vez que se pulsa uno de ellos indica la direcion en que se movera el motor (direciones
contrarias).
Los pulsadores de marcha estaran debajo de alfombras que estan a nivel de tierra y en las entradas de las escaleras, una en la planta inferior y la otra
en la superior. En cada planta hay indicadores de luz de dos colores el verde y el rojo que estan en paralelo.
Como ejemplo, si estan subiendo de la planta baja a la superior, se encienden las luces en la inferior de color verde y en la superior roja; estos estan en
paralelo funcionan al mismo tiempo, lo mismo ocurre cuando bajan.
Cada vez que se pisa la alfombra comienza a contar el tiempo que dura tres minutos, si ya estan subiendo y se pisa la alfombra comienza a contar desde
cero.
Existe un pulsador de parada o emergencia que estan en las entradas de la escalera mecanica automatica.
Si el motor va en una direcion y se pulsa el boton de direcion contraria, el motor no canviara de direcion hasta que cumpla el tiempo de
funcionamiento.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
25
Programmer
/AUTOMATIC STAIRCASE IN TWO DIRECTIONS
//PLC DUEMILANOVE. program 0022
#include <AFMotor.h> else if(digitalRead(StopButton) == HIGH) {
int RightMotor = 2; digitalWrite(LeftMotor, LOW);
int LeftMotor = 3; delay(500);
int PushRightMotor = 4; digitalWrite(LedLeftMotor, LOW);
int PushLeftMotor = 5; delay(500);
int LedRightMotor = 6;//two colors red and grenn in paralell }
int LedLeftMotor = 7;//two colors red and grenn in paralell }
int StopButton = 8;
void setup() {
pinMode(RightMotor, OUTPUT);
pinMode(LeftMotor, OUTPUT);
pinMode(LedRightMotor, OUTPUT);
pinMode(LedLeftMotor, OUTPUT);
pinMode(PushRightMotor, INPUT);
pinMode(PushLeftMotor, INPUT);
pinMode(StopButton, INPUT);
}
void loop() {
if(digitalRead(PushRightMotor) == HIGH){
digitalWrite(RightMotor, HIGH);
delay(500);
digitalWrite(LedRightMotor, HIGH);//two colors red and grenn in paralell
delay(10000);
digitalWrite(RightMotor, LOW);
delay(10);
digitalWrite(LedRightMotor, LOW);
delay(10);
}
if(digitalRead(PushLeftMotor) == HIGH){
digitalWrite(LeftMotor, LOW);
delay(1000);
}
else if(digitalRead(StopButton) == HIGH) {
digitalWrite(RightMotor, LOW);
delay(500);
digitalWrite(LedRightMotor, LOW);
delay(500);
}
if(digitalRead(PushLeftMotor) == HIGH) {
digitalWrite(LeftMotor, HIGH);
delay(500);
digitalWrite(LedLeftMotor, HIGH);//two colors red and grenn in paralell
delay(10000);
digitalWrite(LeftMotor, LOW);
delay(10);
digitalWrite(LedLeftMotor, LOW);
delay(10);
}
if(digitalRead(PushRightMotor) == HIGH){
digitalWrite(RightMotor, LOW);
delay(1000);
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
26
R1
100ohm
R2
10kohm
R3
10kohm
5V
Q1
2N2222A
TO PIN
SENSOR
MAXIM
108A
R1
100ohm
5V
TO PIN
SENSOR
MINIMUM
R2
4.7kohm
Q1
BC558AP
BC559
EXERCICI 20 : AUTOMATIC FILLING OF A TANK WITH TWO PUMPS
1 It is real practical and easy to assemble and program.
It is about making a program to fill a liquid tank with two pumps. According to the level of the tank
can work one or two pumps. If you work a single pump will work in an alternative way. The tank has
three sensors, minimum, medium and maximum.
If the liquid level is below the minimum sensor, two pumps will start up, when the liquid level reaches
the second medium level sensor, a single pump will work alternatively and if the level reaches the
maximum sensor this gives the order To stop the bombs.
If the liquid drops below the minimum level the sensor will give the order for the pumps to start
working alternatively until reaching the maximum level.
2 COMPONENTS:
Pumps (2). PushButton (1), Resistor 10K (1). PLC DUEMILANOVE (1). Conectors. Driver L293B.
Battery (2) 9 Vcc and 5Vcc. Sensors (3), two Maximun and one Minimum. Es real práctico y facil de montar y programar.
Se trata de hacer un programa para llenar un deposito de liquidos con dos bombas. Segun el nivel que tenga el deposito pueden trabajar una o dos
bombas. Si trabaja una sola bomba trabajaran en forma alternativa. El depósito tiene tres sensores, minimo, medio y maximo.
Si el nivel del liquido esta por debajo del sensor minimo, se pondran en marcha dos bombas, cuando el nivel del liquido llega al segundo sensor nivel
medio, trabajara una sola bomba en forma alternativa y si el nivel llega al sensor maximo este da la orden de parar las bombas.
Si el líquido baja por debajo del nivel minimo el sensor dara la orden para que las bombas comienzen a trabajar en forma alternativa hasta llegar al
nivel maximo.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
27
Programmer
//PLC DUEMILANOVE. Program 0022.
//AUTOMATIC FILLING OF A TANK WITH TWO PUMPS
#include <AFMotor.h>
int Pump1 = 2; else if(digitalRead(StopButton) == HIGH){
int Pump2 = 3; digitalWrite(Pump1, LOW);
int MinimumSensor = 4; delay(100);
int MediumSensor = 5; digitalWrite(Pump2, LOW);
int MaximumSensor = 6; }
int StopButton = 7; if(digitalRead(MaximumSensor) == HIGH){
void setup() { digitalWrite(Pump1, LOW);
pinMode(Pump1, OUTPUT); delay(100);
pinMode(Pump2, OUTPUT); }
pinMode(MinimumSensor, INPUT); }
pinMode(MediumSensor, INPUT);
pinMode(MaximumSensor, INPUT);
pinMode(StopButton, INPUT);
}
void loop() {
if(digitalRead(MinimumSensor) == HIGH){
digitalWrite(Pump1, HIGH);
delay(500);
digitalWrite(Pump2, HIGH);
}
else if(digitalRead(StopButton) == HIGH) {
digitalWrite(Pump1, LOW);
delay(100);
digitalWrite(Pump2, LOW);
}
if(digitalRead(MediumSensor) == HIGH){
digitalWrite(Pump1, LOW);
delay(4000);
digitalWrite(Pump2, LOW);
delay(100);
digitalWrite(Pump1, HIGH);
delay(4000);
digitalWrite(Pump1, LOW);
delay(100);
digitalWrite(Pump2, HIGH);
delay(4000);
digitalWrite(Pump2, LOW);
delay(100);
digitalWrite(Pump1, HIGH);
delay(4000);
digitalWrite(Pump1, LOW);
delay(100);
digitalWrite(Pump2, HIGH);
delay(4000);
}
else if(digitalRead(StopButton) == HIGH){
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
28
EXERCICI 21 : AUTOMATIC DOOR OF A SUPERMERCAT
SENSOR
OLS CLS
1 We will program as you open and close the automatic door of a two-sheet supermarket.
We have a motor.
There are two sensors one on the outside and the other on the inside.
These sensors will cause the door to open when people are detected entering or leaving.
There are two limit switches, which indicates that the door is closed (CLS) or open (OLS).
The time the door is open is 10 seconds.
If the sensors detect people when the door is closing it will open and the time will start counting from
scratch.
There is a push button (PM) and an emergency (Ps) button; this last will stop the whole system of
operation either by damage of the door or by maintenance of it.
Only maintenance personnel once the door has been checked for it to work.
2 COMPONENTS:
Motor (1). PushButton (1), Resistor 10K (6). PLC DUEMILANOVE (1). Conectors. Driver L293B.
Battery (2) 9 Vcc and 5Vcc. OpticalSensorInside (1). externalopticalSensor (1). Programaremos como se abre y se cierra la puerta automatica de un supermercado de dos hoja.
Tenemos un motor trifasico.
Hay dos sensores uno en la parte exterior y el otro en el interior.
Estos sensores aran que la puerta se abra cuando detecten que entran o salgan personas.
Hay dos finales de carrera, el que indica que la puerta esta cerrada (FCI) o esta abierta (FCS).
El tiempo que la puerta esta abierta es de 10 segundos.
Si los sensores detectan personas cuando la puerta se esta cerrando esta se abrira y el tiempo se comenzara a contar desde cero.
Hay un pulsador de marcha (PM) y otro de emergencia (Ps), este último parara todo el sistema de funcionamiento ya sea averia de la puerta o por
mantenimiento de la misma.
Solo el personal de mantenimiento una vez revisada la puerta ara que esta funcione.
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
29
Programmer
//AUTOMATIC DOOR OF A SUPERMERCAT
//PLC DUEMILANOVE. Programmer 0022
#include <AFMotor.h>
int RightMotor = 2;
int LeftMotor = 3;
int PushButton = 4;
int OpticalSensorInside = 5;
int ExternalOpticalSensor = 6;
int OpenLimitSwitch = 7;
int CloseLimitSwitch = 8;
int StopButton = 9;
void setup(){
pinMode(RightMotor, OUTPUT);
pinMode(LeftMotor, OUTPUT);
pinMode(PushButton, INPUT);
pinMode(OpticalSensorInside, INPUT);
pinMode(ExternalOpticalSensor, INPUT);
pinMode(OpenLimitSwitch, INPUT);
pinMode(CloseLimitSwitch, INPUT);
pinMode(StopButton, INPUT);
}
void loop(){
if(digitalRead(PushButton) == HIGH){
digitalWrite(RightMotor, LOW);
delay(10);///
digitalWrite(LeftMotor, HIGH);
}
if(digitalRead(OpenLimitSwitch) == HIGH){
digitalWrite(LeftMotor, LOW);
delay(3000);
digitalWrite(RightMotor, HIGH);
}
if(digitalRead(CloseLimitSwitch) == HIGH) {
digitalWrite(RightMotor, LOW);
}
else if(digitalRead(StopButton) == HIGH) {
digitalWrite(RightMotor, LOW);
}
if(digitalRead(OpticalSensorInside) == HIGH){
digitalWrite(RightMotor, LOW);
delay(10);///
digitalWrite(LeftMotor, HIGH);
}
if(digitalRead(OpenLimitSwitch) == HIGH){
digitalWrite(LeftMotor, LOW);
delay(3000);
digitalWrite(RightMotor, HIGH);
}
CATALONIA-SPAIN Projects with arduino for all ages
Easy to mont
Engineer Jordi A. Huiman Castillo
.
30
if(digitalRead(CloseLimitSwitch) == HIGH){
digitalWrite(RightMotor, LOW);
}
else if(digitalRead(StopButton) == HIGH){
digitalWrite(RightMotor, LOW);
}
if(digitalRead(ExternalOpticalSensor) == HIGH){
digitalWrite(RightMotor, LOW);///
delay(10);
digitalWrite(LeftMotor, HIGH);
}
if(digitalRead(OpenLimitSwitch) == HIGH){
digitalWrite(LeftMotor, LOW);
delay(3000);
}
if(digitalRead(CloseLimitSwitch) == HIGH){
digitalWrite(RightMotor, LOW);
}
else if(digitalRead(StopButton) == HIGH){
digitalWrite(RightMotor, LOW);
}
}