(Agious) Dios

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

CONTROLAR IGNIÇÃO/RPM

SENSOR HALL/INDUÇÃO
MAP
MAPA PROGRAMAVEL

const int crankPin = 8; //pin 8 for signal input


const int sensorPin = A2; // select the input pin for the potentiometer
int InjectorPin = 12; // select the pin for the LED
int sensorValue = 1; // variable to store the value coming from the sensor
int outputValue = 0;
int CrankSignal = 0;
int lastCrankSignal = 0;

void setup() {
// declare the InjectorPin as an OUTPUT:
pinMode(InjectorPin, OUTPUT);
pinMode(crankPin, INPUT);
}

void loop(){
CrankSignal = digitalRead(crankPin);

if (CrankSignal != lastCrankSignal) {
// if the state has changed, increment the counter
if (CrankSignal == HIGH) {

// read the value from the sensor:


sensorValue = analogRead(sensorPin);
// turn the InjectorPin on
outputValue = map(sensorValue, 0, 1023, 1500, 3500);
// change the analog out value:
digitalWrite(InjectorPin, HIGH);
// stop the program for <sensorValue> milliseconds:
delayMicroseconds(outputValue);
// turn the InjectorPin off:
digitalWrite(InjectorPin, LOW);
// stop the program for for <sensorValue> milliseconds:
// delay(30);
//(60)ms is 2000rpm
}
else{
digitalWrite(InjectorPin, LOW);
} // save the current state as the last state,
//for next time through the loop
lastCrankSignal = CrankSignal;
} }

You might also like