motorcycle blinking controller

yakke

New Member
Hi all,

I recently bought led pinkers for my motorcycle, but now they flash to fast because of the resistance. So i tought to make a controller for it myself, and also add a 4 warning lights function.

I want to control it with no extra switches, just the original left/right "tumble" switch.

so i have 2 inputs: left and right switch
and 2 outputs: led's led's on the left and on the right

the code for left and right blinking is allready ok, but for the 4 warning lights i can't get the code right.
i want them to work when i do: left right left right within 2 seconds for example.

I have a Picaxe 08M.

Can someone please help me with the code?

Sorry for my english, but i'm a dutch guy.
 

Attachments

Last edited:

lbenson

Senior Member
Welcome to the forum. First a matter of forum practice--you will get more people looking at your code if you embed it in your post within standard bulletinboard tags: [code]...[/code] I have done this below.

You say you have two input switches and you want 4 output conditions: off, right blinking, left blinking, alternate blinking. Typically a third switch would activate the alternate blinking, and I am not certain from your code how you intend to have it activated. You can do this on the 08M by moving the "right" output to pin 0 and using pin2 as another input.

You test for "b1 = 4" in several places. It is possible for b1 to exceed 4 without this test occurring (at least at simulation speeds), so you may want to change the test to "b > 3".

To debug your code, I would suggest trying it in the simulator. There it performs slowly enough so that you can see what is happening. Press the left turn signal input (pin4) on and off and watch what happens. Then press the left turn signal input. Try this for various durations and sequences. See if what you intended is what you get, and if not, what the values are which produce unintended results.

Code:
#picaxe 08M
main:
	
	if pin3 = 1 then PR
	if pin4 = 1 then PL
	let b1 = b1 + 1
	if b1 = 4 then rst
	goto main
	
PL:
	if b1 = 4 then rst
	if b0 = 10 then PLR
	high 1
	pause 300
	low 1
	let b0 = b0 + 3
	let b1 = b1 + 1
	goto main
	
PR:
	if b1 = 4 then rst
	if b0 = 10 then PLR
	high 2
	pause 300
	low 2
	let b0 = b0 + 4
	let b1 = b1 + 1
	goto main
	
PLR:
	let dirs = %00000110
	let pins = %00000110
	pause 300
	let pins = %00000000
	goto main
	
rst:
	let b0 = 0
	let b1 = 0
	goto main
 

MPep

Senior Member
Yakke,

As you have also posted your question in the Main forum (which is the correct place for it to go!), have you tried the code I posted there?

Mark.
 
Top