Confused!

HI folks, I'm very, very new to programming and am trying to design a small project for my Motorcycle that monitors the ambient light and turns on a relay for the lights, in addition to a turn signal function all in the same programme. I have produced these two projects, the "autoheadlamp" seems to work fine but the "indicator" one which seems to verify but won't work on my setup.. I would like to combine them into one piece of code can anyone help?

indicators.ino (1.31 KB)

Autoheadlights.ino (614 Bytes)

Please follow the advice on posting a programming question given in Read this before posting a programming question

In particular note the advice to Auto format code in the IDE and to use code tags when posting code here as it prevents some combinations of characters in code being interpreted as HTML commands such as italics, bold or a smiley character, all of which render the code useless

stevemac76:
HI folks, I'm very, very new to programming and am trying to design a small project for my Motorcycle that monitors the ambient light and turns on a relay for the lights, in addition to a turn signal function all in the same programme. I have produced these two projects, the "autoheadlamp" seems to work fine but the "indicator" one which seems to verify but won't work on my setup.. I would like to combine them into one piece of code can anyone help?

I'm not sure what you want to do in your autoheadlamp sketch but you only write a LOW to the LED, never a HIGH. Do you actually want the LED to turn on?

HI, don't know what's happened as the code definitely works and does write HIGH to the led... Like I say I'm a complete noob and will try to repost a more readable code

ToddL1962:
I'm not sure what you want to do in your autoheadlamp sketch but you only write a LOW to the LED, never a HIGH. Do you actually want the LED to turn on?

Doesn't that depend on how the LED is wired (and if it ever needs to be turned off)?

TheMemberFormerlyKnownAsAWOL:
Doesn't that depend on how the LED is wired (and if it ever needs to be turned off)?

True but his comment says LOW turns it off. The OP has a button and an LED. The LED stays off and the button toggles a flag. Pretty boring....

stevemac76:
HI, don't know what's happened as the code definitely works and does write HIGH to the led... Like I say I'm a complete noob and will try to repost a more readable code

I'm sorry. I was referring to your indicators.ino not the autoheadlamp.ino. The indicators sketch never turns on the LED.