hello ron...float switch has three wires to indicate each level of fuel low,mid or high every time fuel reaches a particular level particular wire gives out 5v and some 0.5amps current so we built the circuit to reduce the current since our micro controller can take only max of 20ma so...in our current reduction circuit just ttl logic 7408 and in series with a 560 ohms resistor that gave us some 8ma output current so we were happy to connect it to board but when we connect it the atmega32 board is driving the voltage i dont know why??????????what can be the best solution please reply...as quickly as possible
OK, now we are getting somewhere. This also makes sense. Well, almost sense. When the pins of the uC are programmed as a DO (Digital Out) they can sink or source a limited amount of current and I believe that is where you came up with the 20 mA.
You mentioned that the switches have 3 wires? If you have levels of low, mid and high the switch should have 4 wires total? The 5 volts is coming from somewhere? If I apply 5 volts to the switch common then I can understand the 5 volts but there would be a 4th wire as the 5 volts is coming from somewhere?
You mention the uC has internal pull up correct? That tells me if you configure the pins for DI (Digital In) the pins will float at between 3.3 and 5 volts depending on the uC. Placing a low on any of those pins will produce results. But ..... Let me maks a drawing to explain this. Back soon.
OK attached is a very rough sketch of a uC using digital inputs driven by switches. The resistors drawn in the uC are the internal pull up resistors. The uC is programmed so the Digital In/Out pins D0, D1 and D2 are Inputs. I just used simple switches that are NO (Normally Open but when the tank is full they are all closed. The switches in my example likely could have been drawn better. Since when the tank is full all switches are closed as the tank level decreases the switches will sequentially open top to bottom.
Switch 3 will open and D0 will go high and the code for that D0 pin would look something like:
if pin D0 = 1 then
do something the tank has 1/3 less than full
if pin D1 = 1 then
do something else the tank is down 2/3
Something along those lines is where I think you should be going. This is based on your mention about the internal pull up resistors. The DIO pins should be programmed as DI.
The attached was done in haste so I hope you get the idea.
Ron