NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » make 1 or 2 pins function as a switch without a relay

September 06, 2010
by sporkalicious
sporkalicious's Avatar

I'm attempting to come up with a way to make the MCU take the place of a switch in an external circuit, using either one or two pins. I have an electric airsoft gun mounted on a turret I made based on the servosquirter code (fairly heavily modified so far, aside from the code to control the pump. I currently have a relay from pin 17 to ground that joins the trigger wires from the gun to make it start/stop firing, but would like to come up with a way to make it work without having to using either the MCU alone, or with solid state parts (ie. transistor/mosfet etc) I tried using the transistors that came with the kit, without any luck, though It may have been my lack of understanding the function of the parts. The gun is just a small motor, 4 AA batteries, and a little switch as far as electronics go, and I simply soldered two wires to the switch to allow it to operate simply by completing the circuit between the wires. Any help/insight would be greatly appreciated, I've been tearing my hair out for days trying to get this to work without that relay.

September 07, 2010
by Rick_S
Rick_S's Avatar

Based on your description, you should be able to wire the gun the same way the servo squirter tutorial did the pump motor. You will need to find out if the motor is hard wired to the positive terminal of the battery or negative. That would determine which side of the mosfet pair you would place the wires from your switch. In the video, the gun appeared to have a clear case so tracing the wires may not be too difficult even without disassembly.

If the motor has a wire that goes to the positive terminal of the battery holder and the other to the switch, you would take the motors swtich wire and attach it to the drain side of the mosfet pair. The other switch wire (which should to to the ground side of the battery) would attach to the mosfet pair source. The gates would then go to the nerdkit.

If the opposite is true (motor has a wire directly to negative battery side and switch has a wire directly to positive side) then the source / drain wires would be reversed. This would have the motor side of the switch would attaching to the source of the mosfet pair and the battery pack side of the switch attaching to the drain. The gate connections would remain the same.

Hope that helps,

Rick

September 07, 2010
by sporkalicious
sporkalicious's Avatar

After reading this I attempted to give it another go, what happens is as soon as i hook the gun to the source and drain, the gum hums and attempts to work, I can only assume the transistors are allowing a small amount of current to flow, after attempting to add/remove a transistor to the setup with no real change i went for broke and tried swapping the drain and source for a brief moment, and the gun instantly starts firing, could one or more of my transistors be the issue?

September 07, 2010
by Rick_S
Rick_S's Avatar

Photo's would help a lot...

September 07, 2010
by Ralphxyz
Ralphxyz's Avatar

Why don't you try lighting a LED using the transistor?

Once you have that working, dependable, you should be able to hook up your motor.

Ralph

September 07, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Sporkalicious,

Couple of questions. Have you tried taking a multimeter to the gun to figure out a little more of what you are dealing with. What is the voltage across the two ends of the switch?

What is the current being drawn when the motor is on? This will help you figure out if the transistor is limiting your current. If your model of how the gun works is accurate the current can be measured by putting the multimeter in current mode across the switch.

If you provide us with a diagram of how you think the electronics in the gun are laid out, and where you are putting the transistor in, we can let you know if you are going in the right direction.

Can't wait to see this feature working on your project!

Humberto

Post a Reply

Please log in to post a reply.

Did you know that negative numbers are represented in two's complement notation in binary? Learn more...