VSS (VEHICLE SPEED SENSOR) NO ARDUINO COM 4N25
1 x 4N25
2 x resistor 4k7
1 x diodo 1n4148
1 x VSS AUTOMOTIVO 3 fios
código
===
int pino = 11;
int led = 13;
int old;
int valor;
void setup(){
Serial.begin(115200);
Serial.println("inicio");
pinMode(pino, INPUT);
pinMode(led, OUTPUT);
}
void loop(){
valor = digitalRead(pino);
if(valor != old){
Serial.println( valor);
if( digitalRead(pino) ){
digitalWrite(13, HIGH);
}else{
digitalWrite(13, LOW);
}
old = valor;
}
}
===
volatile int iIRQ2_Count;
int IRQ2_PIN = 2;
int IRQ2_IRQ = 0;
void setup(){
// Put your setup code here, to run once:
Serial.begin (9600);
attachInterrupt(IRQ2_IRQ, IRQ2_Counter, RISING);
delay(25);
detachInterrupt(IRQ2_PIN);
Serial.print(F("Counted = "));
Serial.println(iIRQ2_Count);
}
void IRQ2_Counter() {
iIRQ2_Count++;
}
void loop() {
Serial.println(iIRQ2_Count);
iIRQ2_Count = 0;
delay(1000);
}
Nenhum comentário:
Postar um comentário