Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int IGBT_out = 3; // output for IGBT to pin 3
- int delays[14] = {e1000, e2000, e3000, e4000, e5000, e6000, e7000, e8000, e9000, e10000, e11000, e12000, e13000, e14000}; // delays in uS. Points 1000-14000rpm.
- float rpm;
- float timeold;
- int dwell; // time to charge the coil
- float pulse_number; //variable to store pulses from trigger
- void setup()
- {
- // put your setup code here, to run once:
- Serial.begin(9600);
- pinMode(IGBT_out, OUTPUT);
- digitalWrite(IGBT_out, LOW);
- attachInterrupt(0, pulse, RISING);
- dwell = 2000;
- }
- void pulse()
- {
- pulse_number++;
- }
- void loop() {
- if (pulse_number >= 5)
- {
- rpm = 60.0f*1000000/(micros() - timeold)*pulse_number;
- timeold = micros();
- pulse_number = 0;
- Serial.println(rpm, 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement