Skip to content

Tacómetro

javierre edited this page May 21, 2019 · 6 revisions

TBD

Tacho

Tacho wiring

const int sensorPin = D6;

int cuenta=0;
int last_=0;
 
void setup() {
  Serial.begin(9600);   //iniciar puerto serie
  pinMode(sensorPin , INPUT);  //definir pin como entrada
}
 
void loop(){
  int value = 0;
  value = digitalRead(sensorPin );  //lectura digital de pin
 
  if (value == LOW) {
      Serial.println("Optointerruptor activado");
      if(last_==0) cuenta++;
      last_=1;
  }
  else last_=0;
  delay(1000);
}
Clone this wiki locally