Show Posts
Pages: 1 ... 6 7 [8] 9 10
106  Forum 2005-2010 (read only) / Interfacing / Re: measuring battery voltage on: January 21, 2007, 02:55:58 pm
Using the formulas here ...
http://en.wikipedia.org/wiki/Voltage_divider

... I would choose resistors such that:
1. There is little current constantly flowing through the resistors from +9V to GND, so their sum should be on the order of 100K or higher.  I don't know what the input impedance of the Arduino analog inputs are, but hopefully it is in the high megohms range, so it won't mess up the voltage divider math.
2. Fresh 9V batteries are actually above 9V.  Perhaps a simple divide-by-2 would work, such that 10V is converted to 5V, which yields the maximum 10-bit analog sample value of 1023.

Putting these together, two 47K resistors ought to do the trick.  One resistor goes from +9V to analog pin, and the other goes from analog pin to GND.  I notice my (homemade) Arduino tends to flake out when the supply falls below 6.5V, which means the analog pin will see 3.25V, which will show up as an analog reading of (3.25/5.00)*1023 = 665.   Maybe as a safety margin, your red LED should come on when the value drops below 700 or 750?

Also, keep in mind that real resistors are never perfectly accurate.  I highly recommend getting a digital multimeter if you don't already have one.   (Even a cheap US$30 one will be one of the best hobby electronics investments you have ever made!)  That way you can measure the real value of your resistors, plus you can measure the exact voltage your analog pin is seeing to double-check your math and wiring.

Hope this helps...

- Don
107  Forum 2005-2010 (read only) / Interfacing / Re: arduino mini & analong pins 6 & 7 on: January 15, 2007, 03:58:58 pm
Which processor are you using?  On the ATmega8, there are only 6 analog input pins: 0..5.
108  Forum 2005-2010 (read only) / Interfacing / Re: Arduino PS2 mouse interface on: January 08, 2007, 01:54:12 pm
Nice job!  I don't have a PS2 mouse right now, but it was interesting to see how the code worked.  Interesting that both X and Y are a single byte... are they actually X and Y, or are they delta-X and delta-Y since the last time you talked to the mouse?
109  Forum 2005-2010 (read only) / Interfacing / Re: Audio out using PCM (synth trial runs) on: January 06, 2007, 12:30:09 pm
Actually, I would like it if we could figure out how to get a faster version of analogRead also... it was bugging me because I was thinking of doing some faster sampling than 1kHz.  It would be really neat if we could get the sampling rate up above 10kHz, because I would like to experiment with recognizing sounds on a microphone hooked up to an analog pin.  For example: something that could decode the touch tone frequencies on a telephone back into the numbers that were pressed.  These frequencies are (all in Hz):  697, 770, 852, 941, 1209, 1336, 1477.  Since the highest is 1477, the sampling rate would have to be at least 2*1477, or about 3kHz.
110  Forum 2005-2010 (read only) / Interfacing / Re: resistors: 5V USB = 9V battery? on: January 07, 2007, 11:49:35 am
Yes, to use a 9V battery, you need to switch the jumper to "external", and connect + to the 9V terminal, - to the GND terminal.  The board has a built-in voltage regulator that converts down to exactly 5V, so long as the input is above 6.5V or so.  In fact, I hate buying expensive 9V batteries, so I power mine using 6 AA rechargeable Ni-MH batteries.
111  Forum 2005-2010 (read only) / Interfacing / Re: Several serial interfaces on: January 06, 2007, 05:50:56 pm
I am not the author, so this is just a guess...

To send or receive serial data, one must be synchronized with the other side.  At 9600 baud, there are 9600 bits per second, which is almost 10K bits per second.  That means each bit has to be transmitted in about 100 microseconds with almost perfect timing.  My guess is that with software driving the timing, that is about as good as you can get with a 16 MHz processor.

Or, maybe I'm totally wrong and the code could be improved!  smiley
112  Forum 2005-2010 (read only) / Interfacing / Re: Several serial interfaces on: January 06, 2007, 04:42:59 pm
The Atmel processor supports only a single hardware serial interface, but starting in Arduino-0007 there is a new SoftwareSerial class that you can use also for the other serial links.  It is a library that you can import now.
113  Forum 2005-2010 (read only) / Interfacing / Re: serial speed on: January 02, 2007, 10:27:06 am
I use 115200 baud all the time with mine and it works fine.  I don't know about higher speeds.
114  Forum 2005-2010 (read only) / Interfacing / Re: 2 led alternating on and off on: December 28, 2006, 04:47:56 pm
OK, you have a couple of problems with this line:

    if (ledaPin = HIGH)

First of all, you are using '=', which assigns the value HIGH to the variable leadaPin.  I think what you meant was '==', which compares the two for equality.  But this also has a problem, because the value of leadaPin is 6, and the value of HIGH is 1.  Asking whether 6 == 1 is not what you meant either.

Perhaps you could try:

    if (digitalRead(ledaPin) == HIGH)

but I don't see the point, because every single time you get to that line of code, you know that the value will be LOW, because that is the most recent value you wrote to ledaPin.

If I were trying to do literally what you describe, I would code it as follows:

Code:
char state = LOW;

void loop()
{
    digitalWrite (ledaPin, state);
    state = !state;    // toggle the current state
    digitalWrite (ledbPin, state);
    delay(1000);    // wait one second
}
115  Forum 2005-2010 (read only) / Interfacing / Re: 3.5v SPI? on: January 01, 2007, 10:33:43 am
I would be worried about using just a diode by itself, because of course it allows current to flow only one way.  When hooked up to a high-impedance input, it may serve to charge up the input pin like a capacitor, and not allow the charge to escape quickly enough when the +5V output goes back to 0V.  Another thing to consider is that diodes do not have a constant voltage drop.  The voltage drop depends on the amount of current flowing through the diode.  With a small enough current flowing due to high impedance, the 3.5V input pin may end up receiving higher voltage than it should.  So you might end up needing a diode with a pull-down resistor on the input pin, at which point you are using up as much real estate on your board as if you used 2 resistors.

It is possible to save space by mounting the resistors vertically, with one lead wrapped over in a U shape, as shown here:

116  Forum 2005-2010 (read only) / Interfacing / Re: 3.5v SPI? on: December 31, 2006, 06:31:11 pm
You might be able to get away with a simple voltage divider, using 2 resistors per I/O line.  Atmega8 outputs are +5V when high.  You want to convert this down to +3.5V, which is 3.5/5 = 0.7 times as much.  So you want to find two resistors R1 and R2 such that R2/(R1+R2) = 0.7 (or close enough).  Also, R1+R2 should be on the order of 10K to 100K.  This is large enough to avoid wasting a lot of power, but small enough so that the input impedance of the receiving device does not mess up the voltage level.

See the following for schematic:

http://en.wikipedia.org/wiki/Voltage_divider
117  Forum 2005-2010 (read only) / Interfacing / Re: DIY Touch Sensor on: December 31, 2006, 10:22:52 am
If you want a simple sensor that senses finger touch, here is another approach:

http://www.kpsec.freeuk.com/trancirc.htm

In the section "Darlington Pair", look at the schematic with the label "Touch switch circuit".  I have built these and they are surprisingly sensitive.  

The schematic says to use +9V, but I have used +5V and it works just fine.  Replace the 470-ohm resistor and the LED with a single 10K resistor, and attach the transistor collectors to one of your analog input pins.  

The voltage will be +5V when there is no touch, and will drop dramatically when you touch the sensor.  In fact, with some experimentation, you should be able to have your program react differently based on how much pressure you apply to the sensor.
118  Forum 2005-2010 (read only) / Interfacing / Re: DIY Touch Sensor on: December 30, 2006, 08:40:56 pm
This is not the same thing at all, but is a lot simpler:  you could just make a simple light sensor using a cadmium sulphide photoresistor in series with an ordinary resistor (I used 10K to make sure I wasn't wasting too much current).  Connect one side of the photoresistor to your +5V, the other side to the top of your ordinary resistor, and the bottom of your ordinary resistor to GND.  Attach the junction where the photoresistor connects to the ordinary resistor to one of your analog input pins.  What you have here is a basic voltage divider.  

The voltage received by the analog input pin increases when the light hitting the photoresistor is brighter, and decreases when the light is darker.  Now put a lamp where it shines on the photoresistor.  When you put your hand between the light and the photoresistor, the analog input pin can detect the shadow and react to it in some manner.  You will have to experiment using a voltmeter (or just printing sample values to the serial port) to figure out what your algorithmic thresholds should be.

Of course the behavior will depend on ambient light, so the program might get messed up if the Arduino board is near a window on a bright day, etc.  Not nearly as cool as that capacitance sensor, but hey, it's a LOT easier to build (or cheaper to buy, depending on how you look at it)!
119  Forum 2005-2010 (read only) / Interfacing / Re: computer control on: December 17, 2006, 10:36:21 am
If you use a relay, be sure to connect a protection diode reverse biased across the relay coil, as illustrated in this diagram:



This will protect the transistor from harmful voltage surges when the relay is turned off.
120  Forum 2005-2010 (read only) / Interfacing / Re: Controlling 32 powerful leds via 5 digital pin on: December 26, 2006, 07:34:35 pm
Wow, 32 amps!  You are going to either need to get the circuit breakers on your house rewired, or get a whole bunch of gerbils running on the generator wheels!  smiley

Seriously though, I would be curious to hear what this project is... or is it TOP SECRET?
Pages: 1 ... 6 7 [8] 9 10