Negative and positive output for Arduino Pro Mini


I am new to the arduino world, but I trying to write a sketch for an arduino pro mini that can output 20mA of current from a 9v source what items would i need and also how can you convert it to a negative output?

Thank you

int pinNode_0 = 2;
int pinNode_1 = 3;
int pinNode_2 = 4;
int pinNode_3 = 5;
int pinNode_4 = 6;
int pinNode_5 = 7;
int pinNode_6 = 8;
int pinNode_7 = 9;
int pinNode_8 = 10;
int pinNode_9 = 11;

When you find yourself writing stuff like that, it's time to look at arrays.

output 20mA of current from a 9v source

How is that program related to your intended function?

Hi jremington,

I am not sure what you mean, to which program are you referring and I intend for the arduino to send out a small positive or negative charge.

Thank you,

The arduino cannot put out a "charge" it only has digital outputs that are 5 V positive. You need external hardware for anything else.

Thank you KeithRB, would you know what external hardware i would need? maybe a voltage convertor or regulator?

If your grounds are isolated, a 9 V source and 2 relays are all you need. However, you will only get 20 mA at a load resistance of 450 ohms. At any other resistance, something has got to give, either the 9 V or the 20 mA.

a quick search and found these hardware components for the task 0 -5 to 4 -20 mA

Thank you Ductor

I am not sure what you mean, to which program are you referring

I will try to be a bit more clear.
In your first post, you included a program.
Does the program you posted have anything to do with your question?

Oh Sorry, yea it does I wanted to know how would i write out the sketch to convert 9v to 20mA.

Thank you Jremington

You will also need a filter between the pwm output and the converter.
ie, with a pulse signal with 50% duty cycle to make a 2.5v dc signal.

Thank you all for your help. I want to know if there is a way anyone can show me how this would work in a sketch and Circuit Diagram I would greatly appreciate it.

Thank you all again.

I'm just guessing here, but do You intend to make a little "intstrument" with a 9v batteri and a Arduino Pro Mini. Like a 4-20mA transitter?
And this instrument will produce a 4- 20 mA signal, which you can variate with maybe a potensiometer , and also want to be able to revert the current flow?
Maybe you are going to run big 3PH AC motors with inverterdrives?

Anyway, if you use a Teensy 3.1, this wil actually have an analog output pin. And the Teensy is fully compatible with arduino program, its just like an Arduino, and nearly the same size as the Mini.

That's exactly what I want to do, Ductor.

I am new at this and have very little understanding of how the arduinos work. I have read plenty of books and websites on them, and made some cool devices, but trying to create my own device has proven to be much harder to do.

I thank you for all your help.