Led Switch Jump
Jimm2
Posts: 16
HI
I will explain the big picture to you. There is A kit that
you can buy for your truck. It plugs into your trail light plug, on the
Truck side.(A led light bar).
It goes below the tailgate and it consists of A bank of led light's. The led's
go from one side of the tailgate to the other side. About 4 feet.
When you step on the brake pedal, all
the led's turn on. When you step off the brake pedal, all led's turn off.
When you use the right turn single. The right side of the led's bar
(witch is half of the led's), turn's on and off, like your turn light does.
When the turn single flasher is switched off the led's are off.
What I am looking to do with the Propeller Chip is.
I want to make the same thing, but I want to change the way the flashing is done. Not on
and off, like A flasher. My way, left to right or one at A time.
I want to use A reed relay, as A switch. The coil part will plug
into the 12v comming from the traler plug,
(witch is both Brake light and turn light). The switch part will have 3.3v
and going into the Propeller Chip as pin (23).
(Trail Plug = Reed Relay = Propeller Chip (23) = Led's)
Propeller Chip Programing.
So when the switch is held down. The (brakelight) program will run untill the switch is let go.
(IN the program now, When you push the switch down the brakelight turn's on, then when you
let go of the switch it turn's off,
then it run's the rightturnlight program). I what it only to run the brakelight program, when
the switch is held down, then let go. This is what I need help with. Is there I way to jump from the
end of the (brakelight) program to the end of the (rightturnlight), so the Led's will just
turn offff.
So you hold down on the button, all the led's come on. When you let go of the button, all
the led's go off.
When you press the button down and released continously, it will run the (rightturnlight) and
only it. Then when you stop pressing it. All led's are off.
1.) button is left alone =(all led's are off)
2.) button is pressed down continoulsy = (brakelight)
3.) button is pressed down and released continously = (rightturnlight)
Last thing is...............................
If you leave the button alone might be caused by the lack of a Pull-down-resistor
between Propeller-IO-Pin 23 and ground. (I have A resistor there.)
This is what someone told me, to fix it.
The next issue is that a switch will bounce when it changes state. So you need some debounce code.
The simplest form is a delay after it switches state. Start with 1 second so you can see the change in your leds.
Will this work as A delay (waitcnt(clkfreq/4 + cnt)?????
Thank you
Thank you much..........
I will explain the big picture to you. There is A kit that
you can buy for your truck. It plugs into your trail light plug, on the
Truck side.(A led light bar).
It goes below the tailgate and it consists of A bank of led light's. The led's
go from one side of the tailgate to the other side. About 4 feet.
When you step on the brake pedal, all
the led's turn on. When you step off the brake pedal, all led's turn off.
When you use the right turn single. The right side of the led's bar
(witch is half of the led's), turn's on and off, like your turn light does.
When the turn single flasher is switched off the led's are off.
What I am looking to do with the Propeller Chip is.
I want to make the same thing, but I want to change the way the flashing is done. Not on
and off, like A flasher. My way, left to right or one at A time.
I want to use A reed relay, as A switch. The coil part will plug
into the 12v comming from the traler plug,
(witch is both Brake light and turn light). The switch part will have 3.3v
and going into the Propeller Chip as pin (23).
(Trail Plug = Reed Relay = Propeller Chip (23) = Led's)
Propeller Chip Programing.
So when the switch is held down. The (brakelight) program will run untill the switch is let go.
(IN the program now, When you push the switch down the brakelight turn's on, then when you
let go of the switch it turn's off,
then it run's the rightturnlight program). I what it only to run the brakelight program, when
the switch is held down, then let go. This is what I need help with. Is there I way to jump from the
end of the (brakelight) program to the end of the (rightturnlight), so the Led's will just
turn offff.
So you hold down on the button, all the led's come on. When you let go of the button, all
the led's go off.
When you press the button down and released continously, it will run the (rightturnlight) and
only it. Then when you stop pressing it. All led's are off.
1.) button is left alone =(all led's are off)
2.) button is pressed down continoulsy = (brakelight)
3.) button is pressed down and released continously = (rightturnlight)
Last thing is...............................
If you leave the button alone might be caused by the lack of a Pull-down-resistor
between Propeller-IO-Pin 23 and ground. (I have A resistor there.)
This is what someone told me, to fix it.
The next issue is that a switch will bounce when it changes state. So you need some debounce code.
The simplest form is a delay after it switches state. Start with 1 second so you can see the change in your leds.
Will this work as A delay (waitcnt(clkfreq/4 + cnt)?????
Thank you
CON _clkmode = xtal1 + pll16x _xinfreq = 1_000_000 LEDpin1 = 0 LEDPin2 = 17 SwitchPin = 23 OBJ led: "BreakandRightlights" Var long LastSwitchChange long RateThreshold long LastCNTValue long ResultCNT byte SwitchStatus Pub start Dira[noparse][[/noparse]LEDPin1]~~ Dira[noparse][[/noparse]LEDPin2]~~ Dira[noparse][[/noparse]SwitchPin]~ RateThreshold := 000_500_000 LastCNTValue := cnt repeat ResultCNT := cnt - LastCNTValue if Ina[noparse][[/noparse]SwitchPin] <> SwitchStatus 'is the state of the switch different from the last time it changed? LastCNTValue := cnt 'lets record this time SwitchStatus := Ina[noparse][[/noparse]SwitchPin] 'store this as the current switch status if ResultCNT > RateThreshold 'we have gone over our threshold with no change in the SwitchStatus 'this means either the switch was held down or not pressed outa[noparse][[/noparse]LEDpin1]~ If SwitchStatus == 1 'Switch was held outa[noparse][[/noparse]LED.BrakeLight]~~ else 'switch was not pressed outa[noparse][[/noparse]LEDpin2]~ 'the switch is changing faster than the threshold r else 'the switch is changing faster than the threshold rate outa[noparse][[/noparse]LED.RightTurnLight]~~
PUB RightTurnlight dira[noparse][[/noparse]0..19] := %11111111111111111111 outa[noparse][[/noparse]0..19] := %11111111111111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %01111111111111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00111111111111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00011111111111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00001111111111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000111111111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000111111111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000011111111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000001111111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000111111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000011111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000001111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000000111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000000011111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000000001111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000000000011111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000000000001111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000000000000111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000000000000011 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000000000000001 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000000000000000 waitcnt(clkfreq/4 + cnt) PUB BrakeLight dira[noparse][[/noparse]0..19] := %11111111111111111111 outa[noparse][[/noparse]0..19] := %11111111111111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000000000000000
Thank you much..........
Comments
As Cluso99 explains in your other post, there are some electrical issues that you must deal with before you can make it work, but software wise it isn't a very complicated project.
.S.
Each side probably hardwired.
so it would be hard to divide that half section in to 4 or 6 smaller sections for that rolling effect when using turn signals.
but could be done.
or build your own from scratch?
The cost of 150 bright LEDs is gone be pretty high.
·