Sistema Transporte Paciente Arduino
Sistema Transporte Paciente Arduino
Sistema Transporte Paciente Arduino
h> //
Servo servo1; //
int izqA = 5;
int izqB = 6;
int derA = 9;
void setup() {
pinMode(derA, OUTPUT);
pinMode(derB, OUTPUT);
pinMode(izqA, OUTPUT);
pinMode(izqB, OUTPUT);
pinMode(13,OUTPUT);
servo1.attach (11,660,1400); // Asocia el servo1 al pin 11, define el min y max del ancho del
pulso
void loop() {
if(Serial.available()>0){ // lee el bluetooth y almacena en estado
estado = Serial.read();
analogWrite(derB, 0);
analogWrite(izqB, 0);
analogWrite(derA, vel);
analogWrite(izqA, vel);
analogWrite(derB, 0);
analogWrite(izqB, 0);
analogWrite(derA, 0);
analogWrite(izqA, vel);
analogWrite(derB, 0);
analogWrite(izqB, 0);
analogWrite(derA, 0);
analogWrite(izqA, 0);
analogWrite(derB, 0);
analogWrite(izqB, 0);
analogWrite(izqA, 0);
analogWrite(derA, vel);
}
if(estado=='e'){ // Boton Reversa
analogWrite(derA, 0);
analogWrite(izqA, 0);
analogWrite(derB, vel);
analogWrite(izqB, vel);
delay(0.01);
digitalWrite(ptrig, LOW);
delay(10);
analogWrite(izqB, 0);
analogWrite(derA, 0);
analogWrite(izqA, 0);
delay (200);
analogWrite(izqB, vel);
delay(500);
analogWrite(derA, 0);
analogWrite(izqA, vel);
delay(600);
digitalWrite(13,LOW);
analogWrite(derB, 0);
analogWrite(izqB, 0);
analogWrite(derA, vel);
analogWrite(izqA, vel);
delay(700);
digitalWrite(13,1);
if(estado=='m'){
digitalWrite(13,0);
}
if(estado=='i'){
digitalWrite(derB,1);
if(estado=='n'){
digitalWrite(derB,0);
if(estado=='j'){
digitalWrite(derA,1);
if(estado=='o'){
digitalWrite(derA,0);
if(estado=='k'){
digitalWrite(izqB,1);
if(estado=='p'){
digitalWrite(izqB,0);
if(estado=='l'){
digitalWrite(izqA,1);
if(estado=='q'){
digitalWrite(izqA,0);