How can you use a 9.6V external circuit for a pin input to Arduino mini?

I am attaching an Arduino Mini to a toy rifle in order to use it in conjunction with a computer game. The Arduino Mini will detect a trigger pull and then send a message to fire a "bullet" in the game. I believe the input voltage value for pin 3 must be 5 volts (not sure if the amps matter in this case). The trigger/switch is attached to an existing 9.6V 1600mAh battery-driven circuit that must remain intact (it is not an option to make the switch 2 pole or remove the existing circuit that is driving other weapon functions). The battery charge actually ranges from 9 to 11 volts, depending on charge. From the forum posts, a voltage divider is a valid course of action, but I am not certain of the resistor selection. The equations are giving me weird values that I would like to have validated with more experienced folks...

Question 1 - Due to the battery voltage variation, what would be the best wattage and resistance values for R1 and R2 for this use case to stimulate pin 3?

Question 2 - Does anything look stupid in the diagram as illustrated?

Question 3 - Is there a better method of doing this, or does a voltage divider work as good as anything?

Voltage divider will work - try 10k for the lower half and 15k for the upper half - that will multiply the voltage by 0.4, so 11V goes to 4.4V, 9V goes to 3.6V, both will register as logic HIGH.

The 330ohm resistor in your diagram is completely weird - take it out.

You need to common the ground rails for both circuits or it won't work (a circuit is exactly that, a circuit - joining two things by one wire isn't going to allow a current to flow!)

There is an issue of motor generated noise on the external circuit - one possibility is to add a capacitor of a few hundred pF across the bottom of the voltage divider. The 15k resistor should protect pin 3 anyhow, the capacitor will reduce the chance of noise-induced spurious switching on pin3 (if you use this as an interrupt source this will matter).

I will try the the 10 and 15k resistors and take a look at the voltage.

The intent of the 330ohm resistor was to replicate the "pull down down" resistor from other Arduino tutorials (image).

"If you disconnect the digital i/o pin from everything, the LED may blink erratically. This is because the input is "floating" - that is, it will randomly return either HIGH or LOW. That's why you need a pull-up or pull-down resistor in the circuit." ("http://www.arduino.cc/en/Tutorial/Button")

Looking at the schematic, do you still think 330ohm resistor is useless in this role?

Are you saying that running a jumper wire from the negative on the 9.6V battery to the USB ground is a good idea? Shouldn't the 3.6 to 4.4 volts from the voltage divider flow to the ground present on the USB?

So I can replicate the work, what equation were you using to get 3.6 and 4.4?

button_schem.png

Looking at the schematic, do you still think 330ohm resistor is useless in this role?

After you make the required connection between the battery minus and GND the 330 ohm resistor is worse than useless. It will completely mess up the voltage divider because it will be in parallel with R2.

So I can replicate the work, what equation were you using to get 3.6 and 4.4?

Ohm's law, twice for each calculation.

When battery is 9 Volts:
I = E / Rtotal = 9 / (10K + 15K) = 9 / 25K = 0.36 mA
Vout = I x Rout = 0.36mA x 10K = 3.6V

When battery is 11 Volts:
I = E / Rtotal = 11 / (10K + 15K) = 11 / 25K = 0.44 mA
Vout = I x Rout = 0.44mA x 10K = 4.4V

Don

You really should rethink the entire circuit since the noise from your motor will probably keep the circuit from working reliably. You might have better luck using an opto-isolator rather than a voltage divider.

Don

I ended up using the opto-isolator and it works in its intended role.

One issue that came up was the corrolation in time between the cycling of the rifle, the message sent to the simulation, and the presentation in the image generator. The rifle firing in the simulation was a millisecond behind the rifle report. That millisecond mattered with respect to accuracy and experience. The overall effort was successful.

We think it is primarily an issue with the simulation. There was some talk about slightly adjusting the timing of the rifle discharge and figuring out a way to speed up the messaging protocol...but we have not revisited the issue as the rifle is working as is currently.

Thank you for the assistance.

RS