Show Posts
Pages: 1 ... 102 103 [104] 105 106 ... 265
1546  Using Arduino / Installation & Troubleshooting / Re: Can't download with 1.X, can with 023 on: June 13, 2013, 04:12:02 pm
Do you have !!! in your sketch anywhere?
1547  Using Arduino / Installation & Troubleshooting / Re: Is this a bootloader error? on: June 13, 2013, 04:10:38 pm
If the light doesn't flash is there a problem with the ATmega16U2 chip? My computer won't find my Uno R3 any more. The green power LED lights (on USB or 9v supply) but the orange transmit light won't. I can't talk to the chip if the PC won't connect, right? I'm a ME and this computer science stuff is new to me.
Instead of tagging the same thing on everyone else's thread, why not start your own - you might get a response then.
1548  Using Arduino / General Electronics / Re: can soldermask + paste keep a package from shorting to vias? on: June 13, 2013, 03:44:10 pm
The exposed pad is there for a reason.  If you fail to use it you risk the component going out of specification and breaking.

Either select a different component that doesn't require the exposed pad, or re-design your board to use the exposed pad.
1549  Using Arduino / Programming Questions / Re: Need help troubleshooting error on: June 13, 2013, 03:41:36 pm
Am I blind, or do I not see anywhere at all where you ever turn OFF any of the LEDs?

Also, how is your button wired up?
1550  Using Arduino / Programming Questions / Re: Size of array on: June 13, 2013, 09:04:59 am
There isn't one.

There is no such thing as an unoccupied position in an array - every entry has a value.

You could go through and count the number of entries that match a certain criteria.
1551  Using Arduino / Programming Questions / Re: Size of array on: June 13, 2013, 07:32:23 am
sizeof returns the size of the allocated memory for the array.  This will never change.

To find out how long a string is (string as in null-terminated character array) use the strlen() function.
1552  Using Arduino / General Electronics / Re: Mosfet switches without a cause on: June 13, 2013, 04:12:38 am
OK, I thought a bit about the whole "long cable => low pulldown" theme - and I don't get it.

As long as my button is not pressed, the pulldown resistor pulls my input-pin to ground. At that moment the value of the resistor is completely irrelevant.

As soon as my button is pressed, I have a series of resistors between 5V and GND:

R(C) is the cable resistance and R(P) is the pulldown-resistor.

That is a voltage-divider, the voltage "x" that is applied to my input is as follows:

x = 5V/(RC+RP) * RP

As long as RC is as small as possible, we have

x = 5V / RP * RP = 5V

As soon as I have a hiogher value for my cable-resistance, let's say RC = 1k (which is far beyond realistic!), my RP gets interesting:

x = 5V / (1k+RP) * RP

let's fill in some values:

100o   =>   x = 5V / (1k+0,1k) * 0,1k = 0,45 V
1k   =>   x = 5V / (1k+1k) * 1k = 5V / 2k * 1k = 2,5V
10k   =>   x = 5V / (1k+10k) * 10k = 5V / 11k * 10k = 4,54V
100k   =>   x = 5V / (1k+100k) * 100k = 5V / 101k * 100k = 4,95V

So in my opinion, the higher the resistor is, the better my input-value should be.

Realistic, cat5-cables have a DC-resistance of 50-150Ohm/km, so anything above 1k should be perfect.

So why do you say that I should try a lower pulldown-resistor because of the long cables? I don't want to argue, but I'd love to understand! smiley

It's all to do with current flow and noise rejection.  A lower resistance causes more current to flow.  That's what the "strength" of a pull up or pull down resistor is all about.  A "weak" one, like inside the Atmel chip, is typically 20K.  "Average" is 10K.  "Strong" is 1K-4K7.

When you press the button, the button, cable and resistor form a voltage divider.  That mid point of that divider is then connected to the gate of a MOSFET, which is a capacitative element.  Current needs to flow into that gate to turn it on, or out of it to turn it off.  The more current you have available in the voltage divider to turn it on, and the lower the resistance on the pull-down to turn it off, the better it is.  But at the same time you don't want to waste current smiley-wink
1553  Using Arduino / Programming Questions / Re: Flickering 4 x 7 segment display on: June 13, 2013, 03:40:42 am
You're modifying V every loop iteration, but you're only getting its starting value once every 500 ms.

You should have another variable that you store the temperature in.  Get the temperature into that variable every 500ms, and then copy it into V every loop.
1554  Using Arduino / Programming Questions / Re: Understanding the 4051Multiplexer code on: June 12, 2013, 12:14:31 pm
... except you want to shift *before* the or, not after, or the last bit will always be 0 and you'll lose your first bit off the end.
1555  Using Arduino / Programming Questions / Re: Understanding the 4051Multiplexer code on: June 12, 2013, 08:36:04 am
You can read multipex[count] quite happily should you want to.  Putting the LEDs in an array will make the whole thing more efficient.  However, you could short-cut it:

for (count = 0; count < 8; count++) {
  selectMultiplex(count); // do whatever you need here
  digitalWrite(led[count], digitalRead(A0));
1556  Using Arduino / Programming Questions / Re: Understanding the 4051Multiplexer code on: June 12, 2013, 06:36:14 am
You always read from the analog pin that the multiplexer is connected to.  So, if it's wired to A0, then you always read from A0.

1. Switch MUX to input 0
2. Read from A0
3. Compare with threshold value (NOT "HIGH")
4. Do something
5. Switch MUX to input 4
6. Read from A0
7. Compare with threshold value
8. Do something
... etc ...
1557  Using Arduino / Programming Questions / Re: PCINT question on: June 12, 2013, 04:21:22 am
and how do I explain what they do?
You read the data sheet for the chip that's on your board.  They are all detailed in there, with what each bit means, and how you configure them to do different things.
1558  Using Arduino / Programming Questions / Re: Passing variable name over Serial on: June 12, 2013, 04:15:37 am
You are right in that what you want to do is not possible.  Once the program is compiled it loses all concept of variable names.

The way you are doing it is reasonable for small quantities (though I'd stay away from the String library and use C strings and functions, like strcmp()).  For larger quantities you might want to consider a couple of arrays (one for pin names, one for pin numbers), or an array with a custom data structure.  Then you iterate through the array(s) looking for a match.
1559  Using Arduino / Programming Questions / Re: Flickering 4 x 7 segment display on: June 12, 2013, 03:59:01 am
Timing is critical - so is the sequence of what you do.

Whenever I do multiplexed displays I do the following sequence:

1. Set all segments off
2. Set current digit off
3. Increment digit
4. Wrap digit number to 0 if needed
5. Set needed segments on
6. Set current digit on
7. Slight delay (not using delay()) and repeat.

Note especially the inclusion of step 1 as the first thing to do with each pass - turn off all the segments.  This helps to reduce the ghosting you see.

I usually have 1-6 running from within a timer interrupt, so that you don't need to worry about your code interrupting the fluidity of the display overmuch.  It's also useful to have an array containing a bitmask for each digit 0-9 which is then mapped to the output pins, then you don't have to have a massive case statement; a simple lookup in the array, then map that to your IO pins using bitshifting / masking.

For instance, here is the update code from a system of mine (not written for the Atmel though, so the library won't work for you, but you get the idea):
void LEDMux::update()
    unsigned char v;
    unsigned char i;
    unsigned char c;
    static unsigned char b = 0;

    for (i=0; i<this->nAnodes; i++) {
        digitalWrite(this->anodes[i], 0);
    for (i=0; i<this->nCathodes; i++) {
        digitalWrite(this->cathodes[i], 0);

    if (this->digit >= this->nCathodes) {
            this->digit = 0;
            b = b & 0b11111;

    if (this->brightness[this->digit] == 0) {

    if (b < (1<<(this->brightness[this->digit]-1))) {
        c = buffer[this->digit];
        c = c - ' ';
        c = c % 96;

        v = digits[c];
        if ((this->dp >> this->digit) & 1) {
            v = v | 0b10000000;

        for (i=0; i<this->nAnodes; i++) {
            digitalWrite(this->anodes[i], v & (1<<i) ? 1 : 0);
        digitalWrite(this->cathodes[this->digit], HIGH);

(This one has most of the ASCII set in it's character array, but you can use just the digits.  It happily supports 8 digits, and uses a char array to store the data, and inherits the Print class and implements write so you can print to it like Serial, or an LCD smiley-wink )
1560  Using Arduino / General Electronics / Re: Mosfet switches without a cause on: June 11, 2013, 05:50:13 pm
What value pull-down resistor do you have on the input?  10M is quite a long length of cable.

You might be better off using pull-up instead of pull-down, and using a smaller resistor, say 1KΩ.
Pages: 1 ... 102 103 [104] 105 106 ... 265