lunes, 22 de abril de 2019

Sensor de Velocidad

Primer Programa Utilizando el Sensor de Velocidad
 con Interrupciones


//++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++
volatile int DER=0; 
volatile int IZQ=0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  attachInterrupt(0,RUEDADER,RISING);//INT0 en pin2
  attachInterrupt(1,RUEDAIZQ,FALLING);//INT1 en pin3
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(1000);
  Serial.print("Pulsos en Rueda Derecha=");
  Serial.println(DER);
  Serial.print("Pulsos en Rueda Izquierda=");
  Serial.println(IZQ);
  Serial.println("+/+/+/+/+/+/+/+/+/+/+/+");
  DER=0;
  IZQ=0;
}

void RUEDADER(){
  DER++;        //INCREMENTAR +1
}

void RUEDAIZQ(){
  IZQ++;        //INCREMENTAR +1
}
//++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++




Les deseo mucho éxito
y sigamos programando!!!

No hay comentarios.:

Publicar un comentario

Transformación del Samybot

Les deseo mucho éxito y sigamos programando!!!