Show Posts
Pages: 1 ... 7 8 [9] 10
121  Forum 2005-2010 (read only) / Interfacing / Re: internal pullups enabled by default? on: December 22, 2006, 03:40:21 pm
I seem to remember that the internal pullup is disabled by default, but if you want to enable it, you actually can do so using

   pinMode (pin, INPUT);
   digitalWrite (pin, HIGH);

i.e. you write HIGH to the pin as if it were an output pin, even though you have already defined it as input.

Can somebody confirm this with certainty?
122  Forum 2005-2010 (read only) / Interfacing / Re: A whole lot of LEDs on: December 10, 2006, 07:40:24 pm
Hey Daniel,

Points well taken.  I have used this trick myself in a little pantry light I made for myself:  it uses 4 very bright yellow LEDs.  (I used a 555 timer chip in monostable mode so that the LEDs stay on for 1 minute, then turn themselves off.)  Before rigging them all up to share a resistor, I hooked them all up independently and measured the current drain, and they were very nearly identical.  The resulting pantry light has worked just fine for the past 2 months, and to look at them, I cannot tell any difference in the brightness.  I also felt the leads coming out of each LED and could not notice any heat, so I'm not worried about them burning out.

But, your warning is exactly right.  And, considering that resistors are dirt cheap, it's probably safer to go ahead and give each LED its own resistor.
123  Forum 2005-2010 (read only) / Interfacing / Re: A whole lot of LEDs on: December 10, 2006, 05:06:29 pm
In circuits like this, where you are driving a bunch of LEDs as a unit, I have found that you don't need a dedicated resistor for each LED.  For example, in the schematic given, you can calculate the equivalent resistance of all four 330-ohm resistors in parallel, which is 330/4 = 82.5 ohms.  So find a single resistor in the 80 to 90 ohm range, wire one side to the Arduino +5V, the other side to all the positive LED terminals connected together, and the rest of the circuit remains the same.

This works because the four resistors in the given schematic have, in theory, identical current flowing through them, and therefore identical voltage drop across them, so it is as if the bottom of all the resistors are connected, due to the voltage at the bottom of each being identical.  If they were connected, you would have four resistors in parallel, hence the 330/4 formula above.

Note that this does NOT work if you are trying to turn on/off LEDs independently of each other; in that case, each LED must have an independent resistor in order to safely limit the current flowing through the LED.  This trick also assumes that all the LEDs are the same kind, and all are connected to the same transistor driver, so that the assumption of identical current flowing through all resistors is identical.
124  Forum 2005-2010 (read only) / Interfacing / Re: Strange LED Sensor like behavior  (Video on: December 02, 2006, 08:14:35 pm
This thing with LEDs being sensitive to incoming light was interesting to me.  I did some simple experiments today where I hooked up a yellow LED to my digital multimeter.  When sunlight was shining on it, I got about 1.5V of potential measured.  When I tried to measure the current, the meter always said 0, so it was definitely less than 0.1 mA.  The voltage was much less when not in direct sunlight: about 0.1 V was a typical value.

So the bottom line is, if you want to use an LED as a light sensor, it's a good idea to feed it into a high-impedance input, perhaps even an op-amp configured as a negative feedback voltage follower.

- Don
125  Forum 2005-2010 (read only) / Interfacing / Re: Booting Arduino with rx active causes hang on: December 01, 2006, 05:00:08 pm
Just to follow up on Daniel's comment:

I don't know how it's done on the official Arduino board, but on the do-it-yourself serial model they use a hex inverter (7404) chip to provide a pair of inverters, one used for serial transmit and one for serial receive.  Perhaps you could replace one of the inverters with a 2-input NAND gate, and use the extra NAND input connected to a digital output on the Atmega8 to enable/disable the GPS serial input from software.  You might need to add a manual switch to bypass this gate when you want to upload new firmware.
126  Forum 2005-2010 (read only) / Exhibition / Re: Visual Studio C++ on: January 22, 2007, 03:00:54 pm
Here is a good place to start:

To set the baud rate (and other parameters), you fill in the DCB structure and pass it to SetCommState.  This assumes you have already successfully opened a handle to the comm port with GENERIC_READ | GENERIC_WRITE access.
127  Forum 2005-2010 (read only) / Exhibition / Re: Visual Studio C++ on: January 22, 2007, 11:04:03 am
I don't think doing serial communications in Visual C++ is a nightmare, so long as you stay away from some of the more advanced features like "overlapped I/O".  You just open a handle to the port using CreateFile.  The name of the port will look like:  "\\.\COM1".  Because this is C++, you need to escape the backslashes, so in your code it will look like "\\\\.\\COM1".  (Thanks Microsoft for not using forward slashes like every other O/S on the planet!)  Then use ReadFile to read from the device, WriteFile to write to it.  If you are an experienced programmer, you may want to create a separate thread to run your serial monitor code in, so that your main dispatch thread doesn't get stuck waiting for stuff to happen on the serial port.  If you aren't used to multithreaded programming, then yes, you are in for a nightmare!  smiley
128  Forum 2005-2010 (read only) / Exhibition / Re: Switchboard on: January 13, 2007, 05:16:45 pm
I once joked to a friend about having foot pedals for my computer, but now someone actually goes and does it!  That is a very clever use for Arduino.  I looked at your web page and saw the Arduino code, but I was wondering how exactly you did things on the O/S side... (Windows? Linux? other?)  If Windows, do you have to find which window has focus and inject keyboard messages into its particular message dispatch loop?  

I once wrote a program that would take over the mouse and send pretend mouse clicks to solve Minesweeper.  (I called my program "Minebroom".)  It would even grab pixels to figure out what the numbers were on the screen.  But I never had to do anything with the keyboard, so I am curious about the programming details.

Thanks for sharing...

- Don
129  Forum 2005-2010 (read only) / News / Re: Arduino 0007 available. on: December 26, 2006, 02:00:47 pm
Hey Mellis,

Excellent!  I will start working on that some time this week.  I am trying to contact the original author of the library patch (nrolland) to see if he wants to collaborate, since it was his idea in the first place.  If he is too busy I will be glad to take over for him.  In any event, assuming this thing becomes part of Arduino 0008, he should get credit for the idea.

When I have some changes ready to propose, should I contact you?  If so, what is the best way?  I figure I should run it by somebody official before releasing it out into the wild!


- Don
130  Forum 2005-2010 (read only) / News / Re: Arduino 0007 available. on: December 26, 2006, 09:31:54 am
Does this release include the patch mentioned in this article?  This is the one that makes the runtime code into a library, so that the linker excludes anything your program doesn't call.

(I have found this very helpful for squeezing more complicated algorithms into the limited space of the Atmega8.)

If not, I would like to volunteer to assist any way I can in getting this into the next release.  Testing, coding, etc... just let me know.

- Don
131  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Generating Composite Video on: January 09, 2007, 01:16:12 pm
My guess is that you might have some problems because of timer interrupts (or other interrupts?) messing up your timing.  Just as an experiment, try adding this to the end of your setup():

    cli();   // disable interrupts

Of course, this will mess up all kinds of stuff you might want to add later, like serial port I/O, use of timers, delay(), millis(), etc.

I say this because I was surprised when I tried generating radio frequency energy and encountered an unexpected tone modulated on top of what was supposed to be a pure carrier wave.  See here:
132  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: data storage options on: December 29, 2006, 04:11:05 pm
A trick I've heard about (but haven't tried) is to create a dummy file with junk in it, fighure out where that file starts on flash, then make sure you skip that many bytes (and don't write past the length of the file) when writing to the flash device.  I don't particularly like the sound of this, but it does have the potential of being the cheapest in terms of interface hardware and software development.

This will work only if you are lucky enough to get the file allocated all in a single fragment.  In general, a file on any filesystem (FAT, NTFS, etc) can be fragmented into multiple chunks, each chunk being an integer number of clusters.  The cluster size can be any power of 2 between 512 bytes and 64K.

It just so happens that my day job involves low-level systems programming with filesystems and partition tables for data backup.  Writing code to create a new file in a FAT filesystem is definitely non-trivial, especially if the file name doesn't fit in the old 8.3 character format.  There are interface chips out there (forget the name) that solve this problem for you.
133  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Arduino as a cheap DAQ-I/O alternative on: February 16, 2007, 09:35:56 am
Here is a simple sketch I wrote that allows you to read/write any digital/analog pin.  It works by sending simple commands via serial port from the computer to the Arduino board, which replies back on the serial port.  Currently I use it by just typing in the commands manually, but somebody could write a program that automates this on the computer side.  This could possibly be morphed into something like you are talking about.  Feel free to steal the code and hack on it!
134  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Just playing mp3 or other audio data from PC on: February 14, 2007, 11:30:12 am
People here will gladly help if presented with a "I tried this but it didn't work... what is going wrong?" kind of question, but it's beyond lazy to just ask someone to write your code for you...  smiley-razz
135  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Writing a function on: January 25, 2007, 12:12:34 pm
Follow-up:  I just tried a template function at it works fine:

template <typename type>
type Maximum (type a, type b)
    return (a > b) ? a : b;

void setup()
    Serial.begin (9600);

void loop()
    Serial.println (Maximum(3,4));
Pages: 1 ... 7 8 [9] 10