necesario para cada software.
Código Arduino
1.
Descarga el software Arduino
2.
Abre el programa Arduino y, una vez en él, copia el siguiente programa:
#include <Servo.h>
Servo motor1;
int
TrigPin = 13;
int
EchoPin = 12;
float
SSound = 0.0343;
long
Lengh, Distance ;
cm
int
RedLED = 4, YellowLED = 5;
void
setup() {
// Put your setup code here, to run once:
motor1.attach (9);
EL SERVO 1
pinMode(TrigPin, OUTPUT);
CONECTADO EL SENSOR DE ULTRASONIDOS
pinMode(EchoPin, INPUT);
pinMode(RedLED, OUTPUT);
pinMode(YellowLED, OUTPUT);
}
void
loop() {
// Put your main code here, to run repeatedly:
DistanceCM();
if
(( Distance < 30) && ( Distance > 1))
ENTRE 1 Y 30 cm
{
// SALUDAR DOS VECES y PARPADEO DE LOS LEDS
for
{
motor1.write (140);
digitalWrite(RedLED, HIGH);
digitalWrite(YellowLED, LOW);
delay (300);
motor1.write (60);
digitalWrite(RedLED, LOW);
digitalWrite(YellowLED, HIGH);
delay (300);
}
5
y realiza el proceso de instalación.
// DECLARAR SERVOMOTOR
// PUERTOS DEL SENSOR ULTRASONIDOS
//VELOCIDAD DEL SONIDO EN cm/us
// VARIABLES PARA CALCULAR LA DISTANCIA EN
// PUERTO DIGITAL PWM 9 DONDE ESTÁ CONECTADO
// LLAMAR A LA FUNCIÓN PARA CALCULAR LA DISTANCIA
(int
x=0; x<2 ; x++)
// PUERTOS DIGITALES 12 Y 13 DONDE ESTÁ
// SI LA DISTANCIA ES
www.ebotics.com