Need help for a toggle switch code

Hi all. I want to modify an effect pedal with my arduino. I have managed to do all what I wanted excepted something with one of the toggle switches. This one has a strange behaviour and I can't do what I want with it so I come to you to see if someone can help me. Here is the problem, this is a spdt switch an led is connected to it, when I start my pedal, whatever the switch position is, the led is off, which means that wether the position is HIGH or LOW, the controlelr inside the pedal is LOW at start. So, does anyone know a way to do the same with arduino and that would be having the switch LOW when it starts even if it's HIGH? In a way, what I want to do is to convert the toggle switch into a momentary switch... Any help is welcommed. :.


The switch is momentary, the firmware in the effects unit is remembering the state.

No, it is a real toggle switch, I have opened it, I plan to control it with a transistor, so if I can do this toggle to momentary convertion, my project will not work.


there must be a way to covert the change of state from high to low or low to high into "pulses"?

A 555?

isn't there a way to do it by programming it?

I should imagine so, but a 555 will be cheaper.

How could it be cheaper as I would have to add electronic components?

Why don't you just trigger on [u]transitions[/u] of the switch, with LOW being the default?

That's exactly what I am looking for (I guess). I have done a lot of tests, none of them worked. If you have a lead to give to me I would be more than happy.

Look at the state of the switch. Is it the same as last time looked? No, so toggle your variable.

May need some debounce.

I have already done it, I have been able to invert the state of the switch, but not to tell him to be LOW when the program starts whatever would its position be.

Well, I can't see your code, so I can't tell you what you did wrong. Sorry.

I know and I am affraid I won't be able to show you all my mistaken tries. I have done several tests and I am now back to the square zero, simply trying to make the light on or off with my switch to understand what I did wrong. I know this is not a good way to ask for help in arduino's forums but I am desperate. Anyway, I'll try to find my old attempts and show them to you but I am not home now so I won't be able.