Programmable Shift Light

Hi. Hope this is allowed. :o
I'm looking to commission someone to design the circuit and write the code for a programmable shift light.

The rpm signal will come from a non latching hall effect sensor mounted on the engine pulley.
I nead to switch on 3 banks of different coloured led's at 3 different rpm values. If possible I would like to be able to set those values using push buttons at say 100 rpm intervals.

I hope that makes sense and if anyone is interested or has already done this please get in touch via here or at carboncopiesltd@yahoo.co.uk.

Thanks in advance.

I've suggested to the mods that they move this to Gigs and Collaborations

Thank you.

Hello, Wozsher!
I guess the code is simple.
You need to use PulseIn function:
https://www.arduino.cc/en/Reference/PulseIn
+
if operand.
Like so:

#define a 100
#define b 200
#define c 300
#define pin 5
#define GREENLED 10
#define YELLOWLED 11
#define REDLED 12
unsigned long duration;

void loop()
{

duration = pulseIn(pin, HIGH);
// reset leds
digitalWrite(GREENLED, LOW);
digitalWrite(YELLOWLED , LOW);
digitalWrite(REDLED , LOW);

// set leds
if(duration < a){digitalWrite(GREENLED, HIGH);}
else if(duration < b){digitalWrite(YELLOWLED , HIGH);}
else{digitalWrite(REDLED , HIGH);}

// pause
delay(200); //ms

}

Dmitron1036:
Hello, Wozsher!
I guess the code is simple.
You need to use PulseIn function:
https://www.arduino.cc/en/Reference/PulseIn
+
if operand.
Like so:

#define a 100
#define b 200
#define c 300
#define pin 5
#define GREENLED 10
#define YELLOWLED 11
#define REDLED 12
unsigned long duration;

void loop()
{

duration = pulseIn(pin, HIGH);
// reset leds
digitalWrite(GREENLED, LOW);
digitalWrite(YELLOWLED , LOW);
digitalWrite(REDLED , LOW);

// set leds
if(duration < a){digitalWrite(GREENLED, HIGH);}
else if(duration < b){digitalWrite(YELLOWLED , HIGH);}
else{digitalWrite(REDLED , HIGH);}

// pause
delay(200); //ms

}

Thank you very much for your help. I'm totally new to Arduino so this is going to be a very steep learning curve.

I said I'd be back. Whilst trying to verify the code at the voidloop() point I get the following error.
voidloop was not declared in this scope.

All help appreciated. Thanks

Hmmmm I get a different error, namely that there's no setup(), which is because your contractor :wink: gave you a sketch with no setup().

If I put this line in:

void setup(){}

... it at least compiles. But an empty setup() won't be correct since it needs pinModes() at least to set the leds to outputs.

Post the actual code you can't compile. (edit: do you actually have voidloop writeen like that with no space, not void loop?)

Thanks for the quick reply.
I have no space in voidloop.
On my phone at the moment but I'll post up the full code asap. Cheers

The full code is like this:
// define values here:
#define a 600000 // 1000000us * 60 s/m /100rpm
#define b 300000 // 1000000 * 60/200
#define c 200000 // 1000000 * 60/300
#define pin 5 // the digital pin to read pulse duration
#define GREENLED 10 // Digital pin nomber
#define YELLOWLED 11 // Digital pin nomber
#define REDLED 12 // Digital pin nomber
// custom project variables:
unsigned long duration;///< pulse duration, the length of the pulse (in microseconds) or 0 if no pulse is completed before the timeout (unsigned long)
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(GREENLED, OUTPUT);
pinMode(YELLOWLED, OUTPUT);
pinMode(REDLED, OUTPUT);
// serial port init
Serial.begin(115200);//115200 baud!!!
}

// the loop function runs over and over again forever
void loop()
{

duration = pulseIn(pin, HIGH);
// reset leds
digitalWrite(GREENLED, LOW);
digitalWrite(YELLOWLED , LOW);
digitalWrite(REDLED , LOW);

// set leds
if(duration < a){digitalWrite(GREENLED, HIGH);}
else if(duration < b){digitalWrite(YELLOWLED , HIGH);}
else{digitalWrite(REDLED , HIGH);}

// pause
delay(200); //ms

}

Well that compiles because it has the space in "void loop" and has a setup() unlike what you posted before.

So I have no idea what you're asking now.

Dmitron 1036 thanks for the new code.
I'm trying to adapt it to my needs and below is where the problems start.
I'm totally new to this so please be gentle

As I see, In my code:

digitalWrite(YELLOWLED , LOW);

and in your code:

digitalWrite(YELLOWLED . LOW);

  • point instead of comma.