0% found this document useful (0 votes)
9 views1 page

(Agious) Dios

The document describes code for controlling ignition and RPM of an engine. It uses a Hall effect sensor or induction sensor on pin 8 to read crank position and an analog potentiometer on pin A2 to set ignition timing. Pin 12 controls the injector and is pulsed on and off based on crank position and timing set by the potentiometer.

Uploaded by

Swliw II
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

(Agious) Dios

The document describes code for controlling ignition and RPM of an engine. It uses a Hall effect sensor or induction sensor on pin 8 to read crank position and an analog potentiometer on pin A2 to set ignition timing. Pin 12 controls the injector and is pulsed on and off based on crank position and timing set by the potentiometer.

Uploaded by

Swliw II
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 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