text:
Using ArduinoISP on an Arduino Uno to program an ATmega328
I have an Arduino Uno R3 and would like to use it to program a blank ATmega328 on a breadboard. I've followed the instructions for the 8 MHz version on http://arduino.cc/en/Tutorial/ArduinoToBreadboard with an added 10K pullup resistor on the RESET pin of the ATmega328 on the breadboard; and I've uploaded the ArduinoISP sketch from the Arduino 1.0.5 distribution to my Uno.
I've also added the metadata for my setup: the following is the contents of  ~/sketchbook/hardware/breadboard/boards.txt:
atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=stk500v1
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=arduino:standard

I've also added the following section to my ~/.avrduderc file:
part
    id          = "m328";
    desc        = "ATMEGA328";
    has_debugwire   = yes;
    flash_instr     = 0xB6, 0x01, 0x11;
    eeprom_instr    = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
              0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
              0x99, 0xF9, 0xBB, 0xAF;
    stk500_devcode  = 0x86;
    # avr910_devcode    = 0x;
    signature       = 0x1e 0x95 0x14;
    pagel       = 0xd7;
    bs2         = 0xc2;
    chip_erase_delay    = 9000;
    pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
         "x x x x x x x x x x x x x x x x";

    chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
         "x x x x x x x x x x x x x x x x";

    timeout = 200;
    stabdelay   = 100;
    cmdexedelay = 25;
    synchloops  = 32;
    bytedelay   = 0;
    pollindex   = 3;
    pollvalue   = 0x53;
    predelay    = 1;
    postdelay   = 1;
    pollmethod  = 1;

    pp_controlstack =
    0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
    0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
    0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
    0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
    hventerstabdelay    = 100;
    progmodedelay   = 0;
    latchcycles     = 5;
    togglevtg       = 1;
    poweroffdelay   = 15;
    resetdelayms    = 1;
    resetdelayus    = 0;
    hvleavestabdelay    = 15;
    resetdelay      = 15;
    chiperasepulsewidth = 0;
    chiperasepolltimeout = 10;
    programfusepulsewidth = 0;
    programfusepolltimeout = 5;
    programlockpulsewidth = 0;
    programlockpolltimeout = 5;

    memory "eeprom"
    paged       = no;
    page_size   = 4;
    size        = 1024;
    min_write_delay = 3600;
    max_write_delay = 3600;
    readback_p1 = 0xff;
    readback_p2 = 0xff;
    read = " 1 0 1 0 0 0 0 0",
           " 0 0 0 x x x a9 a8",
           " a7 a6 a5 a4 a3 a2 a1 a0",
           " o o o o o o o o";

    write = " 1 1 0 0 0 0 0 0",
            " 0 0 0 x x x a9 a8",
        " a7 a6 a5 a4 a3 a2 a1 a0",
        " i i i i i i i i";

    loadpage_lo = " 1 1 0 0 0 0 0 1",
              " 0 0 0 0 0 0 0 0",
              " 0 0 0 0 0 0 a1 a0",
              " i i i i i i i i";

    writepage = " 1 1 0 0 0 0 1 0",
            " 0 0 x x x x a9 a8",
            " a7 a6 a5 a4 a3 a2 0 0",
            " x x x x x x x x";

    mode        = 0x41;
    delay       = 20;
    blocksize   = 4;
    readsize    = 256;
    ;

    memory "flash"
    paged       = yes;
    size        = 32768;
    page_size   = 128;
    num_pages   = 256;
    min_write_delay = 4500;
    max_write_delay = 4500;
    readback_p1 = 0xff;
    readback_p2 = 0xff;
    read_lo = " 0 0 1 0 0 0 0 0",
          " 0 0 a13 a12 a11 a10 a9 a8",
          " a7 a6 a5 a4 a3 a2 a1 a0",
          " o o o o o o o o";

    read_hi = " 0 0 1 0 1 0 0 0",
          " 0 0 a13 a12 a11 a10 a9 a8",
          " a7 a6 a5 a4 a3 a2 a1 a0",
          " o o o o o o o o";

    loadpage_lo = " 0 1 0 0 0 0 0 0",
              " 0 0 0 x x x x x",
              " x x a5 a4 a3 a2 a1 a0",
              " i i i i i i i i";

    loadpage_hi = " 0 1 0 0 1 0 0 0",
              " 0 0 0 x x x x x",
              " x x a5 a4 a3 a2 a1 a0",
              " i i i i i i i i";

    writepage = " 0 1 0 0 1 1 0 0",
            " 0 0 a13 a12 a11 a10 a9 a8",
            " a7 a6 x x x x x x",
            " x x x x x x x x";

    mode        = 0x41;
    delay       = 6;
    blocksize   = 128;
    readsize    = 256;

    ;

    memory "lfuse"
    size = 1;
    min_write_delay = 4500;
    max_write_delay = 4500;
    read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
           "x x x x x x x x o o o o o o o o";

    write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
            "x x x x x x x x i i i i i i i i";
    ;

    memory "hfuse"
    size = 1;
    min_write_delay = 4500;
    max_write_delay = 4500;
    read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
           "x x x x x x x x o o o o o o o o";

    write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
            "x x x x x x x x i i i i i i i i";
    ;

    memory "efuse"
    size = 1;
    min_write_delay = 4500;
    max_write_delay = 4500;
    read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
           "x x x x x x x x x x x x x o o o";

    write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
            "x x x x x x x x x x x x x i i i";
    ;

    memory "lock"
    size = 1;
    min_write_delay = 4500;
    max_write_delay = 4500;
    read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
           "x x x x x x x x x x o o o o o o";

    write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
            "x x x x x x x x 1 1 i i i i i i";
    ;

    memory "calibration"
    size = 1;
    read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
           "0 0 0 0 0 0 0 0 o o o o o o o o";
    ;

    memory "signature"
    size = 3;
    read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
           "x x x x x x a1 a0 o o o o o o o o";
    ;
;

So I thought I'd be good to go: I've set the programmer type to ArduinoISP and the board type to ATmega328 on a breadboard (8 MHz internal clock) in the IDE.
However, when I try to either upload the Arduino bootloader, or use the Upload using programmer feature on the Blink example, I get this:
avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

Full output:
/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega328 -cstk500v1 -P/dev/ttyACM0 -b19200 -Uflash:w:/tmp/build6008715511691559175.tmp/Blink.cpp.hex:i

avrdude: Version 5.11.1, compiled on Apr 28 2013 at 18:46:46
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/usr/share/arduino/hardware/tools/avrdude.conf"
         User configuration file is "/home/cactus/.avrduderc"

         Using Port                    : /dev/ttyACM0
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
         AVR Part                      : ATMEGA328
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
avrdude: Send: A [41] . [80]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [02]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [81]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [01]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [82]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [12]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [98]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
avrdude: Send: A [41] . [84]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [85]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [86]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [87]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [89]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: Send: A [41] . [81]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [01]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [82]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [12]
avrdude: Recv: . [10]
avrdude: Send: B [42] . [86] . [00] . [00] . [01] . [01] . [01] . [01] . [03] . [ff] . [ff] . [ff] . [ff] . [00] . [80] . [04] . [00] . [00] . [00] . [80] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: E [45] . [05] . [04] . [d7] . [c2] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: P [50]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: AVR device initialized and ready to accept instructions

Reading | avrdude: Send: V [56] 0 [30] . [00] . [00] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: V [56] 0 [30] . [00] . [01] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
################avrdude: Send: V [56] 0 [30] . [00] . [02] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
################################## | 100% 0.06s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

avrdude: Send: Q [51]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]

avrdude done.  Thank you.

I've double-checked and triple-checked, I've rebuilt the whole circuit on another breadboard with another ATmega328, I've even checked the jumper cables one by one, they all work.
How do I use my Arduino Uno as an ISP to upload code to this blank ATmega328?

Feeling really stupid about it in retrospect...
One last thing I tried was taking the ATmega328P out from the Arduino Uno and plugging the blank ATmega328 in its place, thinking I could use the Uno programmer as such to burn the bootloader on the chip. That didn't work and I don't know if it's supposed to work.
However, to plug the new chip into the DIL on the Uno, I had to bend the DIP legs inwards slightly to give it a smaller straddle. After seeing that it didn't work, I plugged the ATmega328P back into the Uno and plugged the ATmega328 back into the breadboard. However, this time, because of the smaller straddle, it slipped in deeper into the breadboard, the plastic package actually touching the board. And with this setup, wiring it up again via the Arduino and using the ArduinoISP I was able to burn both the bootloader and (via the 'Upload with programmer' functionality) test programs to it.
TL;DR: I didn't have the blank ATmega328 properly plugged into the breadboard...

Hehe so many times I've done something similar. :P

By the way, when checking connections it is always good to test for continuity from pin to pin. That way you pick up these kind of problems.

@geometrikal: how would I do that? I don't see how I could clip an alligator clip onto the tiny part of the DIP leg that sticks out of the breadboard.

Buy a multimeter with probes (e.g. http://www.thomasnet.com/articles/image/digital-multimeter.jpg). Can get a cheap set for < $20. Pretty handy for troubleshooting.

Do you have another UNO or similar? Try getting the boot loader upload working on a stock board just to confirm it is not the programmer. 0x000000 usually means it can't talk to the chip being programmed.

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

This is the clue to the solution. The signature is different between different versions of the ATmega328, for example:

ATmega328-PU
ATmega328P-PU

and so on...
You can google on "arduino signature error ATmega328P" to find the solution.
One hint is: http://forum.arduino.cc/index.php?topic=201920.0
I can be more specific if you post the version off the ATmega328 you have.

No (valid) AVR has a 0x000000 signature.


text:
util/delay.h from arduino _delay_ms not delaying in accurate time with my hardware configuration
I have configured my arduino as a flash programmer and i'm sending data to an atmega328P. It is actually working and the data is send to my atmega328. But what is strange that the _delay_ms from  from the Arduino library is not delaying in accurate seconds.
_delay_ms(1000) who should wait from 1s, is actually more 8 seconds from my atmega328P hardware point of view.
My question is what could possibly turn the program wrong. I'm strongly assuming that this a misconfigured clock cycle from my Atmega, but this is my newbie guess,  it can be something else, that's why I'm posting my question here. Can someone can hint me what's wrong with my configuration?
Here's the sample code, a dumb toggle pin on / off:
#include <util/delay.h> // from arduino library

/*
*/

 DDRB |= 0b0000001;

  while (1) {
    PORTB = 0b00000001;
    _delay_ms(1000); // it should be 1 second, but on my hardware it is more ~8 seconds

    PORTB = 0b00000000;
    _delay_ms(1000);
  }

And my configuration is (from arduino IDE)
Arduino Pro / pro Mini (3,3v 8 Mhz) / Atmega 328
I have tried with
Arduino Pro / pro Mini (5v 16 Mhz) / Atmega 328
expecting that more power will affect speed, but the result is actually the same.

It's likely to be the CKDIV8 fuse is set because it's the default, although I'm not sure how you change the fuse settings when using an Arduino as a programmer.

At a 30000 ft. level, it's because the defined F_CPU value doesn't match your hardware. This can happen because the incorrect device is chosen in the IDE or because the device is misconfigured in boards.txt, or because the hardware is somehow different from what is expected.
Given that you are using a bare ATmega328P, assuming that you've selected the correct crystal, and that the apparent time scale is 8x, it is likely that the CKDIV8 fuse is set. This means that the chip is running at 1/8 the crystal speed. You will need to unprogram (set to 1) bit 7 of the low fuse byte in order to reset it. Use AVRdude from the command line to read the low fuse byte (-U lfuse:r:-:h), set the bit (lfuse | 0x80), and then write it back (-U lfuse:w:0xnn:m).

Hi Ignacio. Yes it is exactly what happened. The clock speed was 1/8 speed because of that. I have resolved my problem with using avr-gcc and avrDude from command line. Setting the clock speed at 8000000 (F_CPU) resolved my problem, i think arduino IDE was using 1Mh instead. I have also tried your solution from arduino IDE and it worked like a charm too.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Interfacing Arduino through USB or I2C?
I am planning to connect multiple Arduinos to my Raspberry Pi. There are basically two ways I can achieve that:

Use an USB hub. Each Arduino will then be available through ordinary serial commands both for reading and writing. The USB hub I have is powered and can handle both communications and powering the Arduinos.
Use I2C, so that the Arduinos are I2C slaves of the Raspberry Pi.

Since USB is used for updating the Arduino, I don't have the best feeling about using this same connection for "management" tasks.
Are there any known disadvantages to using the pre built USB socket on
the Arduino in "production", any best practises or similar saying that I should not do
this? Is this USB socket meant to be used for debugging and code deployment only?
The plan is to let the computer send commands to the Arduinos using a serial protocol. The computer will automatically detect whenever an Arduino is connected and immediately send a "hello" command over serial. The Arduino is then supposed to send back its "name" and a list of capability keywords. A capability may be "motion-sensor". The computer will then know that it can ask the Arduino if it has detected motion. Other capabilities may be "temperature-sensor", "barometric-sensor", "lights".
It's for a generic open source home automation system/robotics system I am working on creating a framework for.

Personally, I'd look at using a bused asynchronous serial scheme, a bit like RS485 but perhaps without the differential drivers/receivers if the distances are short, since you can software tri-state the ATMega's serial output pin. If you either use soft serial or bare ATmegas without the USB interface chips (or pull the series resistors to isolate them), this means the only hardware you need is a piece of wire - no hubs, no muxes, etc. Actually, this would work best with Leonardo's where you have the USB interface for programming and the hardware serial free for coms.

One complication you should be aware of is that in its default configuration, an Arduino Uno (and I assume that is what you’re talking about) will automatically reset whenever a serial connection is opened to it. This is easily bypassed with a capacitor between RESET and GND, but not taking it into account might make for hours of debugging fun.
The other complication is that just after a power up or RESET, an Arduino will delay for a second or two to listen for a programmer connection on the serial port, but that’s something you’ll have to take into account anyway.

I would go with USB rather than I2C for these reasons:

The Arduino can be powered via USB so there is no need for extra power supplies.
The system will work with PCs, making it easier to develop the code and the product more versatile.
USB cables are commercially available with standardised sockets. I2C cables would have to be made to specification (e.g. this app note) and would require some kind of additional socket for robust termination.
The Arduino Wire (I2C) library will hang if you disconnect the cable in the middle of waiting for a byte.

A good product will be robust and easy to use. One thing you may wish to consider is to create an internet of thing (IoT) type system. This involves the Arduinos sending sensor data to the web via the RPi. It could be that the RPi is a dumb conduit for the Arduinos, or it could collate the data and present itself as the end device. Check out Xively for details. I made a basic system to do the former, it is on github here.

The plan is to make a web app framework so whenever you hook something into a computer and that computer is running this software, the arduinos will add them self to the UI.

In my opinion, think USB on the Arduino is stable enough for production use.* There are ways to rename your Arduino if someone would connect it to a computer.
I think the real problem with this approach is people tampering with it. I know it's open source and all, but do you really want users (if it does get produced on a big scale, which is unlikely, but possible) without much tech knowledge plugging it into their computer?
If none of that sounds like a problem to you (and the delay/reset problems outlined by others isn't a big deal), I'd say go for USB. It's pretty easy to use, and it's universal, thus someone could connect the system to their computer if you developed the software for PC.
*Assuming you're using a full Arduino in a production environment, you won't care about if it shows up to the computer as "Arduino Uno."

This is an open source project so being open for tampering is no problem whatsoever. I want people to take the framework and make their own stuff.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Why does increasing resistance make a capacitive sensor more sensitive?
From the Capacitive Sensor Page on the Arduino website, it states the following:

The capacitiveSensor method toggles a microcontroller send pin to a new state and then waits for the receive pin to change to the same state as the send pin. A variable is incremented inside a while loop to time the receive pin's state change. The method then reports the variable's value, which is in arbitrary units.

AND

Use a 1 megohm resistor (or less maybe) for absolute touch to activate. With a 10 megohm resistor the sensor will start to respond 4-6 inches away. With a 40 megohm resistor the sensor will start to respond 12-24 inches away (dependent on the foil size)...

However, as mentioned above, what I'm measuring is the time taken to change state, and I understand that more resistance = more time taken = higher value, how exactly does increasing the resistance make the sensor more sensitive, allowing it to respond without even touching it (i.e., inches away)?
Am I not simply increasing the time taken to change state by increasing resistance? How would that make it more sensitive?!?

A capacitor is created from two conductors with a dielectric between them. The capacitance of the capacitor is determined by the surface area of the conductors and the distance between them. The larger the conductive surface, the higher the capacitance. The further apart the conductors, the smaller the capacitance. Using a higher resistance means that you can use a smaller capacitance, i.e. be further away from the sensor, to get the same results.

Thanks for taking the time to reply again Ignacio, i think i get what you mean about the bolded sentences. However, if i am acting as the conductor in a capacitive sensor, what would be the other conductor and dielectric in this case? I find it amazing that i am able to trigger the sensor without even touching it! How would i (acting as a capacitor) even store the voltage produced without even being in contact?

The other conductor is the wire. The dielectric is the air between. Capacitors are capacitors, regardless of what they're made of.

I had a feeling that was the case! Thank you for fast,concise and easily understood answers, i've upvoted your comment and answer in addition to accepting them !


text:
How do I know if a board fits my requirements?
I'm new to Arduino and I saw on their website that there are many different kinds of boards.
What are the differences, or to be more specific, how would I know which board meets my requirements? I understand that the shields can be connected to the board, but are some boards that do not support certain shields?
Another thing, is it possible to connect external sensors to an Arduino board or there are special sensors that can communicate with the board? I want to use weight sensors.

Things to consider when picking an Arduino board:

Do I want native keyboard/mouse support? If yes: you'll need the Leonardo (or it's breadboard mountable equivalent) or the TRE (not released, dual MCU board).
Do I want a small form factor and/or have it breadboard mountable? If yes, choose a board like the Mini/Micro/Nano/etc.

If you want to make it even smaller, either get a board without USB built in or try using an ATTiny

Am I computing large numbers with it? If yes: use the Due, Galileo, or TRE (not released yet)
Do I want video/audio? If yes: TRE is the only way to go as of now (but it's not released yet).
Do I need a USB host (and not want to have an external shield)?  If yes, use the Mega ADK (limited support), Yun, TRE (again, not released yet), or Galileo.
Do I need WiFi/ethernet built in? If yes; use the Yun, TRE (still, not released yet), Ethernet board, or Galileo.
How many pins do I need (and how many of each type)?

Digital: simple ON or OFF. Use these for buttons, simple lights, some communication, etc.

Stay away from the Due if you don't want to mess with 3.3V logic. Most other boards are 5V. You can work around this with either voltage dividers (doesn't always work) or level shifters. As far as I know, you can't really do much if a sensor provides max 5V; level shifters AFAIK only work with digital signals.

UART Pins: these are the pins that you can use the serial library on. (Note: this doesn't include the software-serial library). One of these on most boards is connected to a USB chip.
SPI Pins: These are pins which are used by a form of communication (like on the Ethernet shield).
Inturupt Pins: These can trigger an event when the signal getting sent to the board changes. There are a couple of different settings, but this can be used for near-instant response time when low latency is critical.
PWM Pins: pins that go on and off to simulate a lower voltage. It does this by turning it on and off very rapidly. This is used often for dimming LEDs and controling the speed of a motor.
Analog pins: pins that can read a voltage and convert it into a number.

The Arduino Due has a much higher precision rate, as it has more possible values and it has less voltage, thus much more accuracy.

All of these types of pins can act as a digital pin. All of these, except the analog pins, are under the "digital pin" section of your Arduino board. I didn't go into the technical aspects of the pins; I explained then in the simplest way I could.

I left a lot of boards out of this list, but this should give you some things to think about when choosing a board. There's a lot of weird quirks with this list, so it's incomplete, especially with the types of pins. You'll just have to do research and figure out what you need and if a board can meet your needs. Just make sure to not plan two things on the same pin, especially when mixing different shields and sensors! Shields do take up pins.

Shields: they are pretty much compatible with every board except for if the board is 3.3V (newer shields can adapt automatically) OR if it's a breadboard mounted board, like the Nano. There are ways to work around this problem, but it's very difficult.

To start with arduino you need to have some factors in consideration, for example the board you will chose, arduino UNO being the starting board for most beginners, if you are already an experienced programmer in C++ you might want to try more powerful boards.
You have a pretty good overview of all of them in this link :
http://arduino.cc/en/Main/Products
Also there are hundreds of shields out there, you will find some in the link above.
Adafruit also has some interesting ones, https://www.adafruit.com/search?q=arduino, you can even find them on ebay, and you can always buy individual sensors, LEDs, buttons etc, and plug them in directly or in a breadboard.
Sparkfun has a big variety of very interesting sensors.
There is also a lot of open source shields out there, you can check a very simple one i designed myself :
http://electropepper.org/projects/prototyping/item/proto-i-os-arduino-v1-0

thanks for the help :) , I am familiar with C++, I just want to know if any board is supporting on the various shields or there are some special requirements?

I forgot to say most, if not all shields are compatible across the several arduino boards, that’s supose to be the idea at least.

The usual suggestion I give to people new to Arduino is to get a Starter Kit (either from the store or from a local reseller): it contains an UNO, plenty of sensors and actuators and a projects book.

There are some good answers already, but here are a some secondary considerations

Many Arduino boards use a ceramic resonator rather than a crystal as their timing source. This rules out using them in critical timing applications. For instance you might need to add a real time clock board if you need to keep track of time of day.
The boards based on the Atmega328 chip only have three timers, and one of these (Timer 0) is used by the delay() function, which is in turn used by other libraries. Timer 1 and timer 2 get used if you include the PWM and tone libraries. The boards based on  the 2560 chip have 6 timers, which is a lot more generous.
If you want to count external inputs at speed (i.e. up to 4MHz), you need to access the Tn pin of the appropriate timer counter(s). On the UNO, only T0 is exposed to the outside world, and the timer is already in use. Even the Mega2560 boards only seem to expose T0 and T5.


text:
Using arduino mega with linear encoder to control movement of dispenser
My goal is to deliver very small quantities (100 microliters) of fluid to the (approximate) center of a 25mm x 75mm surface. My first idea was to repurpose an old inkjet printer for the project. I thought I'd load the fluid dispensers (probably 3ml syringes) into the unit where the ink cartridges would go and use an arduino to manipulate the linear encoder used by the printer to tell the dispenser unit where to go.
Main problem at the moment is that I'm having trouble getting the dispenser unit to go exactly where I want it to. I've tried incorporating the PID library into my code to get the head to oscillate around the desired position until it stops at the right location. However the oscillation never stops and the head always moves beyond the desired position.
I'm trying to figure out the easiest way to get this done. Maybe that'll mean moving away from using the inkjet printer but I'd like to get some feedback here before I make any decisions.
Code:
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
#include <PID_v1.h>

//
//// Interrupt information
//// Int 0 on pin 2
//// Int 1 on pin 3 Not used
//
#define encoderI 2  // Interrupt 0 is use
#define encoderQ 4 // Only use one interrupt in this example
#define maxPos   3733 // left hand side
#define minPos   0    // right hand side
#define maxSpeed 150
#define minSpeed 0
#define Freq     1600
#define maxWait  500 //12 millisec before stopping the motor
#define maxPositionError 10 //max error from actual desired position. It is approximately 0.032 of an inch
#define PIDsampleTime 25

//
//// Tuning parameters
double kP=0.37; //Initial Proportional Gain
double kI=2; //Initial Integral Gain
double kD=0.020; //Initial Differential Gain
double Drive = 0;

int outputSign;
//
double Setpoint, Input, Output;

PID myPID(&Input, &Output, &Setpoint,kP,kI,kD, DIRECT);

volatile int ActualHeadPosition; //current position will be modified with each interrupt
volatile int PreviousHeadPosition; //Previous position will be modified with each interrupt
volatile uint8_t Speed = maxSpeed;                      //Speed for the dispenser head
volatile unsigned long lastPositionTime;
volatile int setPoint;
volatile int Err;
volatile int lastError;
volatile int Integral;

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
//
//// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *dispenserDCMotor = AFMS.getMotor(1);
//
void setup() {
     Serial.begin(9600);           // set up Serial library at 9600 bps also this is the baud rate per second for the input?
     pinMode(encoderI, INPUT); //pin #2 is assigned as an input
     pinMode(encoderQ, INPUT);
     attachInterrupt(0, handleEncoder, CHANGE);
//
     AFMS.begin(Freq);
//
//    // Set the speed to start, from 0 (off) to 255 (max speed)
    dispenserDCMotor->setSpeed(Speed);
    dispenserDCMotor->run(FORWARD);
//    // turn on motor
    dispenserDCMotor->run(RELEASE);
//
  Setpoint = 1800;
  myPID.SetSampleTime(PIDsampleTime);
  myPID.SetOutputLimits(minSpeed, maxSpeed);

    //turn the PID on
    myPID.SetMode(AUTOMATIC);

     //Initialize procedure should be the first thing
    Initialize();
}

void loop() {
  Serial.print(", ActualHeadPosition: ");Serial.print(ActualHeadPosition);Serial.print(", SetPoint: ");Serial.println(setPoint);

  setPoint = 1800;
  Input = ActualHeadPosition;
  outputSign = myPID.Compute();
  Err = setPoint - ActualHeadPosition;
  Serial.print("PID Output");Serial.print(Output);Serial.print(" Error: ");Serial.println(Err);
  Speed = Output;
  if (Err > 0){
    moveLeft();
    Serial.println("moveLeft");
  }
   else if (Err < 0){
     moveRight();
     Serial.println("moveRight");
  }

};
//
void handleEncoder(){
  lastPositionTime = millis();
   PreviousHeadPosition = ActualHeadPosition;
   if(digitalRead(encoderI) == digitalRead(encoderQ)){
     //dispenser is moving to the left
     ActualHeadPosition++;
   }
   else {
     //dispenser is moving to the right
     ActualHeadPosition--;
}

 }

void moveLeft(){
  uint8_t i;
  dispenserDCMotor->run(FORWARD);
  dispenserDCMotor->setSpeed(Speed);
}

void moveRight(){
  uint8_t i;

  dispenserDCMotor->run(BACKWARD);
  dispenserDCMotor->setSpeed(Speed);
}

boolean isMotorMoving(){
  if (((millis() - lastPositionTime) > maxWait))
    return false;
  else
    return true;
}

void Initialize(){
    //Move to origin
    moveRight();
    while (isMotorMoving()){
  //    Serial.println("MOVING!");
  delay(10);
    }
    ActualHeadPosition = 0;
    PreviousHeadPosition = 0;
    dispenserDCMotor->setSpeed(0);
    dispenserDCMotor->run(RELEASE);

}

maybe you just have to tune your pid settings

The easiest option, using the code you have, is to spend a little time tuning the PID algorithm. The lines you are interested in are these
double kP=0.37; //Initial Proportional Gain
double kI=2; //Initial Integral Gain
double kD=0.020; //Initial Differential Gain

PID takes a setpoint and a current location, calculates error, and uses it to make a new output that should sent the location to the setpoint. It does this by adding
P*(error)+I*(all historic error added together)+D*(recent change in error)
By changing the multipliers P, I, and D, you change how it reacts to different situations. In your system, the D value will have very little effect (at least in my experience). You should probably keep that where it is, or even just set it to 0.
The P value controls direct response to error, and should be the main component in your setup. Try increasing this to make it move faster, and mildly decrease the oscillations.
The I value controls how much all historic error affects output. It is the factor leading to all the oscillations. Lowering it will make your output settle sooner. It also assists when fighting other constant forces, or if static friction keeps the head locked in one position too close for the P term to overpower. My guess is in your isolated and low friction system, it should be very low.
Increment these values slowly (.05 at a time maybe) and experiment, you should be able to fix your oscillations and make the system behave how you want.

Based on the description, the system is underdamped, and increasing D may help a lot.  Decreasing I can help too - I is most useful in correcting standoff errors - when it never actually reaches the target.

"I" is useful for such errors, but I suggest lowering it because the inkjet printer rails should not have much problem with friction or outside forces. In my experience, "D" is nearly inconsequential in similar systems, but I encourage experimentation. In any case, an underdamped system should need the damping ratio increased to 1, but increasing "D" would lower the damping ratio if my math is correct, based on this article: https://en.wikipedia.org/wiki/Damping#Example:_mass.E2.80.93spring.E2.80.93damper

I haven't worked with inkjet printers, so I may be offbase. I was working off my memory, reinforced by this As I understand it, when the error is dropping quickly as you approach the target, D dials down the gain, helping prevent overshoot.

I was referencing a model of PID as altering the coefficients on a 2nd order Diff EQ, but your link directly on the tuning of PID could be more accurate, depending on the actual characteristics of his system. experimentation is key.

The reason why your slide/microarray microdispenser continually oscillates about a point rather than dispense the fluid containing your cells/DNA sample specifically at a particular specified/designated point on your slide/microarray is due to your code below:
if(digitalRead(encoderI) == digitalRead(encoderQ)){
     //dispenser is moving to the left
     ActualHeadPosition++;
   }

   else {
     //dispenser is moving to the right
     ActualHeadPosition--;
}

which tells the Arduino to actuate the motor regardless of the values stored in the vars encoderI & encoderQ.

You can try changing this part of the code to the following instead:
`if((digitalRead(encoderI) == digitalRead(encoderQ)) && ActualHeadPosition != setPoint){
//dispenser is moving to the left
ActualHeadPosition++;
}
else if (ActualHeadPosition != setPoint) {
//dispenser is moving to the right
ActualHeadPosition--;
}
Also, make sure to changeSetpoint = 1800;in 'void setup()' tosetPoint = 1800;` instead. Please note that due to comment limitations in Stack Exchange, in places where there are large spaces, this is actually a line break.


text:
How to create delays in AVR assembly language
Hi i'm new to AVR assembly language so i was trying to get delay function to create 1 ms , 100us, and 1us  delays to do that i need to figure out what to replace nop's with below here (mainboard arduino uno r3 ATmega328
Thank you.
"delay_ms%=:    nop                 ; code to replace  nop  \n"
"delay_100us%=: nop                 ; code to replace  nop  \n"
"delay_1us%=:   nop                 ; code to replace nop  \n"
"               sbiw r30,1          ; decrement ms count (r31:r30)\n"
"               brne delay_ms%=     ; loop to delay_ms while > 0  \n"
"               ret                 ; return from subroutine      \n"

The rest is below.
word millisecs;
Serial.begin(9600);
}
void setup() asm volatile(
"          ldi r16,0x3F    ; r16 = 00111111\n"
"          out 4,r16       ; set pins 8-13 as outputs in DDRB\n"
::: "r16");
millisecs = 1000;            // 1s blink delay
Serial.begin(9600);
}
void loop()
{
long starttime = millis();        // make a note of the start time

asm volatile(
// jump to "blink" - ie jump around the delay_ms subroutine
"            rjmp  blink%=        ; relative jump to 'blink' \n"
"          ldi r16,0x3F    ; r16 = 00111111\n"
"          out 4,r16       ; set pins 8-13 as outputs in DDRB\n"
::: "r16");

registers used:
r31 - millisecond count (lo byte)
r30 - millisecond count (hi byte)
r17 - 100 microsecond count
r16 - 1 microsecond count
Overall delay (ms) = r30:r31 * r17 * r16
---------------------------------------------------------------------*/
"delay_ms%=:    nop                 ; code to replace  nop  \n"
"delay_100us%=: nop                 ; code to replace  nop  \n"
"delay_1us%=:   nop                 ; code to replace nop  \n"
"               sbiw r30,1          ; decrement ms count (r31:r30)\n"
"               brne delay_ms%=     ; loop to delay_ms while > 0  \n"
"               ret                 ; return from subroutine      \n"

This is a pure programming question and probably should have remained on stackoverflow, rather than been migrated here.

its atmega328 so 16mhz but how many clock cycles would that be 16000 for 1 millisecond?

AVR LibC already has macros that do this, provided F_CPU is set correctly.
// Note: The Arduino IDE gets the value for F_CPU from boards.txt
#define F_CPU xxxxxxxxxx

#include <util/delay.h>

 ...

_delay_ms(1);
_delay_us(100);
_delay_us(1);


text:
How does the Arduino handle serial buffer overflow?
How does the Arduino handle serial buffer overflow?  Does it throw away the newest incoming data or the oldest?  How many bytes can the buffer hold?

For hardware serial ports you can see in HardwareSerial.cpp that the buffer size varies depending on the amount of RAM available on the particular AVR:
#if (RAMEND < 1000)
    #define SERIAL_BUFFER_SIZE 16
#else
    #define SERIAL_BUFFER_SIZE 64
#endif

For a software serial port in SoftwareSerial.h the receiver buffer size _SS_MAX_RX_BUFF is defined as 64 bytes. In both cases it stops attempting to insert received data into the queue when it is full, so you could get a mix to old and new data depending on how you're retrieving data from the queue.
Ideally it would be best to ensure the buffer always gets emptied in a prompt manner to avoid the buffer filling. Maybe take a look at timers and implementing a simple state machine if your problem is related to other code blocking the main loop.

I get the impression that if I transmit data to the Arduino and don't have an active "puller" of data on the Arduino side then if more data arrives than can fit in the buffer, it will be discarded.  Can you confirm that?  I had naively assumed that the transmitter would block until space available to hold the data became available.

I just looked through all that code (under /usr/share/arduino/hardware/arduino/core/arduino/HardwareSerial.cpp) and can confirm what you wrote here. The only thing I would add is that since the SRAM is 2K (RAMEND>1000) then that if statement will always use 64 rather than 16 on a Nano or an Uno. So if one would want to expand the size of the ring buffer that would be the place to change it

Receiving
You can see from the source of HardwareSerial that if an incoming byte finds the ring buffer full it is discarded:
inline void store_char(unsigned char c, ring_buffer *buffer)
{
  int i = (unsigned int)(buffer->head + 1) % SERIAL_BUFFER_SIZE;

  // if we should be storing the received character into the location
  // just before the tail (meaning that the head would advance to the
  // current location of the tail), we're about to overflow the buffer
  // and so we don't write the character or advance the head.
  if (i != buffer->tail) {
    buffer->buffer[buffer->head] = c;
    buffer->head = i;
  }
}

I get the impression that if I transmit data to the Arduino and don't have an active "puller" of data on the Arduino side then if more data arrives than can fit in the buffer, it will be discarded. Can you confirm that?

Yes it will be discarded. There is no software or hardware flow control, unless you implement your own.
However with a 64-byte buffer, and receiving data at (say) 9600 baud, you get one byte every 1.04 ms, and thus it takes 66.6 ms to fill up the buffer. On a 16 MHz processor you should be able to check the buffer often enough that it doesn't fill up. All you really have to do is move the data from the HardwareSerial buffer to your own, if you don't want to process it right now.
You can see from the #if (RAMEND < 1000) check that the processors with 1000+ bytes of RAM get the 64-byte buffer, the ones will less RAM get the 16-byte buffer.

Sending
Data that you write is placed in a same-sized buffer (16 or 64 bytes). In the case of sending if the buffer fills up the code "blocks" waiting for an interrupt to send the next byte out the serial port.
If interrupts are turned off this will never happen, thus you do not do Serial prints inside an Interrupt Service Routine.

I believe you're off by an order of magnitude: at 9600 baud, you get a byte every ~0.1 ms, so it only takes 6.6 ms to fill up the buffer.

At 9600 baud you get 9600 bits per second. Since each byte is 10 bits (8 data + 1 start bit + 1 stop bit) then you get 960 bytes per second. 1/960 = 0.001042 s - that is one byte every 1.04 ms.

Ahh of course, bits not bytes! Thanks for the correction.

So Nick, please answer this for me:  If I have a Pi running Python sitting at a ser.readline() waiting for input as a data logger, and it is fed via serial by Arduino taking readings then sending them as a batch with tab delimeters, then using delay(120000) so the batches come in every two minutes, the Python innards probably immediately read in each character until it encounter a newline, at which point it releases the whole line as a return value.  So I don't have to worry about the Arduino buffer size even if I am sending 80 characters total, eh?  Would that be a good assumption?

Yes, the sending buffer size won't matter in this scenario. A small buffer would slow down the sending (slightly) but if you are doing a lengthy delay anyway you won't care.


text:
Making analog telephone calls?
How can we make the Arduino board interact with old, analog telephone, and to make phone calls?
I guess it involves connecting the board to the telephone with some specific cable (how it's called?)
In addition, I assume it will require us to use the telephone low-level dialing protocol (in order to actually interact with the phone and to send commands). Where can I read about it?
Is there a reason to concern about conversation between the digital/serial board and an analogous device?
By the way, I've read that analog telephones have relatively high voltages that can easily damage the board. I'd love to get any information about things like this, related to connecting Arduino to analog telephones, in order to know about such issues and about what to be concerned and to explore.
Thanks a lot!

Buy an external voice modem with a RS-232 connection. Connect it to a RS-232C shield. Use AT commands to dial numbers and pick up calls. Use voice AT commands to transmit or receive audio.
Never attempt to connect the telephone line directly to an Arduino since, yes, you will fry it. The voltage is all wrong in the first place, and goes even higher when the phone line rings.

Or something like this (which I did not know existed until 5 minutes ago) with proper isolation.

Connect a microcontroller to a telephone line is a rather technical task and requires knowledge concerning the operation of the line, but it is not an impossible task, although it can be dangerous, and sample some nasty shocks if you're not prepared for such work.
Initially you should build a rectifier circuit, mainly for its polarizing power circuit, since you do not know which is the antibody positive your telephone line but know that tensions are measured inversely ie, when measured with respect to ground (GND) the measures will be negative, this is because it was discovered that the poles of the batteries used to be gnawed less well when connected to the system.
A second step is you develop a small coupler to avoid connecting your circuit directly to the telephone line. For this you can use a pair of low-pass filters, which are placed at each connection point of the line after the bridge rectifier, and the downside of the bridge rectifier is connected to ground your circuit with this filter. And the plus point is connected to a PWM output of your controller.
Other important information you can not connect the PWM port directly to this filter, because the voltage levels in the telephone line are quite different, namely:

When the line rings you get a voltage exceeding 60V oscillating above 20Hz.
When the line is in standby mode it remains between 30V and 48V as your carrier and region.
When the line is busy or because your circuit or another extension you will have a voltage between 6V and 12V.
Already the audio modulation in their line occurs with peak 0,7Volts equivalent to 3dBm therefore its PWM output should give output like this.

To match the level of your line voltage with the telephonic system you can use a voltage divider which has an output of 0 to 0,7Volts ie when the door PWM pulse maximum output voltage of 5V should be 0,7Volts the divisor resistive. Another way is to use an operational amplifier having a gain reverse, thus reducing output. you can also use a optoacoplado circuit with 4n25 and thus polarize the phototransistor for such variation with the pulses in your diode.
Another important component in this circuit is a pair of diodes to be done clipping the signal, ie, as our voltage limit for audio is 0,7Volts after the filters put a couple of diodes between the positive and negative of your signal filtered in the bridge rectifier, so prevent signals above this level reaches the arduino when ouver noise on the line.
More Information: http://carlosdelfino.eti.br/WorkshopTelefoniaAutomacao/


text:
Arduino Due - wireless programming via Xbee
I would like to integrate an Arduino Due into a project, which probably will evolve over time and will need some re-programming. Instead of having to disconnect and pull out the Arduino Due out from the enclosure, I was wondering whether it can be set up for wireless programming via an Xbee in a similar way as for the Arduino Fio (like described here: http://arduino.cc/en/Main/ArduinoBoardFioProgramming).
Has anyone tried that already or succeeded doing that?

Theoretically, it is possible I have not tried to do it on an Arduino but I did work something similar with a pic controller. Usually, when we program the board with the firmware file we break the firmware file and send it as multiple packets over the serial com port to be written to on a certain flash memory location on the controller.
In your case, you can try an experiment by using 2 XBee modules that are connected together with the appropriate channel and network ID settings wirelessly. connect one XBee to your computer using a serial to USB cable. On the Arduino side, you have to connect to power it and use the second XBee to connect to it on the UART port. This way the XBee acts as a simple wireless data transfer channel to send and receive data wirelessly (if I am right this should be achievable in the transparent mode on XBee).
One thing to note is to check the Arduino schematic to see how exactly the data over USB is sent to the controller. If it is on UART then this should work straightforward if not then you may have to figure out something else for it.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Are there any products based on Arduino that are sold by companies?
Ok, Arduino is a good technology but is it used professionally? Is the quality good enough to be used for professional purposes?

Quite a few 3d printers have the circuitry of an Arduino and a special motor/heater driver shield combined to form their main circuit board.

In theory, an Arduino board could be used in some low-end professional products (i.e. where the performance and memory limitations aren't an issue). The build quality of the official boards is certainly good enough. The only issue they would potentially have is making suitably robust connections -- i.e. anything plugged into a female header would have the potential to get shaken loose.
In practice though, using an Arduino board would only make sense for extremely small-scale projects, where only a few units will be produced, and where there will be a minimum of external circuitry.
A commercial project would normally have a custom circuit board designed. That allows them to economise on space and features, eliminating unnecessary costs. Even if it only saves a small amount per board, it can make a big difference if you're doing mass-production.
With that said, a professional product could certainly use an AVR microcontroller or similar at its heart (much like the Arduino boards). Atmel was producing chips long before Arduino was around, and their products are well known and widely used. The choice really depends on the needs of the individual project.

We are doing this right now, and it's more than a few cents difference. Our prototype (Arduino, sensors, wiring) costs about $45. Our boards will cost about $5 and could be cheaper if we make a lot of them.

@Jasmine - Thanks for sharing some real values. I've clarified my wording so it's hopefully better now.

Just to be totally clear... that's the retail cost of Arduino boards and breakout boards, along with prototyping tools like breadboards and wires. The $5 is a hard price point to hit, and most of that is the Atmel chip, but that's our estimate for wholesale cost of our boards. The product itself needs a case and some documentation as well as packaging, so don't forget to add that in.

Yes, you can also use an Arduino for professional usage. The Arduino is actually just a prototyping device and easy to use for people at home/school. I suppose there might be products on the market which were developed using an Arduino. But the most important thing is the Atmel MCU inside the Arduino which can be used for anything. But, if you wanna know if the ATmega328P-PU which is used in the Arduino Uno is a common MCU used by professionals? The answer would be no. Everything has to be smaller and better so it'll be more likely to find the same MCU like the Arduino Leonardo, Mega etc etc.
Examples where professionals might use an Arduino for as base (The end product will only contain the MCU of the Arduino):

Kid toys like an Simon Says Game, Line following toy cars etc etc.
Small industrial products like an automated tape dispenser.
AVR programmers.
Card readers.

Yes, I work for an engineering design house and we use Arduino frequently to prototype ideas for clients.  It significantly speeds up the time to get a proof-of-concept device in the hands of the client and their potential investors.
We have found though that there is significant work to get from an Arduino-based prototype to a commercially-ready product.  Essentially you have to start again and design a completely custom printed circuit board, which is a relatively expensive exercise.
We are now developing a platform that is compatible with the Arduino IDE, but uses surface-mount modules rather than the Arduino shield system, allowing it to be manufactured in an automated surface-mount facility.  Check it out if you are interested at duinopro.cc.  We are in development stages at the moment, but already have hardware and are mainly working on our website, and designing new modules.


text:
CC3000 - Send GET request to an app on heroku
I'm struggling to get the CC3000 to connect to a heroku hosted app, and other examples posted online haven't turned on the light bulb quite yet for me.
The gist is that I collect some temperature and humidity readings, and then send those via a GET request using the CC3000. The heroku app then reads the parameters and displays them on a page.
The CC3000 hardware is A-OK, as I've tested it using the test sketches. The sketch I've put together (on github: https://github.com/jsimms/compost_monitor) works except for the last bit where it needs to connect to the server and send the HTTP request. Which makes me wonder if this is a heroku quirk, or if I'm just screwing something up right at the finish line.
First, I define everything
#define WEBSITE      "myapp.herokuapp.com"
String route = "/sensor";
uint32_t ip;
int port = 80;

Then during setup, I use getHostByName to assign the ip variable. I print it out, just to confirm it was able to snag an ip. I then close it to make sure I don't screw up anything during the loop.
  ip = 0;
  Serial.print(WEBSITE); Serial.print(F(" -> "));
  while (ip == 0) {
    if (! cc3000.getHostByName(WEBSITE, &ip)) {
      Serial.println(F("Couldn't resolve!"));
    }
    delay(500);
  }

  cc3000.printIPdotsRev(ip);
  Serial.println("");

  // Close the connection
  Serial.println(F("Closing connection..."));
  cc3000.disconnect();
  Serial.println(F("Connection closed."));

During the loop, I create a String with the request, and then call a function that actually does the request.
String request = "GET " + route + "?temp=" + temperature + "&hum=" + humidity + " HTTP/1.0\r\n";
send_request(request);

Finally, the send_request function is supposed to take care of connecting via TCP and sending it.
void send_request (String request)
{
  // Connect to server
  Serial.println("Connecting to server...");
  Adafruit_CC3000_Client www = cc3000.connectTCP(ip, port);

  // Send the request
  if (www.connected()) {
      www.println(request);
      www.println(F("User-agent: CompostMonitor/1.0\r\n"));
      www.println(F("\r\n"));
      Serial.println("Connected & data sent successfully...");
    }
    else {
      Serial.println(F("Connection failed."));
    }

    while (www.connected()) {
      while (www.available()) {

      // Read answer
      char c = www.read();
      Serial.println(c);
      }
    }

  // Disconnect
  Serial.println("Closing connection...");
  Serial.println("");
  www.close();
}

However, I never get anything but connection failed.
Any insight and help would be wonderfully appreciated. :)
UPDATE: Ok. So, through the comments below, I was able to identify by telnet'ing the web app, that there was something wrong with the HTTP requests. I made a small tweak to the app, but the real issue was that I wasn't including Host: weathervane.herokuapp.com in the header. FML! I'm going to test out sending the request with the Arduino later tonight. Hopefully that puts an end to this HTTP 101 lesson I've been doing.

Have a look at this code:  https://github.com/adafruit/Adafruit_CC3000_Library/blob/master/examples/SendTweet/SendTweet.ino
There is a delay after cc3000.connectTCP to wait for connection. Your code does not wait for the connection and thus gives 'connection failed' straight away.
Serial.print(F("OK\r\nConnecting to server..."));
t = millis();
do {
    client = cc3000.connectTCP(ip, 80);
} while((!client.connected()) &&
    ((millis() - t) < connectTimeout));

if(client.connected()) { // Success!

etc

Edit based on comment:
getHostByName returns positive value on success and negative on failure. Therefore the check should be
if (cc3000.getHostByName(WEBSITE, &ip) < 0)

Also try putting http:// in the website address

That's a very good point. I did put in the timeout, however, it still does not successfully connect. Part of me wonders if I'm missing something important in regards to Heroku architecture. In addition to the timeout, I tried two things - first, I tried using port 5000 - this did not work. Second, I moved the getHostByName lookup into the send_request function. This resulted in a "could not resolve" error message. Both for ports 80 and 5000.

@JakeSimms please see edits to answer

@JakeSimms I wonder if it wasn't getting the right address

@JakeSimms Oh, what happens if you don't disconnect? It might be that because you disconnect the socket you can't connect the TCP connection. That might be why getHostByName fails when you move it into send_request.

If you use http:// it actually hangs everything up. Even in their examples. Not sure why. One thing I did not do your other suggestions yet, mainly because I'm unsure if the sketch is the issue anymore. I'm getting bad gateway and bad request errors as you can see in the printout. Which is strange because things work fine in a browser.

One thing I want to make sure I understand. I do need to get connect to the host (getHostByName) and then I need to connect and send the TCP request. Is that correct? I then close the TCP and the getHostByName connection. Just like closing parent/child elements in html.

@JakeSimms I'm not sure. I haven't used the CC3300 before hehe. :P  From my browser http://weathervane.herokuapp.com loads. I used this site, http://www.hurl.it , to send a GET request to your heroku site and can confirm that it returns 502. BUT it does update. The full GET string is "GET http://weathervane.herokuapp.com/sensor?temp=-42&hum=-3" which includes the site address so you might need to have that in there. But it looks like something with Heroku.

Don't know if this helps: https://groups.google.com/forum/#!topic/openbadges/Hde8L6BPrUw

Thanks @geometrikal :) I the hurl.it test (and I did one with telnet) leads me to believe I still have work to do on the app.

There is something screwy with the app once it gets up on heroku. I get 200 ok responses when I test things locally. The second it is up on Heroku it starts spitting 400 errors and cutting off the second parameter.

www.println(request);
www.println(F("User-agent: CompostMonitor/1.0\r\n"));
www.println(F("\r\n"));

Both request and the other two strings end with \r\n. You also use println(), which adds \r\n of itself. This means that you end every line with two CRLF sequences, which is not correct according to the HTTP standard (Sec 2.2, Basic Rules).
Instead, use print() which doesn't add anything, or don't add \r\n to the strings yourself.
Servers may not complain about this but your code is not conform the standard and may not work on all servers / may stop working after a server update. It's also possible that some of the header fields are not being considered by the server because it treats them as body instead of headers.

Besides that, you should considering use HTTP 1.1. There's no hard reason to change now, but it's newer, includes more features, is supported by (almost) all server software, and will still work even when (if) servers decide to start phasing out HTTP 1.0 support. You then need to change 1.0 to 1.1 in the request string, and after that specify the Host field explicitly:
www.println("Host: myapp.herokuapp.com");


text:
What is the cheapest way to add wifi to Arduino?
I am trying to find some sort of wifi adapter for Arduino, it needs to be as small as possible (not a shield) and as cheap as possible.
So far I can only seem to find shields that cost about £10+ but I figured that if you can get a replacement wifi adapter for a laptop for next to nothing that I should be able to get a wifi adapter for Arduino much cheaper than this.
It's possible I just don't know what to search for.

The most cost effective solution is likely not to use a literal Arduino, but rather to utilize something else source-compatible which either has wifi built in, or can host a cheap USB wifi dongle.  It's not entirely out of the question that such a solution, complete, could cost less than a genuine Arduino UNO - and provide a lot more memory and compute resources to work with.

Some months have passed since my previous answer and now the ESP8266 based WiFi modules are available.
They get connected to your project serially (3.3V) and are controlled in a modem like way using AT commands.
With a pricing of round about $5 they fit the question better than my previous OpenWrt based answer.
For more information about ESP8266 ask your favorite finding machine or list news with tag ESP8266 at Hackaday.

(Old answer from the pre-ESP8266-days:)
I vote for a small router reflashed with OpenWrt like "TP-Link TL-WR703N".
It is like building an own Yùn with an Arduino of your choice...
The WR703N:
It has Ethernet, 150MBit WiFi, USB and if you want to solder, a serial console and 2 GPIO-Pins which can be turned into I2C.
This sure is not a chip- or stamp-sized solution but often cheaper than the alternatives, more powerfull and extendable.
Search the net with your favourite find'o'bot for "arduino wr703n" and you'll find lots of examples...

I've seen it somewhere where they use the I2C for direct connection. This would be slower than direct ethernet, but it reduces costs and size without another ethernet chip

The easiest way to connect an Arduino to a WR703N is serial via USB.

The question was asking for "as small as possible, not a shield" and "less than £10". This isn't it.

@FedericoFissore ... The WR703N in fact is one of the cheapest ways to bring WiFi and Arduino together. It is not my fault if someone dreams to use nonexistent mucht cheaper solutions.

Ok... now we have the ESP8266 based modules to add WiFI to your projects... ak your favourite finding machine or http://hackaday.com/tag/esp8266 ...

The Roving Networks RN-XV WiFly module (found sold at €30) might be a solution. I've never tried it. It supports 802.11b/g.

Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.

The question was asking for less than £10. This isn't it.

https://www.forward.com.au/pfod/CheapWifiShield/index.html
provides a very inexpensive wifi addon for Arduino

The WiFi Shield needs just two parts, 4 bits of wire and some soldering equipment. Parts List:-
Adafruit HUZZAH ESP8266 Breakout US$9.95 + shipping
Uno Protoshield US$1.88 + shipping
Total US$11.83 (as of June 2015)
For an even cheaper version ~US7 see https://www.forward.com.au/pfod/CheapWifiShield/ESP2866_01_WiFi_Shield/index.html
Both of these need a US10 USB to TTL cable to program them
After you have installed the pfodESP8266BufferedClient library, open the Arduino IDE and copy this sketch, ESP8266_WifiShield.ino, into the IDE.
That provides this setup webpage.

While that link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.

Please disclose your affiliation, you appear to be the author of the site you've linked multiple times.

Sure I will add a 'my' to future posts.

Texas Instruments CC3000 module 10USD/1000pcs, it does only support connecting to AP, i.e. no AdHoc/AP which is useless for direct using with iPad.


text:
What's the most accurate way to time-stamp analogRead data?
I want to sample an Analog sensor as fast as possible, and time-stamp each sample that I take as accurately as possible.
Currently, I'm doing the following:
val = analogRead(SENSOR_PIN);
clocktime = micros();

writeData(val, clocktime); // writes the values to an SD card

I'm wondering if there is a more-accurate way of time-stamping the data from the analogRead call. Put another way, I would like to record the exact time that the analogRead data was collected. My guess is that this is basically impossible on an Arduino, so what technique will let me get as close as possible?

For "as fast as possible", I'd

Rewrite your sampling code in assembly language (just those two statements, not the whole program); and
Buffer the raw data pairs in memory if you have enough of it, then store it to the card after the measurement burst. If you need more data space, consider that the timing of a tight assembly loop will be consistent (and fast!) and can be measured. You may not need to read the clock at all. Note that you can get the same timing consistency using C/C++ if you read the analog and clock ports directly, and maybe as fast. It's just that with assembly language, WYWIWYG (what you write is what you get); the compilers' code-generators and optimizers won't mess with it.

A possible issue with your code as you've written it is that writeData probably buffers the data on most calls, but whenever a call results in a full buffer, writes the whole buffer to the card, introducing jitter into your sampling.
Addressing your edit of June 3, 2014, "I would like to record the exact time that the analogRead data was collected":
Since you proposed using micros() (as opposed to a real-time clock), I assume you are satisfied with the relative time. Once you know your data collection code is completely predictable, then the offset from reading data to reading time is constant, and since we're using relative time anyway, can be discounted, or at least, corrected for.
It isn't completely predictable of course, since in this case, you're using an interrupt-maintained clock, and can expect that sometimes the interrupt will occur between the data read and the clock read, stretching the offset for that tuple. To get even more accurate, you'd need to keep interrupts off, read the timer yourself in an invariant way. f/ex, you might run the timer at such a rate that you could expect to take two or more samples between overflows of the low-order byte, read and store only the low order byte as your time sample, and post process the time data to reconstruct the high order byte by detecting wrap-around in the low-order.
With no interrupts running, and once you know the rate at which you can sample data without reading the clock, you could read and save the clock once immediately prior to taking the first sample, and infer the times of each subsequent sample based on the known sample rate.

There is no more accurate way of getting time on the arduino, but I would suggest you use millis() instead.
micros() returns microseconds, or millionths of a second, since the arduino was turned on. The issue is that the 32 bit unsigned integer used to store time on the arduino can only count about 70 minutes worth of micros before overflowing and resetting to 0. (see http://arduino.cc/en/reference/micros)
millis() is in thousandths of a second since the arduino turned on, and it will not reset for about 50 days. If you think one thousandths of a second is good enough resolution, it will probably be the better choice.
If you need time to be absolute, as in the current day/hour/minute, you will need to buy a real time clock to plug into the arduino. They are about 20 bucks, and available from all the standard arduino accessory stores like sparkfun, adafruit, ect.
On your question of the order, both commands run so quickly, I can think of no reason it would matter.

thanks for the reply. I am measuring very fast events that are near millisecond resolution and I only need to run the program for a few minutes at a time.


text:
How do I avoid this error trying to connect arduino to pc with linux fedora 20
I used Arduino successfully on my old Linux Fedora 12 system. Now I have a brand new PC with Fedora 20, and have today installed Arduino on it. In my first attempt to use it I typed Arduino as follows at the root prompt, after the "yum install arduino" gave me "Complete!", as follows:
Complete!
[1344][root@localhost:/home/Harry]# arduino
WARNING:  RXTX Version mismatch
    Jar version = RXTX-2.2
    native lib Version = RXTX-2.2pre2

Subsequently I have loaded the "Blink" sketch, and that is running nicely, whether I start the IDE from the command line, which still gives me the same WARNING, or from the desktop icon, which does not give it.
So my question is: please, does this WARNING matter? If so, what should I do about it?

The warning, as I'm sure you can tell, is about a mismatch in version of RXTX arduino is expecting, and what is installed on your system. If everything is functioning, I would not worry about it at all. The versions seem to only be slightly different, maybe just a few bug fixes are missing from the older one.
RXTX is a library for java to communicate with serial devices, but it is not under development anymore and only available from mirrors, not the original developer site. Arduino has moved on to a library called jSSC, which is currently being maintained, and a much better library IMHO. The change to jSSC is still only in the arduino beta version, 1.5.6r2 at time of writing, but it works very well. Anyway, if RXTX ever actually gives you trouble, you can download the beta version of arduino and not have to deal with it.

An excellent answer, covers it nicely for me, thanks.


text:
Arduino servo acts weird with photocell (lightsensor)
I have a weird thing with my servo, I really dont know what is wrong with my code, I tried everything. Either it is my connection on arduino or my code. Please help me guys, this is my code.
#include <Servo.h>

int servoPin = 9;
Servo servo;
int angle = 0;
int photocellPin = 0;

void setup() {
  servo.attach(servoPin);
}

void loop() {
  int reading = analogRead(photocellPin);
  Serial.print("Reading = ");
  Serial.println(photocellPin);
  int newAngle = reading / 2;
  servo.write(newAngle);
  delay(80);
}

Can you describe exactly what is weird with the servo? It just sits there and do nothing?

Maybe a good quality picture of your setup would help us help you. Also, it could help if you tested the photocell separated from the servo. For example, have you tried to feed a few hardcoded angles to the servo, say, 0, 90, 180, 90, 0, delaying a few seconds from each call? Also, what results do you get from the serial prints?

Thank you for answering. The servo acts weird in a way that it is moves and gives little shocks each time. Also my connection with my usb port doesnt work continue, I got the feeling their is a bad connection. I will make a picture of my setup, maybe it is just the wires.

You mean the servo doesn't move smoothly, but in quick steps, like it's quicking, is that it? Can you show us your circuit and tell us which servo it is. Maybe the servo is trying to use more current than the USB is able to provide and that's causing the suply voltage to drop and making the Arduino reset.

I added a photo :) It is a small servo.

It is just a weirdo servo to be honest, he doesnt know what he wants.

Servos accept a signal from 0 to 180, with 90 being the center point on the servo. analogRead() will output a number from 0 to 1023. The arduino "map" function makes a conversion easy to do. just replace
int newAngle = reading / 2;

with
int newAngle = map(reading, 0, 1023, 0, 180);

you can read more about the map function here: http://arduino.cc/en/reference/map
It is hard to tell from the picture that everything else is wired correctly, but this should fix up your code.


text:
How do I remotely acquire data from Arduino based portable device?
I am making a device which will have an Arduino board and a sensor attached to it. The sensor will acquire data every 10 minutes and the data will be uploaded to my server. The size of every upload is about 200 characters. I'd like this device to work anywhere in my city (US).
What are my options for uploading data to my server? Keep in mind that it will work without human intervention. FYI... this is NOT for reconnaissance device! ;)

I can't guarantee anywhere in your city, but this hack will work pretty much wherever there is cell coverage for the carrier you choose.
You'll want the GSM shield.

Picture from Arduino
Anyway, it uses pins 2, 3, and 7 on it. It also has the ability to solder (on the bottom of it) a microphone and speaker connection. You'll need to buy a SIM card and a contract to connect your shield to a network. I don't know how often you would use this, but I've seen a pay-as-you-go plan that charges you $2 for unlimited talk/text/internet per day. If you're going to use this once a month, that would be the way to go. I didn't look to see if they supported the GSM shield (it was on TMobile's site). You would want to contact them for more details. Also, depending on where you live, I don't know if you would get good coverage. This goes with any cell phone provider, but make sure that you get coverage where you want to go (and don't always trust the maps they provide).


text:
Adding an Arduino variant into ~/sketchbook and using it from a Makefile
I have a pins_arduino.h file for a given Arduino variant, installed in ~/sketchbook/hardware/attiny/variants/tiny14/pins_arduino.h. The IDE has no problem picking it up if I set the right board type. However, if I use a Makefile like this:
BOARDS_TXT      = $(HOME)/sketchbook/hardware/attiny/boards-cli.txt
BOARD_TAG       = attiny44-8

include /usr/share/arduino/Arduino.mk

then running make fails to compile it because of a missing pins_arduino.h. Moving the tiny14 directory to /usr/share/arduino/hardware/arduino/variants  fixes the problem, but I don't want to pollute my system directory (and also, it sounds fragile if I ever remove/replace my Arduino software distribution).
How do I get the CLI Make toolchain to pick up my pins_arduino.h file from my ~/sketchbook?


text:
Connecting Nokia 106 to Arduino
I was wondering if this can be done. I got a Nokia 106 and am trying to make it talk, but the audio jack doesn't seem to cooperate and the Fbus pins are right under the SIM slot, which is right under the battery. Any advice?
Added: It seems that it talks AT commands, since it is a GSM model, but I'm not 100% positive.

Hi, can you give us some information on the communication protocol of the Nokia? It's impossible to tell you if its possible to talk to the Arduino if we don't know how it talks.

@sachleen There's actually not much info out there. The phone was release on August 2013, so there doesn't seem to be much research. I found out about the Fbus here: http://forum.gsmhosting.com/vbb/f148/nokia-105-new-100-working-solution-1731398/

@sachleen Sorry for the difficult question. I'm kinda new to this and I don't want to screw up the cellphone… to much.

Here's the picture of the Nokia FBUS connector from your link:

And here's a (slightly dubious) method of connection from some random web page

which goes on to say

The F-bus protocol uses 115,200bps so we can easily use the Arduino’s serial function to communication with the phone. All you need to is hook up the phones TX to the Arduino’s RX and then use a resistor divider (I choose 330 ohm resistors) to connect the Arduino’s TX to the phones RX as shown above.

That page goes on to show how to use an Arduino to get the phone to send SMS text messages.
Sources:

http://www.insidegadgets.com/2013/01/12/how-to-use-nokia-f-bus-to-send-an-sms-message/
http://forum.gsmhosting.com/vbb/f148/nokia-105-new-100-working-solution-1731398/

Thanks, but the problem is that I'd need to pretty much tear the cellphone apart. I'd rather not kill my phone :/

just trim the actual simcard, so its level with 'microsim insert' back edge. Its what i did on my Nokia 100/GPO 746 project, works fine, wont kill the phone


text:
Unable to read text file from server
I saw the Web client Example  , In the example, the server connection is initialized in setup(). But I want the server to update the text file every time. So, I need the server connection to be in loop().
But, it is not working. Where is the problem in my code.
#include <GSM.h>

#define PINNUMBER ""

// APN data
#define GPRS_APN       "GPRS_APN" // replace your GPRS APN
#define GPRS_LOGIN     "login"    // replace with your GPRS login
#define GPRS_PASSWORD  "password" // replace with your GPRS password

// initialize the library instance
GSMClient client;
GPRS gprs;
GSM gsmAccess;

// URL, path & port (for example: arduino.cc)
char server[] = "yourdomain.com";
char path[] = "/current.txt";

int port = 80; // port 80 is the default for HTTP

void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(9600);
Serial.println("SMS connected");

// connection state
boolean notConnected = true;

// After starting the modem with GSM.begin()
// attach the shield to the GPRS network with the APN, login and password
while(notConnected) {
   if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
    (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
    notConnected = false;

else {
     Serial.println("Not connected");
     delay(1000);
    }
   }
Serial.println("GPRS connected...");
Serial.println(" Connecting to Server ");
}

void loop() {
if (client.connect(server, port)) {
  client.print("GET /current.txt");
  Serial.print("GET /current.txt");
  client.println(" HTTP/1.1");
  Serial.println(" HTTP/1.1");
  client.println("Host: www.yourdomain.com");
  Serial.println("Host: www.yourdomain.com");
  client.println("User-Agent: Arduino");
  Serial.println("User-Agent: Arduino");
  client.println("Accept: text/html");
  Serial.println("Accept: text/html");
  client.println("Connection: close");
  Serial.println("Connection: close");
  client.println();
  Serial.println();
  Serial.println("\nCOMPLETE!\n");
  //client.stop();

} else {
  Serial.println("connection failed");
  Serial.println("\n FAILED!\n");
}

if (client.available()) {
  char c = client.read();
  Serial.print(c);

} else {
  Serial.println();
  Serial.println("disconnecting.");
  client.stop();
}
}

What's not working?

The server is connected, but it does not gives the server response for the requested text file.

It looks like your sketch will only ever read the first character from the server. Is that deliberate?

Its working as long as the connection doesn't break or the server doesn't stall. We must wait till the response .
while (client.connected())
{
 while(client.available())
 {
 char ch = client.read();
 Serial.print(ch);
 }
}
 client.stop();


text:
Can a PC connect to an Arduino for serial communication without installing the entire dev kit?
I'd like to send a prototype board to a friend pre-programmed and wired. Ideally they should just need to plug in the USB and connect to it over a serial COM port.
With another laptop I used for testing I had to install the full dev kit, sketch editor and all to get it working.
Can I somehow send just the portion of the kit that provides the COM drivers and not the rest? Is there a prebuilt install for just that portion?

On Windows in C:\Program Files\Arduino there is a folder called drivers, which contains all the drivers for the Arduino boards. I think that's what you are looking for.

And for OSX and Linux the driver is typically shipped with the OS already (though older FTDI boards may require a driver on OSX?  Anyone remember?)


text:
LED Cube lighting wrong LEDs randomly
So I built my First LED Cube and the thing turns ON!!! Pretty happy about that but here is my problem.
When I try and get the Cube to display say a basic "outline" (a wire form of a cube only the outer most LEDs are on)
The shift registers, that I have daisy chained together, give the correct display 80% of the time, but the other 20% give completely wrong LEDs lighting up.
I have used 4 74HC595 shift registers linked together so I am only using 3 of my Arduino ports to control the 5*5*5 Cube.
The basic shape is there but the ones that are not meant to be lighting up cause a lot of flickering (or ghosting?) in the center of the cube.
I have thought about using pull up or pull down resistors but I find that, when I run my program at a slower rate, the LEDs that are lighting wrongly are lighting up controlled so I think it has to be something with my code or setup.
Has anyone got any experience with LED cubes doing this?
Also I am only using the output enable and disable to make use the wrong this is not displayed when I am shifting the data out, should I be using the clear?
One last thing, does anyone have recommendations for the delay time to let each layer shine for?
My code is below
int clockPin = 8;
int dataPin = 7;
int set = 6;

void setup()
{
  //set pins to output so you can control the shift register
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(set,OUTPUT);
}

void loop()
{
      digitalWrite(set,HIGH); // DISABLES OUTPUT
  // level 1 ( top )
      shiftOut(dataPin, clockPin, MSBFIRST, B00000011);//from left 3rd to the 7th = levels 5-1,, The right first LED
      shiftOut(dataPin, clockPin, MSBFIRST, B11111000);// Makes the " wire cube "
      shiftOut(dataPin, clockPin, MSBFIRST, B11000110);// Makes the " wire cube "
      shiftOut(dataPin, clockPin, MSBFIRST, B00111111);// Makes the " wire cube "
      digitalWrite(set,LOW);  // enables output
      delay(2);

       digitalWrite(set,HIGH); // DISABLES OUTPUT
 // level 2
      shiftOut(dataPin, clockPin, MSBFIRST, B00000101);//from left 3rd to the 7th = levels 5-1,, The right first LED
      shiftOut(dataPin, clockPin, MSBFIRST, B00010000);// Makes the " wire cube "
      shiftOut(dataPin, clockPin, MSBFIRST, B00000000);// Makes the " wire cube "
      shiftOut(dataPin, clockPin, MSBFIRST, B00010001);// Makes the " wire cube "
      digitalWrite(set,LOW);  // enables output
      delay(2);

      digitalWrite(set,HIGH); // DISABLES OUTPUT
 // level 3
      shiftOut(dataPin, clockPin, MSBFIRST, B00001001);//from left 3rd to the 7th = levels 5-1,, The right first LED
      shiftOut(dataPin, clockPin, MSBFIRST, B00010000);// Makes the " wire cube "
      shiftOut(dataPin, clockPin, MSBFIRST, B00000000);// Makes the " wire cube "
      shiftOut(dataPin, clockPin, MSBFIRST, B00010001);// Makes the " wire cube "
      digitalWrite(set,LOW);   // enables output
      delay(2);

      digitalWrite(set,HIGH); // DISABLES OUTPUT
 // level 4
      shiftOut(dataPin, clockPin, MSBFIRST, B00010001);//from left 3rd to the 7th = levels 5-1,, The right first LED
      shiftOut(dataPin, clockPin, MSBFIRST, B00010000);// Makes the " wire cube "
      shiftOut(dataPin, clockPin, MSBFIRST, B00000000);// Makes the " wire cube "
      shiftOut(dataPin, clockPin, MSBFIRST, B00010001);// Makes the " wire cube "
      digitalWrite(set,LOW);   // enables output
      delay(2);

      digitalWrite(set,HIGH); // DISABLES OUTPUT
 // level 5 ( bottom )
      shiftOut(dataPin, clockPin, MSBFIRST, B00100001);//from left 3rd to the 7th = levels 5-1,, The right first LED
      shiftOut(dataPin, clockPin, MSBFIRST, B11111000);// Makes the " wire cube "
      shiftOut(dataPin, clockPin, MSBFIRST, B11000110);// Makes the " wire cube "
      shiftOut(dataPin, clockPin, MSBFIRST, B00111111);// Makes the " wire cube "
      digitalWrite(set,LOW);   // enables output
      delay(2);
}

Any help would be appreciated
Thanks

add circuit scheme , for the times it depends on many things (mainly fps) but the usual is 1-10ms look here for similar problem http://stackoverflow.com/a/20468992/2521214

A simple way to test for short between LEDs is to write a loop that lights one of them at a time, one right after the other, for 50ms or so. It's relatively easy to notice two LEDs lighting together (a short) or a missing blink in the sequence (an open), assuming you can see all the LEDs at once.
Update (6 years later, but hey - I since people still read this question):
I use a sketch that does exactly this to help find shorts and opens when I'm building up a new board. I'd previously implied that you need all of the LEDs attached, but you need at most 2.
On a newly soldered cpu with power & ground (and reset jumpered to ground), holding an LED on each of two adjacent pins will show a shorted pair, while a single LED on one pin will display an open or a short to ground (or to +5, if you orient your LED+resistor that way). I keep a few LEDs with a resistor soldered to the cathode, or ground, leg to use as digital probes.

I have had a similar issues when building this instructable, a 8x8x8 LED cube. Lighting up some of the LEDs caused wrong LEDs to light up simultaneously, even though according to the circuit diagram they where not suppose to. The wrong LEDs that lighted up seemed to be random, though it was reproducible.
The root cause was, after some debugging using a Multimeter's continuity test, that some of the LEDs legs where touching in places they shouldn't, and so the current was flowing where it was not supposed to flow. I strongly recommend to investigate that direction, verifying that Ground paths and Vcc paths are properly isolated from each other. This should be easier to do with a 5x5x5 cube.
About the delay - I suggest you'll take a look at the Arduino code in that instructable - it seems that between the different layers, the code does not use any delay, only between effects. The final result seems to works great.

I have a similar circuit (running a 7-segment display); I don't use reset, and for something like this (since the only state it keeps is reset on sending of new data, which is every frame).
For debugging, I would suggest seeing if there are any patterns. For example, if it doesn't happen on LEDs controlled by the first shift register, then it's likely to be due to the connection between them.
You might try seeing if a pulldown resister (try >10kOhm) between the data pin and ground has an effect, too.
If you get really desperate, it might be worth getting an oscilloscope - see what is actually happening on the wire.


text:
Arduino Interrupt Debouncing
I have an issue with debouncing.
I am using a MCP23017 as an I/O-extender with an Arduino. This uses I2C to communicate with each other.
A variable amount of switches is connected to the MCP23017 (0-16 switches). On change of the inputs, an interrupt is generated and the Arduino captures this on rising edge. So whenever a button is pushed or released, an interrupt is generated.
Now I'm confused as how I should debug them. One option would be to set a delay after an interrupt (of let's say 50 ms), before turning the interrupts back on. This could have an issue however, since multiple inputs are connected to the same interrupt line.
Another option is to have a timestamp or something for the last time each switch was changed, and check if the time difference is big enough, otherwise ignore the next pulse. The problem with this is that it uses quit some resources as I have limited memory and there can be up to 8 extenders (so 8 * 16 = 128 inputs).
What is the most efficient way to handle these interrupts with debouncing?

Just don't use an interrupt.  It does the exact opposite of what you want, the point of debouncing is to respond to input changes slowly.  Just poll in your main loop, increment a counter when the input is active, set it to 0 when it is inactive.  When it reaches a certain value (depends on your main loop scan rate) then you declare it on.

What @HansPassant says.  If you already have a periodic timer interrupt,, (eg. for an RTOS), hook it and poll the port that the switches are on.  You can keep a 'currentKeyState' 16-bit var and bitwise XOR to detect changes. If a change is consistent for two, (or more), interrupts, accept it as valid.  Dedicated interrupts for manual pushbuttons/keypads etc. are not justified, cause more problems than they solve and are just a major PITA..

Waiting for a consistent value over successive reads can help with some sorts of noise, but it's not really a solid de-bouncing strategy.  I prefer to act on (or at least record) the keypress when it is first seen, but then ignore subsequent presses of that (or potentially any) key for a certain amount of time or number of iterations through the loop.  This keeps the system responsive, while letting the criteria for a second valid press be adjusted - or even expanded to include a key-repeat function.

Add debouncing circuitry if you can; it's not that difficult.

Circuitry is too late - the PCB's have already been ordered.

Hardware debouncing adds cost and layout complexity - software is cheaper and more configurable.

Depends on the application.
Define efficiency. What are you looking to optimize for? Manhours spend coding/testing, processor speed, response time?
Are theses keys to a piano synth? Yes you'll want interrupt speed, and each key needs to not affect the surrounding keys.
Is it going to be rare that two keys are pressed anywhere near each other? a timeout for the ISR is perfectly legitimate.
Will the user not observe any lag when he flips a switch and resources are tight? Then polling could be a viable option.
Are the EMI concerns and you need to filter out false positives? Well you're going to need do some more. Like sampling for sustained values or counting how long until the falling edge occurs.
There are so many options depending on what you want it to do.


text:
What is the circular gold pad on arduino mega 2560 v2 and above?
Could someone point me to the documentation that describes the gold dot and surrounding gold circle on the front of my arduino mega v2 board. It is right above the ICSP header and reset button, and directly underneath the letter 'U' in the silk screened word 'communication'
I've not been able to find any reference to it anywhere. Is is a jumper, a test pad, RF pad???

That is most likely a Fiducial Mark for the vision system of a pick-and-place assembly robot to key off of in order to more precisely place the components on their pads.
If you look carefully, you will see a second one located below the DC barrel jack.
Boards like this are manufactured in a gridded panel having a number of copies in each direction, and only cut apart after they are largely complete.  With such a large workpiece, any linearity error in the manufacturing could result in a high-density component being misplaced far enough to cause problems.  Having a pair of fiducials on each individual board in the panel can help calibrate out errors not only which might otherwise accumulate over the large dimensions of the entire panel, but also rotational skew of the panel in its holder.

You can see both on this picture of the Arduino Mega 2560 from the arduino.cc site

To add to Chris's answer: fiducials appear at three levels. First there are fiducials at the panel level, which contains one or more PCBs, depending on their size. Next there are fiducials for the PCB, acting as a position reference for component placement. Sometimes you can see component fiducials close to some fine pitch components, to make sure they are placed with high precision. You'll sometimes see these latter fiducials on opposite corners of QFP (Quad Flat Package) parts. (The AVR controller on the Arduino Mega 2560 is in QFP.)