message:
Multiple shields on one Arduino/Linker base shield

I'm using an Arduino Uno R3 along with an Ethernet shield as well as the linker base shield for interfacing with three linker modules, light, temperature and some LEDs as I believed this would be simpler than using a breadboard and look neater. Are there any problems I'm likely to run into regarding compatibility or power consumption? It's a prototype for a hydroponic garden automation system. As a secondary, are there any c02 sensors under $60 available on the market?

body:
I would recommend looking up the power consumption specs on the datasheets for each shield. Then determine whether the current used by all of the shields exceeds the limits for any given pin and for the board as a whole. I highly recommend the following article: [http://www.ruggedcircuits.com/10-ways-to-destroy-an-arduino/][1]

  [1]: http://www.ruggedcircuits.com/10-ways-to-destroy-an-arduino/


sender: user

message:
How to program ATTiny85 running 3.3V

I have a working project built around ATTiny85 on a breadboard running at 5V. Now I want to move this prototype on a PCB where it will be powered from batteries. All components used are capable of running 3.3V so I want to run the ATTiny85 at 3.3V as well.

I don't have a programmer so I use ArduinoISP to program the ATTiny. If I change the fuses on Tiny to run it at 3.3V can I still use the 5V Arduino to program the tiny?

Since the ATTiny can easily run at 5V I don't see any problem with programming it at 5V levels and then run it at 3.3V. Is that correct?

sender: assistant

body:
> Since the ATTiny can easily run at 5V I don't see any problem with programming it at 5V levels and then run it at 3.3V. Is that correct?

Yes. But if there are *any* components on the board that *can't* run at 5V then you must provide some way of protecting them from the excessive voltage.

> If I change the fuses on Tiny to run it at 3.3V can I still use the 5V Arduino to program the tiny?

There are no fuses required to change the actual operating voltage of the device. There is the BOD threshold, but you can still operate the device at a higher voltage without issue regardless.


body:
Most ideal would be to use a buffer chip (like there is on the [AVR Pocket Programmer](https://www.sparkfun.com/products/9825)).

But in your case you could get away with just placing some resistors (1k or something) on the ISP lines. This is because if the chip is powered by 3v and you put a 5v signal on one of the pins it's clamping diodes will redirect the higher voltage to VCC, raising VCC to 5v. In your case the 5v is not necessarily a problem. But if you circuit is using e.g. 100mA, that means 100mA will go through the clamping diode. It's not designed for that.


message:
Arduino and ESP8266 Web server

First things first, if there was an ESP8266 StackExchange, I would post this there.

I am setting up a web server that will programmaticly be controlled from an external Python script, and I am currently able to send this server data using this script, but I don't receive an HTTP response back when I do, so the external script crashes.

I have googled around and not found much on this, so the question is How do I, From the Arduino, using an ESP8266 send an HTML response code?

body:
After countless Trial/error attempts, I was able to put together the proper sequence.

    AT+CIPSEND=0,40  \\Set this for your current connection ID and payload length.
    HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n
    AT+CIPCLOSE=0  \\Set this for your current connection ID
Send these commands with the arduino, and it should exit successfully.  You can also flush out the HTTP line with any other information you would like to include, as defined in the [rfc2616 (HTTP/1.1) standard][1]

  [1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6


message:
Can you query the current serial port's speed?

Is there some code I can use to find out what the a chosen serial port's speed is running at ?

body:
There is not a top level, easy to use way. Sorry. It is probably easier to just store your chosen baud rate in a variable when you setup the serial port.

Anyway, What you can try to do for the AVR-based, hardware UARTs is undo what `Serial.begin` does to set up a particular baud rate, but its a bit of a pain. This is the code for setting the baud rate:

      // Try u2x mode first
      uint16_t baud_setting = (F_CPU / 4 / baud - 1) / 2;
      *_ucsra = 1 << U2X0;

      // hardcoded exception for 57600 for compatibility with the bootloader
      // shipped with the Duemilanove and previous boards and the firmware
      // on the 8U2 on the Uno and Mega 2560. Also, The baud_setting cannot
      // be > 4095, so switch back to non-u2x mode if the baud rate is too
      // low.
      if (((F_CPU == 16000000UL) && (baud == 57600)) || (baud_setting >4095))
      {
        *_ucsra = 0;
        baud_setting = (F_CPU / 8 / baud - 1) / 2;
      }

      // assign the baud_setting, a.k.a. ubrr (USART Baud Rate Register)
      *_ubrrh = baud_setting >> 8;
      *_ubrrl = baud_setting;

You can find the results of this by reading the right UCSRA, UBRRH, and UBRRL registers. On an uno those are the correct register names, on an mega its UCSR0A, UBRR0H, UBRR0L for Serial, UCRS1A ... for serial1 and so on. Non-avr boards (and `Serial` on a leonardo) will be totally different.

There will be a single state for those three registers on an AVR hardware serial port for a particular board (and frequency of that board) at each baud rate. You can try and make an equation to get the original baud rate out, but I recommend just comparing the direct values with a lookup of some kind because the integer arithmetic rounding errors will make it a huge mess.

For example, on my mega UBBR0H, UBBR0L, and UCSR0A are 0, 207, 2 at 9600 baud, but they are 0, 51, 2 at 38400 baud and 0, 16, 0 at 57600 baud.


message:
STEPPER MOTOR CONTROLLER Using LEONARDO PRO MICRO

I want to Use LEONARDO PRO MICRO and A4988 Stepper Motor DRIVER to control Nema 17 Stepper Motor.

![enter image description here][1]
![enter image description here][2]

Please let me know how to hookup these together.

Please give me a circuit for this type of assembly with Arduino code.

  [1]: https://i.stack.imgur.com/43w75.jpg
  [2]: https://i.stack.imgur.com/pklWd.png

body:
You can simply make a google search;
![Wiring instructions][1]

Here is some code to get you started

    // Declaration of variables
    #define Step 7     // Pin that transmits the "step" order to the board
    #define Dir  6     // Pin that indicates the direction of the rotation
    int vit  =   10 ;   // Speed of the rotation (smaller means faster rotation)
    int sens =   1  ;  // Rotation direction (0 or 1)

    void setup()
    {
      pinMode( Step  , OUTPUT );
      pinMode( Dir   , OUTPUT );
    }
    void loop()
    {
        digitalWrite( Dir   , sens);
        digitalWrite( Step  , LOW);
        // Fabrication d'un "Pas"
        digitalWrite( Step, HIGH );
        delay(vit);
        digitalWrite( Step, LOW );
        delay(vit);
    }

Just a google search and I got on [this site][2] which had the code I gave you.
I think you can also find some libraries that can do the work for you.

in case that you need to wait less than a millisecond, `millis()` won't be useful for you; instead, use `delayMicroseconds()` which will make you wait a thousandth (at minimum) of a millisecond.

**EDIT**

For what you asked you have to first get the voltage:

    float voltage = analogRead ( 0 )  * (3.0 / 1023.0);

You just have to adapt your speed relatively to the voltage.
To do this, I suggest you the [map function][3] directly from Arduino site.

Be careful just because whatever you are doing, analogRead takes **100 microseconds** to get the voltage, so if you need to go very fast you can't.  I suggest you to work with a different type of communication, like Serial, SPI or I2c.

  [1]: https://i.stack.imgur.com/7W4Th.png
  [3]: http://arduino.cc/en/reference/map


message:
Read data from SD

I have logged  some data in my sdcard/FAT32 (format).
I can read and display them on the serial monitor but additionally I want to use these data as float.

Here is my code:

           byte index = 0;

           Tfile = SD.open("DATALOG.TXT",FILE_READ);

           while (Tfile.available()) {

             x[index++] = Tfile.read();
             x[index] = '\0'; // NULL terminate the array
           }

Printing the data using:

       Serial.print(fileContents);

I receive  the following float values that are correct:

       .63
       15.63
       16.60
       16.60
       16.60
       16.60
       etc
Now I want to work with values so i need to store them on a double index:

        double dtemp[320];
        for(index = 0, i=0; index < 320; index++, i++) {
           dtemp[i] =  fileContents[index];
           Serial.println(dtemp[i]); }

but i receive fault values:

          46.00
          54.00
          51.00
          13.00
          10.00
          49.00
          53.00
          etc

Any comment is welcomed !

Thank you in advance !

body:
You have to _parse_ the character array in order to convert it to
floats. There is no fast way to do this: since the Arduino has no FPU,
_anything_ involving floats is slow.

Unless you really have to, I would not recommend slurping the whole file
into RAM. You will save memory by parsing the file on the fly. This
should be as simple as calling the `parseFloat()` method of the `File`
object:

<!-- language: lang-c++ -->

    double dtemp[320];
    int i;
    for (i = 0; Tfile.avalable() && i < 320; i++) {
        dtemp[i] = Tfile.parseFloat();
        Serial.println(dtemp[i]);
    }
    if (i < 320)
        Serial.println("WARNING: Premature end of file.");


message:
Feasibility of a Wi-Fi Positioning System

In the project of guiding a sight disabled person in a known environment, we need to have a precise way of figuring out where the user is. Our current solution is to use WPS.

This is however our first project with Arduino, and we're not quite sure if we're going the right way about this. We're thinking of getting a compass component and such, but is there something we should know before advancing further in the project?

EDIT: Additional information.
The system is placed on the user, most probably strapped to the arm. The communication to the Wi-Fi beacons will be done from there, as well as the calculations.

The environment is supposed to be as complex as an exposition hall, but we can aim higher.

Budget range is around $100, Arduino itself excluded. A UNO is already provided to us.

body: I don't think that arduino is the right hardware for such a project. Better use a cheap android phone, there you have a stronger processor with more memory as well as a lot of sensors like compass, accelerometer, gyroscope and maybe in newer ones barometer, which you will need - also you have wifi. An arduino uno just comes without wifi and all the sensors. Also I guess a lot of persons already have a phone, so this will lower your project costs, because hardware is already available at most users. Last but not least I think you could use mobile phone vibrations to give feedback to the sight disabled users, oder sound commands like "go left" etc.


message:
Problems with (somewhat) large boolean arrays

I am writing a simple Conway's Game of Life implementation just to get to grips with the "Nokia 3310" LCD and I am having problems with boolean arrays. I am using an (unofficial) Arduino Pro Micro 5V/16MHz

Here's the code that is causing me trouble:

    boolean buffer[84][48];

    void setup(){
      for(int i = 0; i < 84; i++){
        for(int j = 0; j < 48; j++){
          buffer[i][j] = true;
        }
      }
    }

    void loop(){}

When I upload this to the Arduino, it seemingly freezes up with the RX led on and its COM port stops working. If I want to upload any other sketch, I have to manually pull the RST pin LOW (since the Pro Micro doesn't have a reset button).

I've been playing around with the code and found out that the source of problems is this line:

    buffer[i][j] = true;

It also doesn't matter if I use `true` or `false`.

I have tried debugging with Serial to the computer, but the Serial communication doesn't work at all, so I tried using an LED to find out where the problem is. I don't have any "regular" LEDs on me, so I had to try with an Adafruit NeoPixel. The outcome was quite interesting. When I comment out the problematic line, everything runs just fine, the led goes red for 500ms then it blinks white every time the problematic line would run and then it goes green and stays that way. With the problematic line in place, the LED won't do anything, even turn red, which I put much earlier in the code than the source of the problem.

Does anybody have any insights that might be useful? (Also, I really hope it is not some stupid typo, I swear I read it through about twenty times)

body:
According to http://arduino.cc/en/pmwiki.php?n=Reference/BooleanVariables, "Each boolean variable occupies one byte of memory." Meaning you are trying to use 4032 Bytes of RAM with your array which I assume you do not have (whatever this unofficial Arduino is -- it's likely to be less than that: the ATmega328 of the Arduino Mini has 2 kB of SRAM, the ATmega32u4 of the Micro has 2.5 kB).

You could try with a quarter of the field size for a start and see if that makes your problems go away.


body:
Well, if each boolean takes a full byte, as fuenfundachtzig says, then you might try some bitwise hacking to fit 8 bools per byte on your own.  Maybe something like this:

    unsigned int16 buffer[84][3];  //16 bits * 3 = 48 bits, per the original example

    void init_buffer()
    {
        for(int i = 0; i < 84; i++)
        {
            for(int j = 0; j < 3; j++)
            {
                buffer[i][j] = 0xFFFF;  //all TRUE: each F is hexadecimal for 0b1111 in binary
            }
        }
    }

    bool get_buffer(unsigned int8 i, unsigned int8 j)
    {
        unsigned int16 k = 0;
        while(j >= 16)
        {
            j -= 16;  //I can do this because i and j are passed by value and are therefore separate copies inside this function
            k++;
        }
        //now k is the array index and j is the bit position inside that element
        if(buffer[i][k] & (1 << j))  //(bitwise AND with 1 shifted left by j positions, so we only care about that bit)
        {
            return TRUE;
        }
        else
        {
            return FALSE;
        }
        //or, if your compiler supports it, you might replace the if/else with:
        return (buffer[i][k] & (1 << j));
    }

As for the stylistic differences between my example and yours:

- I like to completely specify my datatypes if I can.  Don't rely on the compiler to do what you expect because it may have options to that effect that are set differently than you think.
- I like to use brackets for everything, even single statements, and make them obvious.  That way, there's no confusion later or additional bugs because a second statement was added to what used to be a bracketless single without adding the brackets.
 - The only exception to that is when I'm writing a series of almost-identical if's and I put both the if and the action on the same line, all aligned so that the subtle differences line up and become obvious.


message:
7 segment LEDs on wood face

I'm not sure this is right place for this question, but does anyone have any idea how a 7 segment display is projected or embedded in wood for products like this?

![amazon wood clock][1]

Full product info at http://www.amazon.com/Cube-Wood-LED-Alarm-Clock/dp/B00D6DI0LE

Another example:

![enter image description here][2]

From: http://www.selectism.com/2013/11/27/a-wooden-led-alarm-clock-and-wireless-bluetooth-speaker-from-gogroove/

  [1]: https://i.stack.imgur.com/neWtv.jpg
  [2]: https://i.stack.imgur.com/x3VBV.jpg

body:
This is done by carefully placing a layer of wood veneer over the 7-segment displays. The veneer is thin enough to let the light pass through. I wouldn't be surprised if some manufacturers use brighter than normal LEDs to make the display easier to see. [Here is a video detailing an example.][1]

It is also possible to simply drill out the wood to make it very thin where the 7-segment displays go. [Here is an example of drilling the solid wood to be very thin.][2]

  [1]: https://www.youtube.com/watch?v=2P-8-zd7sXg
  [2]: http://www.instructables.com/id/Solid-Wood-Digital-Clock/


message:
Build arduino with windows command line

Can someone explain, step by step, along with all software I must use for using Windows command prompt to build an Arduino sketch (.ino file )?

I've followed [these steps][1] but I can't.

  [1]: http://forum.arduino.cc/index.php?topic=37813.45

body:
The command line interface of the Arduino IDE is described in this document

https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc

For example, this command will compile and upload the Blink example to my Arduino Leonardo

    ./arduino --upload --board arduino:avr:leonardo --port /dev/ttyACM0 --verbose examples/01.Basics/Blink/Blink.ino

Foot note: with IDE 1.6.0, there is an experimental version of the IDE for recent MacOSXs. It doesn't yet support the command line. If you need the command line on Mac, use the recommended version. This will be fixed with 1.6.1


message:
Code for four road junction

This is the Arduino code for a four road junction. In the below code, the `if` case must be tested after every road without delay. Can any one guide me?

    int redLed1 = 7;
    int yellowLed1 = 6;
    int greenLed1 = 5;
    int redLed2 = 4;
    int yellowLed2 = 3;
    int greenLed2 = 2;
    int redLed3 =8 ;
    int yellowLed3 =9;
    int greenLed3 =10;
    int redLed4 = 14;
    int yellowLed4 = 15;
    int greenLed4 =16;
    int THRESHOLD=700;
    int soundvalue=0;
    void setup()
    {
        pinMode(redLed1, OUTPUT);
        pinMode(yellowLed1, OUTPUT);
        pinMode(greenLed1, OUTPUT);
        pinMode(redLed2, OUTPUT);
        pinMode(yellowLed2, OUTPUT);
        pinMode(greenLed2, OUTPUT);
        pinMode(redLed3, OUTPUT);
        pinMode(yellowLed3, OUTPUT);
        pinMode(greenLed3, OUTPUT);
        pinMode(redLed4, OUTPUT);
        pinMode(yellowLed4, OUTPUT);
        pinMode(greenLed4, OUTPUT);
    }

    void loop()
    {
        digitalWrite(redLed2,HIGH);
        digitalWrite(redLed3,HIGH);
        digitalWrite(redLed4,HIGH);
        digitalWrite(redLed1,HIGH);
        digitalWrite(yellowLed1,HIGH);
        delay(5000);
        digitalWrite(redLed1,LOW);
        digitalWrite(yellowLed1,LOW);
        digitalWrite(greenLed1,HIGH);
        if(analogRead(A0)>=THRESHOLD)
        {
            digitalWrite(greenLed2,LOW);
            digitalWrite(greenLed1,HIGH);
            delay(10000);
            digitalWrite(greenLed1,LOW);
        }
        delay(30000);
        digitalWrite(greenLed1,LOW);
        digitalWrite(redLed1,HIGH);
        digitalWrite(yellowLed2,HIGH);
        delay(5000);
        digitalWrite(redLed2,LOW);
        digitalWrite(yellowLed2,LOW);
        digitalWrite(greenLed2,HIGH);

        delay(30000);
        digitalWrite(greenLed2,LOW);
        digitalWrite(redLed2,HIGH);
        digitalWrite(yellowLed3,HIGH);
        delay(5000);
        digitalWrite(redLed3,LOW);
        digitalWrite(yellowLed3,LOW);
        digitalWrite(greenLed3,HIGH);

        delay(30000);
        digitalWrite(greenLed3,LOW);
        digitalWrite(redLed3,HIGH);
        digitalWrite(yellowLed4,HIGH);
        delay(5000);
        digitalWrite(redLed4,LOW);
        digitalWrite(yellowLed4,LOW);
        digitalWrite(greenLed4,HIGH);
        delay(30000);
        digitalWrite(greenled4,LOW);

        }
    }

body:
I'm not sure what a “road” condition is, so I don't know where the “after every road” points in your code are located.  However, you can write a properly-parameterized function to do tests, or a subroutine to do tests and perform actions.  Then place a function or subroutine call whereever you need to perform the test.

Note, the first 14 lines of your code (which define 14 variables that you probably should have defined as constants) could be replaced by an `enum` statement (which defines integer constants) like

    enum { redLed1=7, yellowLed1=6, greenLed1=5, redLed2=4, yellowLed2=3, greenLed2=2, redLed3=8, yellowLed3=9, greenLed3=10, redLed4=14, yellowLed4=15, greenLed4=16, THRESHOLD=700, soundvalue=0 };

or (because `enum` will advance by 1 unit when a value isn't specified) you could say

    enum { greenLed2=2, yellowLed2, redLed2, greenLed1, yellowLed1, redLed1, redLed3, yellowLed3, greenLed3, redLed4=14, yellowLed4, greenLed4, THRESHOLD=700, soundvalue=0 };

For a short sketch like this, the compiler can detect that some of your variables actually are constants, but in general using constants as constants and variables as variables will produce smaller and safer code.


body:
NOTE: all the code below is thrown together; it is there to show you what to do. It will probably require some fixing before it works. The intent should be clear.

From what I read in your code, mostly what you are doing is setting the traffic lights in particular combinations, several times over, with delays in between.

In general, any time you do the same thing, conceptually, several times, it should either be in a loop, or in a function.

In this case, the first thing that (to me) looks like it belongs in a function is: `set all the lights in a particular pattern, and wait for a while`. I would call this function something like `set_lights_and_delay` (or, perhaps `setLightsAndDelay` depending on your coding style). It would take 5 parameters: the state of each light (red, green, or yellow/red, which I would just call yellow), and the time to delay (which may be 0). In this function, you would set ALL the pins, high or low, as appropriate (since your function shouldn't assume the previous state), then delay the appropriate amount of time.

    enum colors {yellow, red, green, yellowred};

    void loop()
    {
        set_lights_and_delay(yellow,red,red,red,5000);
        if(analogRead(A0)>=THRESHOLD)
        {
          set_lights_and_delay(green,red,red,red,40000);
        } else {
          set_lights_and_delay(green,red,red,yellowred,30000);
        }

... and so forth (or whatever light combinations you want).

Now, how would you write this function? This function does the same thing for each light, so it sounds to me like you would want to make a function that takes a color, and the 3 pins to use:

    void setLightsAndDelay(color northlight, eastlight, westlight, southlight; int delaytime)
    {
        setOneLight(northlight, redLed1, yellowLed1, greenLed1);
        setOneLight(eastlight, redLed2, yellowLed2, greenLed2);
        setOneLight(westlight, redLed3, yellowLed3, greenLed3);
        setOneLight(southlight, redLed4, yellowLed4, greenLed4);
        delay(delaytime);
    }

Now, setOneLight is pretty simple to write:

    void setOneLight(color thisLight; int redled, yellowled, greenled)
    {
        if (thisLight==green) // always do the easiest one first.
        {
            digitalWrite(greenled,HIGH);
        } else {
            digitalWrite(greenled,LOW);
        }

        if (thisLight==yellow) || (thislight==yellowred)
        {
            digitalWrite(yellowled,HIGH);
        } else {
            digitalWrite(yellowled,LOW);
        }

        if (thisLight==red) || (thisLight==yellowred)
        {
            digitalWrite(redled,HIGH);
        } else {
            digitalWrite(redled,LOW);
        }
    }

In practice, there would be a lot of other things I'd do: I'd put all the things I know about a single traffic light into a struct; this means I could pass the struct to a function, in one go. I'd put the four traffic lights in an array; this means I could go through them in a loop, rather than calling the same function 4 times individually (great when your city ends up with 1,000 traffic lights!). I would probably put the pattern of lights (green/30000, yellow/10000, red/30000, yellowred/10000) into an array (made a little more difficult by the sensor).


message:
Attiny85 with arduino as ISP

After serveral attempts, I can't make my arduino UNO to program an attiny85, no matter what I do. I've tried under windows 7 and also under ubuntu 14.04, to no avail. I've followed instructions on hi low tech site and similar ones on arduino site. Even some youtube video. Nothing. The wiring of my arduino is as described in those sites, so it should be correct. I'm using the 10uF capacitor too.

This is the output running avrdude manually, extra verbose:

        zop@mikasa:~$ sudo /usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf  -q -pattiny85 -cstk500v1 -P/dev/ttyACM0 -b19200 -Uflash:w:/tmp/build2861466093518309047.tmp/Fade.cpp.hex:i -v -v -v -v -v -v -v -v

        avrdude: Version 6.0.1, compiled on Oct 21 2013 at 15:55:32
                 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/zop/.avrduderc"
                 User configuration file does not exist or is not a regular file, skipping

                 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: Send: 0 [30]   [20]
        avrdude: Recv: . [14]
        avrdude: Recv: . [10]
                 AVR Part                      : ATtiny85
                 Chip Erase delay              : 4500 us
                 PAGEL                         : P00
                 BS2                           : P00
                 RESET disposition             : possible i/o
                 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     6     4    0 no        512    4      0  4000  4500 0xff 0xff
                     Memory Ops:
                       Oeration     Inst Bit  Bit Type  Bitno  Value
                       -----------  --------  --------  -----  -----
                       READ               31     VALUE      7      1
                                          30     VALUE      6      0
                                          29     VALUE      5      1
                                          28     VALUE      4      0
                                          27     VALUE      3      0
                                          26     VALUE      2      0
                                          25     VALUE      1      0
                                          24     VALUE      0      0
                                          23     VALUE      7      0
                                          22     VALUE      6      0
                                          21     VALUE      5      0
                                          20    IGNORE      4      0
                                          19    IGNORE      3      0
                                          18    IGNORE      2      0
                                          17    IGNORE      1      0
                                          16   ADDRESS      8      0
                                          15   ADDRESS      7      0
                                          14   ADDRESS      6      0
                                          13   ADDRESS      5      0
                                          12   ADDRESS      4      0
                                          11   ADDRESS      3      0
                                          10   ADDRESS      2      0
                                           9   ADDRESS      1      0
                                           8   ADDRESS      0      0
                                           7    OUTPUT      7      0
                                           6    OUTPUT      6      0
                                           5    OUTPUT      5      0
                                           4    OUTPUT      4      0
                                           3    OUTPUT      3      0
                                           2    OUTPUT      2      0
                                           1    OUTPUT      1      0
                                           0    OUTPUT      0      0
                       WRITE              31     VALUE      7      1
                                          30     VALUE      6      1
                                          29     VALUE      5      0
                                          28     VALUE      4      0
                                          27     VALUE      3      0
                                          26     VALUE      2      0
                                          25     VALUE      1      0
                                          24     VALUE      0      0
                                          23     VALUE      7      0
                                          22     VALUE      6      0
                                          21     VALUE      5      0
                                          20    IGNORE      4      0
                                          19    IGNORE      3      0
                                          18    IGNORE      2      0
                                          17    IGNORE      1      0
                                          16   ADDRESS      8      0
                                          15   ADDRESS      7      0
                                          14   ADDRESS      6      0
                                          13   ADDRESS      5      0
                                          12   ADDRESS      4      0
                                          11   ADDRESS      3      0
                                          10   ADDRESS      2      0
                                           9   ADDRESS      1      0
                                           8   ADDRESS      0      0
                                           7     INPUT      7      0
                                           6     INPUT      6      0
                                           5     INPUT      5      0
                                           4     INPUT      4      0
                                           3     INPUT      3      0
                                           2     INPUT      2      0
                                           1     INPUT      1      0
                                           0     INPUT      0      0
                       LOADPAGE_LO        31     VALUE      7      1
                                          30     VALUE      6      1
                                          29     VALUE      5      0
                                          28     VALUE      4      0
                                          27     VALUE      3      0
                                          26     VALUE      2      0
                                          25     VALUE      1      0
                                          24     VALUE      0      1
                                          23     VALUE      7      0
                                          22     VALUE      6      0
                                          21     VALUE      5      0
                                          20     VALUE      4      0
                                          19     VALUE      3      0
                                          18     VALUE      2      0
                                          17     VALUE      1      0
                                          16     VALUE      0      0
                                          15     VALUE      7      0
                                          14     VALUE      6      0
                                          13     VALUE      5      0
                                          12     VALUE      4      0
                                          11     VALUE      3      0
                                          10     VALUE      2      0
                                           9   ADDRESS      1      0
                                           8   ADDRESS      0      0
                                           7     INPUT      7      0
                                           6     INPUT      6      0
                                           5     INPUT      5      0
                                           4     INPUT      4      0
                                           3     INPUT      3      0
                                           2     INPUT      2      0
                                           1     INPUT      1      0
                                           0     INPUT      0      0
                       WRITEPAGE          31     VALUE      7      1
                                          30     VALUE      6      1
                                          29     VALUE      5      0
                                          28     VALUE      4      0
                                          27     VALUE      3      0
                                          26     VALUE      2      0
                                          25     VALUE      1      1
                                          24     VALUE      0      0
                                          23     VALUE      7      0
                                          22     VALUE      6      0
                                          21    IGNORE      5      0
                                          20    IGNORE      4      0
                                          19    IGNORE      3      0
                                          18    IGNORE      2      0
                                          17    IGNORE      1      0
                                          16   ADDRESS      8      0
                                          15   ADDRESS      7      0
                                          14   ADDRESS      6      0
                                          13   ADDRESS      5      0
                                          12   ADDRESS      4      0
                                          11   ADDRESS      3      0
                                          10   ADDRESS      2      0
                                           9     VALUE      1      0
                                           8     VALUE      0      0
                                           7    IGNORE      7      0
                                           6    IGNORE      6      0
                                           5    IGNORE      5      0
                                           4    IGNORE      4      0
                                           3    IGNORE      3      0
                                           2    IGNORE      2      0
                                           1    IGNORE      1      0
                                           0    IGNORE      0      0
                                          Block Poll               Page                       Polled
                   Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
                   ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
                   flash         65     6    32    0 yes      8192   64    128  4500  4500 0xff 0xff
                     Memory Ops:
                       Oeration     Inst Bit  Bit Type  Bitno  Value
                       -----------  --------  --------  -----  -----
                       READ_LO            31     VALUE      7      0
                                          30     VALUE      6      0
                                          29     VALUE      5      1
                                          28     VALUE      4      0
                                          27     VALUE      3      0
                                          26     VALUE      2      0
                                          25     VALUE      1      0
                                          24     VALUE      0      0
                                          23     VALUE      7      0
                                          22     VALUE      6      0
                                          21     VALUE      5      0
                                          20     VALUE      4      0
                                          19   ADDRESS     11      0
                                          18   ADDRESS     10      0
                                          17   ADDRESS      9      0
                                          16   ADDRESS      8      0
                                          15   ADDRESS      7      0
                                          14   ADDRESS      6      0
                                          13   ADDRESS      5      0
                                          12   ADDRESS      4      0
                                          11   ADDRESS      3      0
                                          10   ADDRESS      2      0
                                           9   ADDRESS      1      0
                                           8   ADDRESS      0      0
                                           7    OUTPUT      7      0
                                           6    OUTPUT      6      0
                                           5    OUTPUT      5      0
                                           4    OUTPUT      4      0
                                           3    OUTPUT      3      0
                                           2    OUTPUT      2      0
                                           1    OUTPUT      1      0
                                           0    OUTPUT      0      0
                       READ_HI            31     VALUE      7      0
                                          30     VALUE      6      0
                                          29     VALUE      5      1
                                          28     VALUE      4      0
                                          27     VALUE      3      1
                                          26     VALUE      2      0
                                          25     VALUE      1      0
                                          24     VALUE      0      0
                                          23     VALUE      7      0
                                          22     VALUE      6      0
                                          21     VALUE      5      0
                                          20     VALUE      4      0
                                          19   ADDRESS     11      0
                                          18   ADDRESS     10      0
                                          17   ADDRESS      9      0
                                          16   ADDRESS      8      0
                                          15   ADDRESS      7      0
                                          14   ADDRESS      6      0
                                          13   ADDRESS      5      0
                                          12   ADDRESS      4      0
                                          11   ADDRESS      3      0
                                          10   ADDRESS      2      0
                                           9   ADDRESS      1      0
                                           8   ADDRESS      0      0
                                           7    OUTPUT      7      0
                                           6    OUTPUT      6      0
                                           5    OUTPUT      5      0
                                           4    OUTPUT      4      0
                                           3    OUTPUT      3      0
                                           2    OUTPUT      2      0
                                           1    OUTPUT      1      0
                                           0    OUTPUT      0      0
                       LOADPAGE_LO        31     VALUE      7      0
                                          30     VALUE      6      1
                                          29     VALUE      5      0
                                          28     VALUE      4      0
                                          27     VALUE      3      0
                                          26     VALUE      2      0
                                          25     VALUE      1      0
                                          24     VALUE      0      0
                                          23     VALUE      7      0
                                          22     VALUE      6      0
                                          21     VALUE      5      0
                                          20    IGNORE      4      0
                                          19    IGNORE      3      0
                                          18    IGNORE      2      0
                                          17    IGNORE      1      0
                                          16    IGNORE      0      0
                                          15    IGNORE      7      0
                                          14    IGNORE      6      0
                                          13    IGNORE      5      0
                                          12   ADDRESS      4      0
                                          11   ADDRESS      3      0
                                          10   ADDRESS      2      0
                                           9   ADDRESS      1      0
                                           8   ADDRESS      0      0
                                           7     INPUT      7      0
                                           6     INPUT      6      0
                                           5     INPUT      5      0
                                           4     INPUT      4      0
                                           3     INPUT      3      0
                                           2     INPUT      2      0
                                           1     INPUT      1      0
                                           0     INPUT      0      0
                       LOADPAGE_HI        31     VALUE      7      0
                                          30     VALUE      6      1
                                          29     VALUE      5      0
                                          28     VALUE      4      0
                                          27     VALUE      3      1
                                          26     VALUE      2      0
                                          25     VALUE      1      0
                                          24     VALUE      0      0
                                          23     VALUE      7      0
                                          22     VALUE      6      0
                                          21     VALUE      5      0
                                          20    IGNORE      4      0
                                          19    IGNORE      3      0
                                          18    IGNORE      2      0
                                          17    IGNORE      1      0
                                          16    IGNORE      0      0
                                          15    IGNORE      7      0
                                          14    IGNORE      6      0
                                          13    IGNORE      5      0
                                          12   ADDRESS      4      0
                                          11   ADDRESS      3      0
                                          10   ADDRESS      2      0
                                           9   ADDRESS      1      0
                                           8   ADDRESS      0      0
                                           7     INPUT      7      0
                                           6     INPUT      6      0
                                           5     INPUT      5      0
                                           4     INPUT      4      0
                                           3     INPUT      3      0
                                           2     INPUT      2      0
                                           1     INPUT      1      0
                                           0     INPUT      0      0
                       WRITEPAGE          31     VALUE      7      0
                                          30     VALUE      6      1
                                          29     VALUE      5      0
                                          28     VALUE      4      0
                                          27     VALUE      3      1
                                          26     VALUE      2      1
                                          25     VALUE      1      0
                                          24     VALUE      0      0
                                          23     VALUE      7      0
                                          22     VALUE      6      0
                                          21     VALUE      5      0
                                          20     VALUE      4      0
                                          19   ADDRESS     11      0
                                          18   ADDRESS     10      0
                                          17   ADDRESS      9      0
                                          16   ADDRESS      8      0
                                          15   ADDRESS      7      0
                                          14   ADDRESS      6      0
                                          13   ADDRESS      5      0
                                          12    IGNORE      4      0
                                          11    IGNORE      3      0
                                          10    IGNORE      2      0
                                           9    IGNORE      1      0
                                           8    IGNORE      0      0
                                           7    IGNORE      7      0
                                           6    IGNORE      6      0
                                           5    IGNORE      5      0
                                           4    IGNORE      4      0
                                           3    IGNORE      3      0
                                           2    IGNORE      2      0
                                           1    IGNORE      1      0
                                           0    IGNORE      0      0
                                          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
                     Memory Ops:
                       Oeration     Inst Bit  Bit Type  Bitno  Value
                       -----------  --------  --------  -----  -----
                       READ               31     VALUE      7      0
                                          30     VALUE      6      0
                                          29     VALUE      5      1
                                          28     VALUE      4      1
                                          27     VALUE      3      0
                                          26     VALUE      2      0
                                          25     VALUE      1      0
                                          24     VALUE      0      0
                                          23     VALUE      7      0
                                          22     VALUE      6      0
                                          21     VALUE      5      0
                                          20    IGNORE      4      0
                                          19    IGNORE      3      0
                                          18    IGNORE      2      0
                                          17    IGNORE      1      0
                                          16    IGNORE      0      0
                                          15    IGNORE      7      0
                                          14    IGNORE      6      0
                                          13    IGNORE      5      0
                                          12    IGNORE      4      0
                                          11    IGNORE      3      0
                                          10    IGNORE      2      0
                                           9   ADDRESS      1      0
                                           8   ADDRESS      0      0
                                           7    OUTPUT      7      0
                                           6    OUTPUT      6      0
                                           5    OUTPUT      5      0
                                           4    OUTPUT      4      0
                                           3    OUTPUT      3      0
                                           2    OUTPUT      2      0
                                           1    OUTPUT      1      0
                                           0    OUTPUT      0      0
                                          Block

                 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] . [14] . [00] . [00] . [01] . [01] . [01] . [01] . [03] . [ff] . [ff] . [ff] . [ff] . [00] @ [40] . [02] . [00] . [00] . [00]   [20] . [00]   [20]
        avrdude: Recv: . [14]
        avrdude: Recv: . [10]
        avrdude: PAGEL and BS2 signals not defined in the configuration file for part ATtiny85, using dummy values
        avrdude: Send: E [45] . [05] . [04] . [d7] . [a0] . [01]   [20]
        avrdude: Recv: . [14]
        avrdude: Recv: . [10]
        avrdude: Send: P [50]   [20]
        avrdude: ser_recv(): programmer is not responding
        avrdude: stk500_recv(): programmer is not responding
    zop@mikasa:~$

I don't know what else to try, so suggestions are very welcome.

Thanks.

PS: I had to strip out some of the output text because it was bigger than 30000 chars, I hope the info is good enough.

body:
Your log demonstrates that

 - Your programmer settings were correct.
 - You have the right sketch loaded on the Arduino
 - You have the Arduino auto-reset properly disabled.

The failure occurs at the point at which you're trying to enter programming mode. The two most likely error sources are:

 - Your ATtiny85 is not wired up correctly (e.g. you misidentified pin 5 as pin 1, you used a wrong pin on the Arduino, you crossed two signals, etc).
 - Your ATtiny85 is in a mode that prevents ISP reprogramming (programming the `RSTDIBL` fuse is the toughest of these mode, but merely setting the clock source to something odd will also cause this). Does your chip have a past, or is it fresh out of the box?


body: I spent days with exactly the same problem (well, trying to program a 328p). Then I purchased a USBISP (aka USBICSP), and all my problems went away. I got one which had a "program slowly" jumper - setting this jumper will do the equivalent of -b19200, but without needing to explicitly set it, so you can do it from the Arduino IDE. Just my 2c worth.


message:
How best to power down an Arduino for ~5 minutes at a time?

Reading over the datasheet it appears the longest it can shutdown for is 8s so should I just keep a counter in the loop method that checks if it's run 38 times and then execute the code I want? Would this wakeup every 8s hurt battery life much if it's doing nothing but incrementing a counter?

body:
Yes, if you want to wake an ATMEGA (the chip in the Arduino) spontaneously (no outside trigger) from Power Down mode at periodic intervals, the you will need to rely on an interrupt generated by the watchdog timer, which has a maxim timeout of 8s.

Your goal should be to wake, increment and check the timer, and get back to sleep as quickly as possible since the amount of time you are awake will dominate your average power usage while asleep.

Some things to keep in mind...

1. The arduino uses a power regulator which always draws current. If you are going for long battery life, you will need to replace or eliminate this regulator. Much better to have an ATMEGA connected *directly* to a battery.

2. Turn off as much of the chip as possible before going to sleep. Take a look at the power control registers.

3. Make sure you are not driving any unnecessary loads with the GPIO pins when sleeping.

BTW, common wisdom has been that it is best to wake up and run at as fast a clock speed as possible to get your work done and get back to sleep as quickly as possible. However, Jack Ganssle recently published an article that makes a great case for doing the opposite. You will actually get longer battery life if you wake up to a slow clock speed, since this means you can run down the battery to lower voltage (this assumes you don'y need higher voltages for some other part of your circuit). Lots of other great info for designing long running battery-powered systems here...

http://www.ganssle.com/tem/tem275.html

Here is another relevant article about long running Arduinos...

http://www.openhomeautomation.net/arduino-battery/


body: Looks like you've got some great answers already. For a great deal more info and details on the matter, check out what Nick Gammon has written here too: http://www.gammon.com.au/forum/?id=11497 - Power saving techniques for microprocessors


message:
Error while sending message using gsm sim900a module interfaced with arduino uno

The code used for interfacing the gsm module with arduino for sending a message is as follows :-

    #include <GSM.h>

    #define PINNUMBER ""

    // initialize the library instance
    GSM gsmAccess; // include a 'true' parameter for debug enabled
    GSM_SMS sms;

    // char array of the telephone number to send SMS
    // change the number 1-212-555-1212 to a number
    // you have access to
    char remoteNumber[20]= "12125551212";

    // char array of the message
    char txtMsg[200]="Test";

    void setup()
    {
      // initialize serial communications
      Serial.begin(9600);

      Serial.println("SMS Messages Sender");

      // connection state
      boolean notConnected = true;

      // Start GSM shield
      // If your SIM has PIN, pass it as a parameter of begin() in quotes
      while(notConnected)
      {
        if(gsmAccess.begin(PINNUMBER)==GSM_READY)
          notConnected = false;
        else
        {
          Serial.println("Not connected");
          delay(1000);
        }
      }
      Serial.println("GSM initialized");
      sendSMS();
    }

    void loop()
    {
    // nothing to see here
    }

    void sendSMS(){

      Serial.print("Message to mobile number: ");
      Serial.println(remoteNumber);

      // sms text
      Serial.println("SENDING");
      Serial.println();
      Serial.println("Message:");
      Serial.println(txtMsg);

      // send the message
      sms.beginSMS(remoteNumber);
      sms.print(txtMsg);
      sms.endSMS();
      Serial.println("\nCOMPLETE!\n");
    }

the error is found on the 3rd line
    GSM_SMS sms;
as GSM_SMS is not a name type.
what point am i missing here...??

thank you in advance.

body:
Update your IDE software. You need IDE 1.0.4 or later.
I copied your code into my 1.0.5 IDE and compiled it without any error. So it is most probably your version of the Arduino IDE.


message:
Powering LCD Displays without a Breadboard

I hope that this is not a silly question. I may be hoplelessly optimistic in asking, but is there any way to power & display information onto a LCD Display from an Arduino Uno.... Without the breadboard? I am working on a hardware project that has very strict space constraints, and the breadboard is simply not an option.

body: I presume you're looking at [this page](http://arduino.cc/en/Tutorial/LiquidCrystal) - the breadboard is merely a convenience, you can just hard-wire the LCD directly - most don't even come with that header plug soldered on.


message:
TFT and SD don't work together

I use a [2.8" TFT Touch Shield v1][1] and I want to read some data that were stred in sd and plot them with the tft.

When the following code is ordered, to access the data. TFT freezes.... but the code's execution is continued...

        pinMode(SS, OUTPUT);
        // see if the card is present and can be initialized:
        if (!SD.begin(chipSelect)) {
           Serial.println("Card failed, or not present");
        // don't do anything more:
           while (1) ;
        }

        Tempfile = SD.open("DATALOG.TXT",FILE_READ);
        if (! Tempfile) {
           Serial.println("error opening datalog.txt");
        // Wait forever since we cant write data
           while (1) ;}

I tested the code on the example of the tft graphics test... and the result was a freezed tft...

I tried also to run the example: tftbmp but the tft remains black. Once again the code is executed in the loop as i receive results from the Serial monitor but tft is black...

I use an Arduino Uno R3.

Any tip is welcomed

  [1]: https://learn.adafruit.com/adafruit-shield-compatibility/2-dot-8-tft-touch-shield

body:
old topic, but since I'm having the same issues I'll share what I found.

chipSelect is usually 10 for arduino uno, some exemples have other pin setted.

also I found a guy claiming he fixed his issues setting after

pinMode(SS, OUTPUT);
digitalWrite(SS, HIGH);


body: The solution to getting data from SD to TFT may depend on the type of data stored.  See examples included in software for your TFT.  Also it might be possible to solve this issue with 2 Arduinos using Software Serial, which, I believe, is included in the Arduino IDE.  Assume you have stored analog data from a sensor on an SD.  During the recording, you were able to visualize incoming data on your serial plotter and  your sketch also allowed you to see the live data on your TFT.   You now wish to visualize the  data recorded on your SD on the TFT once more. To accomplish this with Software Serial,  the SD card could be mounted on one Arduino and  the TFT on another.  The Tx and Rx pins of the 2 Arduinos must be connected as described in the Arduino Software Serial guide.  This technique should allow user to "fool" the Arduino with TFT into thinking it is receiving live analog data from a sensor.  Since the user has already written the sketch to visualize data from a sensor on TFT , the modifications should be easy.


message:
Web Server Options

I want to give my project a simple web GUI to change config options. I know I could get a shield and write some horrible HTML in C but I'm wondering if there is a better way. Is there another IC I could get to help with this? What's the recommended solution for an embedded web server?

body:
You can buy an ethernet shield of any kind, ENC28J60, wifi module etc etc, and NOT do the html on the chip, just set it up as a server (usually specific the the shield/module you use).

Then you can actually create a local html file on your computer, or even use any webserver on your network or even online. As long as you send the commands to the local address of your arduino.

So if your Arduino ethernet module has the IP-address: 192.168.1.123 then the following form will send a command to the arduino that you can handle in the arduino code:

    <form action="http://192.168.1.123/acommand=1">
    <input type="submit" value="click to send command">
    </form>

So if you create a simple web form to send a command to the arduino you can put this page anywhere, as long as the action is pointing at your arduino IP-address. If you want to go into the whole jquery standard it might be a bit different, unsure how asyncronious submits are handled.

I want to point out that IF you put your simple html page online you dont need to and SHOULDNT open anything in your firewall or router. The code will work as long as the device you are accessing the page from is on the same network as your arduino.


body:
I personally find that one of the simplest solutions to a web server is one of the two following options.

1. Buy a serial cable, and transmit data using the Serial port on your Arduino. You can transmit data to a PC, and use PHP to read the serial port and display the data you would like.

2. Buy a Raspberry Pi. You will be doing the same as step 1, however you don't need a serial cable to use serial between Pi and Arduino. However you might need a 3.3V / 5V converter, which depends if the arduino serial port outputs data at 3.3V or 5V.


body:
**GENERAL IDEA:**

I would recommend getting a simple Wi-Fi and/or Ethernet module.

Then simply set up routes to **receive** and **send** data to Arduino (assuming `arduino_ip` to be your Arduino's IP), and `GET` and `POST` being [HTTP verbs][1]:

Receive data from Arduino:

`GET  http://arduino_ip/data`

Send data to Arduino:

`POST http://arduino_ip/data`

Now use any Web development Framework/Language (`PHP`, `Node.js`, `Python`) to receive and send data.

**NO ADDITIONAL MODULES SOLUTION:**

The above method will allow the arduino and server to communicate if they're on the same network. However, if you can constrain the server to be connected by `USB` to Arduino, you can use `Node.js`, `Python` (even `PHP`) to directly communicate to Arduino.

**ANOTHER SOLUTION**:

Add a **Raspberry Pi**, have it connected to Arduino by USB (Arduino's `Serial`), and the use Raspberry's Ethernet to bring in networking (Raspberry Pi can host a server itself)

  [1]: http://www.tutorialspoint.com/http/http_methods.htm


body:
I'm currently using the ESP8266 modules. They are available for little money on eBay and the like and they provide a pretty nice Wifi-Module. You can even (and I would recommend that) be programmed by the Arduino IDE using some clever core that a few people built here: https://github.com/esp8266/Arduino

Using that you got a Wifi-Server built into the delivered Libraries that can provide basic functions. It can also output files from an SD card if available, there is an example for that.

Aside from that the module has a lot of Flash and you might not even need the Arduino if you don't need a lot of I/O, if you need a lot of I/O then you might want to communicate across a serial link. You will need to make sure to lower the voltage for the ESP, either use a 3.3V Arduino or build a level converter between the Arduino and the ESP, like this: http://www.hobbytronics.co.uk/mosfet-voltage-level-converter

It's not as easy as using a Wifi-Shield but it's very cheap to use.


body:
The Arduino in combination with a wifi/ethernet module will not give you a lot of options to work with. There are currently no libraries that will give you features like including stylesheets, AJAX or websockets. If your project allows it, due to the number of I/O pins you need etc: replace your Arduino with a ESP8266

If you want to produce something fancy: go with the ESP8266. Getting everything setup and working will be a bit harder than with the Arduino, but it will be worth the effort. You can program it in Lua, but that will only give you access to some basic functions. Just write your program in C like you did on the Arduino. There is a thing called Sming framework which allows you to import Arduino libraries with only changing in few lines of code. The Sming framework also includes a HTTPserver with AJAX, websocket, POST/GET, pre-processing, and style/js-file inclusion features.

The web framework is easier than it is in most webframeworks for the pc! The hard part is installing the toolchain and uploading your first bit of code, but once you've got that done it will be easy to figure out the rest. The Sming framework also contains examples for everything you think of.

If you are planning on buying an ESP8266 I recommend you get a few. The basic ESP-01 cost around $2,40 on ebay, but get a fancier one too with a few extra IO pins. I have also got a development version which can be programmed with a USB cable. It is really usefull for developing your program since you don't have to connect a USB-serial device every time just plug a USB cable. When I think my program is done, I upload it to a more basic and replaceable version of the ESP8266 and fix it in my project.

So a summary: It will be harder to figure everything out, but once you've got everything done it will be worth the effort! Here are a few links:

This will show you the power of a ESP8266:
[ESP8266 oscilloscope with websockets video][1]

The Sming framework:
[Sming framework github repo][2]

  [1]: https://www.youtube.com/watch?v=8ISbmQTbjDI
  [2]: https://github.com/SmingHub/Sming


message:
Integrating Freescale Multi Sensor board with Arduino

I recently bought Freescale's [FRDM-FXS-MULTI-B](http://uk.farnell.com/freescale-semiconductor/frdm-fxs-multi-b/dev-board-xtrinsic-sensor-kinetis/dp/2443150), and have been trying to integrate it with an Arduino UNO. The board descriptions say that it has the shield layout that matches that of an Arduino shield. So in theory, I should be able to integrate it fine.

The problem comes when I plug it in and try to program the Arduino. As soon as I plug it in, the board resets and hangs. If I try to upload a simple code (just reading the analogue signal from the light sensor), the IDE hangs when uploading. Sometimes, I can fix it by removing the shield and pressing the reset button, but sometimes that doesn't work: the computer doesn't recognise the Arduino on the port, and the IDE removes the port from the Port Selection option. When I do remove it and it resumes functioning normally, and I re-attach the shield, the board resets and hangs again, until I go into the Serial Monitor.

With this board, I realised the Bluetooth module is connected to the Serial Receive pin, which explains the hang in the IDE, but I cannot understand why it resets and hangs when I plug it in.

Does anyone have any experience with this board, and can help me out? Why can I not find any tutorials online? With the multitude of sensors on this shield, I'm guessing you can access them via normal I2C and SPI communications, right? How do you use the Bluetooth module on the board?

body:
So... 20 months later I stumbled upon this question, only to find out I wrote it. Awkward! Anyway, for anyone who stumbles across this question in the future, here is the answer.

The Rx pin is connected to the Bluetooth module, and as such the module will keep the pin in an idle state (either idle-high or idle-low). The Rx pin of the Arduino UNO (or the Rx0 pin on the Mega/Due) requires to be free of anything that may interfere with the upload. The Arduinos rely on the Rx pin for the sketch upload. If anything is connected to it, the IDE will freeze and nothing will be uploaded. Simply disconnect the FRDM board, upload the code, and put the board back in place. Then it should work.


message:
How to accept user input (array, variables,...)

I am working on a project using my Arduino mega2560 that triggers a solenoid (maximum of three solenoids), my camera and my flash (maximum of two flashes). The core routine is there, and working.

Now I want to refine this by adding a menu and 16x2 LCD with 6 buttons (up/down/left/right/select/reset). This is meant to be so the user can change the default values for:
- the amount of solenoids to be used (max 3),
- the amount of drops per solenoid (max 3),
- the time between drops and
- the time between active solenoids.
The layout of the menu is there, but not yet coded.

My default values for solenoids used, droplet size, droplet timing, solenoid timing, camera delay and flash(es) delay(s) are put in an array. Through the menu the default values will be presented to the user. He can accept (select button) or change the value within certain limits using the up/down buttons.

The question is, what is an easy (for a beginner like me) to program way to accept user input and store this in the array, overwriting the presented default value? I also would like to have the possibility for the user to back out of a menu option and leave the default setting of the specific submenu value.

I was thinking of creating a shadow array with blanks, to be filled in by the user and copy all the values to the array that will be used by the core routine. Another line of thinking leads me to just abandoning the array and making use of a bunch of variables. As you will probably see, I need some advice here.

Thanks very much for reading and your advice, happy to answer questions that may help clarify the issue.

Regards, Kiezel

body:
Your hardware side for the user to use can be based on an ADC type keypad pictured below, this only uses one pin and is pretty reliable. Note that not all code is given or design as it would be useless for learning and I also put effort into the code this came from, logic helps with the rest of each part...
![enter image description here][1]

The code is pretty simple:

You would write a function like so~

    char keypad(int in){

 if(in < 949){
  if(in > 935){
   return 's'; //select
  }
 }

 //......

 else return = 0;
    }

Next would be the code for the menu, you could hold the default values in an array and then modify them in the code, with set positions for defaults, considering

> My default values for solenoids used, droplet size, droplet timing, solenoid timing, camera delay and flash(es) delay(s) are put in an array.

***Example from one of my projects***

    //Menu levels
    #define level0 0
    #define level1 1
    #define level2 2
    //master level of current point
    #define mlevel 6
    #define msub_level 7
    //\\\\\\\\\\\\\\\\\\\\
    #define sub_level1 0
    #define sub_level2 1
    #define sub_level3 2
    #define sub_level4 3
    #define sub_level5 4
    // default level on boot
    uint8_t current_level = mlevel;

Next would be to push the data to

    int navigate(char key){
 if(key == 'u'){
   if(current_level == mlevel){
   if(count == 3){ //roll-over

    count = 0;
    //update LCD....
   }
   else count++;
            //update LCD....
  }

  if(current_level == msub_level){

   if(count == 5){//roll-over

    count = 0;
    //update LCD....
   }
   else count++;
   //update LCD....
  }
 }

    //..... other ones here

     return count;
    }

You would use the returned count to find the relative place in your array. e.g:

`int default[n] ={x,y,z,...};`

>get the key > put into `navigate()` > put into dafault[`count`];

You would also change the default after

 - It has been changed or,
 - The key has been debounced, i.e. use logic to determine if the key has changed state or,
 - The user has chosen 'accept'

Update of the LCD can be done at the points you want it done

  [1]: https://i.stack.imgur.com/veCjf.png


message:
How to make the motor car move left-forward / left-backward/ right-forward/ right-backward

I'm using an Arduino Uno to make a motor car. And I successfully made it move forward / backward / left / right.

    void forward(void) {
      analogWrite(EA, 254); //speed 0 - 255
      analogWrite(EB, 255); //speed 0 - 255
      digitalWrite(EN2, LOW);
      digitalWrite(EN3, HIGH);
      digitalWrite(EN4, LOW);
      digitalWrite(EN5, HIGH);
    }

    void backward(void) {
      analogWrite(EA, 255); //speed 0 - 255
      analogWrite(EB, 255); //speed 0 - 255
      digitalWrite(EN2, HIGH);
      digitalWrite(EN3, LOW);
      digitalWrite(EN4, HIGH);
      digitalWrite(EN5, LOW);
    }

    void left(void) {
      analogWrite(EA, 180); //speed 0 - 255
      analogWrite(EB, 180); //speed 0 - 255
      digitalWrite(EN2, LOW);
      digitalWrite(EN3, HIGH);
      digitalWrite(EN4, HIGH);
      digitalWrite(EN5, LOW);
    }

    void right(void) {
      analogWrite(EA, 180); //speed 0 - 255
      analogWrite(EB, 180); //speed 0 - 255
      digitalWrite(EN2, HIGH);
      digitalWrite(EN3, LOW);
      digitalWrite(EN4, LOW);
      digitalWrite(EN5, HIGH);
    }

The problem is, I found it is quite strange if I need to first press left/ right and press forward to turn around. I would like to make 4 extra buttons for left-forward / left-backward/ right-forward/ right-backward. Any ideas to create 4 extra functions for that?

Thanks for helping.

**Update: Connection**

    int EN2 = 14;
    int EN3 = 15;
    int EN4 = 16;
    int EN5 = 17;
    int EA = 3;
    int EB = 5;

**Update: Attempted code and hardware connection**

    void left_top(void) {
      analogWrite(EA, 128); //speed 0 - 255
      analogWrite(EB, 255); //speed 0 - 255
      digitalWrite(EN2, LOW);
      digitalWrite(EN3, HIGH);
      digitalWrite(EN4, LOW);
      digitalWrite(EN5, HIGH);
    }

    void right_top(void) {
      analogWrite(EA, 255); //speed 0 - 255
      analogWrite(EB, 128); //speed 0 - 255
      digitalWrite(EN2, LOW);
      digitalWrite(EN3, HIGH);
      digitalWrite(EN4, LOW);
      digitalWrite(EN5, HIGH);
    }

    void left_down(void) {
      analogWrite(EA, 128); //speed 0 - 255
      analogWrite(EB, 255); //speed 0 - 255
      digitalWrite(EN2, HIGH);
      digitalWrite(EN3, LOW);
      digitalWrite(EN4, HIGH);
      digitalWrite(EN5, LOW);
    }

    void right_down(void) {
      analogWrite(EA, 255); //speed 0 - 255
      analogWrite(EB, 128); //speed 0 - 255
      digitalWrite(EN2, HIGH);
      digitalWrite(EN3, LOW);
      digitalWrite(EN4, HIGH);
      digitalWrite(EN5, LOW);
    }

Left top / right top seem not to move at all, and right top / down is just similar to right / left.

**And for hardware, I am using**

Arduino  AR 293d

![enter image description here][1]

For the motor connection, it's like this:

![enter image description here][2]

  [1]: https://i.stack.imgur.com/6TtmL.png
  [2]: https://i.stack.imgur.com/V397E.jpg

body:
Regarding the pins - I wanted to find out the physical (hardware) connections.

Pending an updated answer I presume the EA and EB will set the speed for two motors and EN2/EN3 and EN4/EN5 control the direction of the motors. If that's the case you could make the car turn sideways but changing the speed of only one of the motors. For example:

    void forwardLeft(void) {
      analogWrite(EA,128); //speed 0 - 255
      analogWrite(EB,255); //speed 0 - 255
      digitalWrite(EN2,LOW);
      digitalWrite(EN3,HIGH);
      digitalWrite(EN4,LOW);
      digitalWrite(EN5,HIGH);
    }

I assume that EA is the left motor and EB is the right motor. This will make the right one rotate twice as fast as the left one so the car should go forward, but also turn left. If you keep this running the car should end up going in a circle. By making the `128` lower you will change how fast the car is turning.

The other functions should be similar.

_**Caveat emptor** - of course this will mean nothing if the beginning assumptions are incorrect._

**EDIT**
Can't figure out why it doesn't work without having the thing in my hands. Have not found a schematic for that board, but intuitively it should work as described above.

Things you can do to try to figure out - try different numbers instead of 128, the speed of the motors might not vary linearly with the voltage. What you need to obtain is to have one motor go twice as fast as the other one and in the same direction. That should turn the car around.


body:
just go to this link.
Visit to
https://www.arduino.cc/en/Tutorial/PWM

 At first use PWM to both right side and left side motor.
When right side motor spin/rotate at 255 value make leftside motor rotation speed at about 100 then you will see that it goes left-forward like wise you do rest of other.

Eg.

<!-- language-all: lang-cpp -->

    void setup()
    {
      //LEFT MOTOR
      pinMode(7, OUTPUT);
      pinMode(8, OUTPUT);
      pinMode(9, OUTPUT); // connect pwm pin of left motor at pin9

      //right motor
      pinMode(10, OUTPUT);
      pinMode(11, OUTPUT);
      pinMode(12, OUTPUT); motor // connect pwm pin of right motor at pin12
    }

    void loop()
    {
      digitalWrite(7, HIGH);
      digitalWrite(8, LOW);
      analogWrite(9, 100);
      delay(1000);
      digitalWrite(10, HIGH);
      digitalWrite(11, LOW);
      analogWrite(12, 255);
      delay(1000);
    }


message:
How to return a message when calling by a TCP connection?

I am working on a communication between Android and Arduino board.

The Android makes a TCP connection with the board and successfully sends some strings to the board.

The problem is, there is an int in my Arduino code (e.g. `int distance`) and I would like to pass that back to my Android device.

I have handled the Android side already, but I do not know how to return a message from Arduino.

    in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

                    //in this while the client listens for the messages sent by the server
                    while (mRun) {
                        serverMessage = in.readLine();

                        if (serverMessage != null && mMessageListener != null) {
                            //call the method messageReceived from MyActivity class
                            mMessageListener.messageReceived(serverMessage);
                        }
                        serverMessage = null;

                    }

This is the Android side code but I think that it is not a specific Android problem, there should be some way for Arduino to make a response of an integer variable (without concern what is the source device)?

What I should do in Arduino for making that response?

body:
I'm assuming that you are using an Ethernet shield, as nothing about this is stated. But solution is really similar between many network solution.

Once a TCP connection has been established, it can be used like you would use the Serial;

you'll probably end up having something similar to:

    EthernetClient client = server.available(); //accept a new connection
    if (client) { //if valid connection
      client.print(distanceValue);
      client.close(); //close connection
    }

look at the [official API reference][1] for a more detailed list of available command.

  [1]: http://arduino.cc/en/reference/ethernet


message:
Storing data (strings) if ethernet fails to send it

Flow goes something like:

Read sensors
Send data
If send fails store the data in eeprom/flash/sd
If sent check if any previous ones have failed and send those

So my question is what's the best storage option to save the data? Is there an easy way to save strings or am I going to have to write it byte by byte?

body:
In my opinion SD would be the best way because it is cheap, small, relatively fast and easily portable on a PC, using FAT (but it uses a lot of resources) or even raw; but then you have to use some more trick to get to the raw data from a OS, its not just "plug n read".

The SD library uses FAT under the hood, and it gives you a nice and easy interface. Just remember that SD works at 3.3V, and connecting them directly to arduino will break them fast, even if often not immediately.


body:
Other than SD (see @lesto's answer), you can also store the data locally on your Arduino's EEPROM. You can store a byte at a time. The amount of storage varies from chip to chip, the AtMega328p that powers Arduino UNOs has 1kb. The eeprom is persistent over resets, I suspect not if you're reprogramming it, so think how you're going to get the data off before you start storing valuable info.

At 1kb, size is at a premium, so you probably don't want to use text strings, just the raw data. Remember that, if your chip resets, you will lose any memory variables with info about e.g. where you're up to. I would probably include some sort of checksum of each record, to test if the data is yours or not. I would include a counter or timestamp, so when you are starting up, you can read all memory to find the newest (valid) record; the next record is one greater, and at the next memory address. When you get to the end of the memory, restart at 0. If you store a one-byte counter, a one byte checksum, and 2 bytes of data, you can store 256 records. You could mark records off as you send them, or keep a counter in memory of which ones you have already sent - if your chip is reset, it may resend old records (very rarely), which your server would need then need to handle.

If using eeprom, try to spread your writes - you get a certain number of writes PER MEMORY LOCATION, so if you always write to address 15, then 15 will wear out before the others. I think I saw a reference to "100,000 writes", but am unable to find that now to confirm. 100,000 writes at 1 write per second to the same address will have your eeprom fail after about 27 hours; 4 writes per second spread over 1K will cause a fail after about 10 months.

Test what happens when you write past the end of memory - some possible scenarios include failed write, write to a different location (e.g. trying to write to address 1024+1 will write to address 1024), not writing at all and reading it back will return 0, 255, or another number (consistent or otherwise)

See http://arduino.cc/en/Reference/EEPROM on how to write to eeprom.

To find out how many bytes of memory your EEPROM has, use E2END. Addresses run from 0 to E2END, so E2END might be 1023 (0 to 1023=1024 bytes).


message:
Which thermometer for home brewing

**Hello,**

I have an Arduino Yun and I brew beer.

I would like to log the temperature of the beer at all time during the fermentation process (final stage).  This means the thermometer would have to remain in the beer during this time (10 days).  The temperature would be < 40 degrees Celsius (probably around the 20 degree mark).

**Question: What temperature sensor would be best suited to this task?**

It must be:

 - Food grade
 - Can be used in alcohol for extended periods
 - Can be hooked up to Arduino (i.e. add a library and ready to go)

**Thanks, Dan.**

body:
You are looking for a thermocouple.

They need some specific chip to be read, so you'll probably want to spend a bit more and get a chip with a digital interface, there are some witch has arduino library, like MAX6675 (output at 1Hz, 0.25° precision).

As this chip read "C type" thermocouple, you just have to find the right probe for your needing, with probably can be found in many specialized store.

You may even buy a normal k probe, and then wrap it up in some protective case. Obviously that case should be designed to let the heat flow easily, but without short circuiting the probe; a food plastic bag;

or just spend a little more money and buy a stainless steel probe


body:
I am not a brewmaster but from what I understand the temperature will change slowly. Your problem is not to contaminate the beer, you can use a stainless possibly even a plastic tube that is sealed on the immersion side and use a
DS1820B sensor commonly used on Arduinos as well as other platforms. The response will be slower then if the sensor is inserted directly but since the change is slow it should work AOK. This keeps it simple and probably something you have done before.


message:
What type of connector does the GROVE system use?

What type of connector does [GROVE][1] use?

I'm interested in wiring some old sensors so they're compatible with GROVE, so I first need to identify the connector so I can buy the housing and pins to crimp. It looks to be some type of JST connector, but there are [many different sizes][2], each with incompatible pitches and a lot of retailers often advertise them incorrectly. Unfortunately, I can't find any documentation of the connector on Seeedstudio's site.

  [1]: http://wiki.seeed.cc/Grove_System/
  [2]: http://en.wikipedia.org/wiki/JST_connector

body:
It's definitely not a jst-connector - please have a look at them here http://www.amazon.com/Seeedstudio-20-pack-Grove-Connectors/dp/B00BB0I7V2 (the seeed website seems to be down at the moment). I Eagle you would search for a TWIG-4P-2.0.
These guys have 4PINs which are connected to ground and VCC + the data lines depending on the sensor you want to use.


body:
It is not a JST connector. There are ramps on the side of the connector that won't allow the grove/seeed cables slide into the connectors. After I shaved/cut off the ramps, to allow them to fit into the connector, I found that the pins are slightly offset in there vertical alignment.
This appears to be a custom connector. However, if anyone knows better, I would be interested, but the answer is not JST.


body:
It looks like the Grove connector is proprietary. I emailed Seeedstudio, and they directed me to [this datasheet][1]. Unless I'm reading it incorrectly, it doesn't appear to correspond to any type of JST connector, although it's similar. It has 2mm pin spacing, which would make it closest to the [JST-PH type][2], but all the other dimensions are slightly different.

  [1]: https://statics3.seeedstudio.com/images/opl/datasheet/3470130P1.pdf
  [2]: https://www.sparkfun.com/datasheets/Prototyping/ePH.pdf


body:
I believe the OEM part is NS-Tech 1125S-4P: [Wire to Board connector > PITCH 2.00mm > 1125 Series][1]

Good luck finding a vendor!

  [1]: http://www.nstech.com.cn/en/products/product_202201151603323190.html


body: It is proprietary.  It makes it hard to build your own custom length cables. But then if you are, you probably don't need Grove modules in the first place.  I would use them more if I could build a cable.  The JST PH 2.0 definitely doesn't work well, even if you shave it down.  The PH also doesn't have the locking tab that the Grove connector does. It's interesting that some of the Grove boards have both JST PH 2.0 as well as Grove connectors for different purposes (e.g. LiPo battery connector)


body:
Here there are GROVE connectors in SMD and a drawing is included: [Grove - SMD Universal 4 pin connector (10 Stück)][1].

[![Three pin connector diagram][2]][2]

  [1]: http://www.ebay.de/itm/Grove-SMD-Universal-4-pin-connector-10-Stuck-/152174510967?hash=item236e4ec377:g:ItwAAOSwWfFXj1jf
  [2]: https://i.stack.imgur.com/yBS9v.jpg


body:
Following up from Cerin's [answer][1], as the link to the datasheet on Seeed's website appears to have expired, I also contacted the technical support team at Seeed.

They sent me, I assume, the same datasheet. Here is a link to it, [110990030-model][2], and here is a screenshot, should the link die in the future:

[![Grove connector datasheet][3]][3]

Along with the datasheet, I also received the following information:

> 11006005(OLD) -->110060161(NEW)
>
> Grove - Light Sensor change to V1.2, which had another light sensor.
>
> Others same.
>
> 101020040(OLD)-->101020175(NEW)
>
> Just some performance optimization.

From MCU's [answer][4], and the linked eBay item for the [Grove - SMD Universal 4 pin connector (10 Stück)][5], the diagram below also shows the dimensions. However, it is quite clearly only a **three pin** connector, and *not* the **four pin** connector used in the Grove system:

[![Grove SMD connector][6]][6]

See also [Grove connector][7].

  [1]: https://arduino.stackexchange.com/questions/9030/what-type-of-connector-does-the-grove-system-use#answer-18583
  [2]: https://gr33nonline.files.wordpress.com/2016/11/110990030-model.pdf
  [3]: https://i.stack.imgur.com/A6rtU.png "Grove connector datasheet"
  [4]: https://arduino.stackexchange.com/questions/9030/what-type-of-connector-does-the-grove-system-use#answer-26551
  [5]: http://www.ebay.de/itm/Grove-SMD-Universal-4-pin-connector-10-Stueck-/152174510967?hash=item236e4ec377:g:ItwAAOSwWfFXj1jf&nma=true&si=jpWiQ5brMZFPqTrPvqibsJAPgbs%3D&orig_cvip=true&rt=nc&_trksid=p2047675.l2557
  [6]: https://i.stack.imgur.com/5GnNg.jpg "Grove SMD connector"
  [7]: https://gr33nonline.wordpress.com/2016/11/16/grove-connector/


body:
Here is the updated link on the seed website.

http://wiki.seeedstudio.com/wiki/File:3470130P1.pdf

Also note that Digikey now stocks seeedstudio stuff.

http://www.digikey.com/product-detail/en/seeed-technology-co-ltd/110990030/1597-1082-ND/5482560

http://www.digikey.ca/product-detail/en/seeed-technology-co-ltd/110990037/1597-1083-ND/5482561


body:
These look like equivalents to the Molex Sherlock-series connectors ([www.molex.com/molex/products/family?key=sherlock][1]). I've ordered a Grove-compatible board that should get here Monday. I'll try connecting a Sherlock connector to it, and if I remember I'll give an answer back here as to whether it mates and locks properly. The pin pitch and pin dimensions are the same, I can tell that already, and it sure "looks like" a Sherlock connector.

  [1]: http://www.molex.com/molex/products/family?key=sherlock


body:
Have a look at:

YEONHO_ELECTRONICS_20037wr

YEONHO_ELECTRONICS_SMH200

YEONHO_ELECTRONICS_YST200

or

CJT CONN A2008 WR S 4P / A2008 H
......


body:
This connector [A2005(PHB-SMD)](https://www.lhecn.com/a2005/) Series has become common in China, I have not found a supplier in the USA that carries it yet.

There is a similar connector, the [A2008 series here](http://www.cnjmp.cn/en/YH-200-LED-light-bar-connector/A2008WR-S-NP.html).

A2005 images without-latching-plug:
[![A2005 images][1]][1]

  [1]: https://i.stack.imgur.com/ro01A.png


body:
I might have found at least one of the many possible manufacturers that make these types of connector. The manufacturer is Boom Precision Electronics and you can buy the connectors through [LCSC][1].

Here are the links to four of the connectors on LCSC.

[Vert. THT 4-Pin 2.00mm][2]
[RA THT 4-Pin 2.00mm][3]
[Vert. SMD 4-Pin 2.00mm][4]
[RA SMD 4-Pin 2.00mm][5]

Disclaimer: I never bought these connectors listed above so I never got the chance to try and mate the grove cable housing with it. It however does seem to fit the dimension and shape based on the drawings.

  [1]: https://www.lcsc.com/
  [2]: https://www.lcsc.com/product-detail/Wire-To-Board-Wire-To-Wire-Connector_BOOMELE-Boom-Precision-Elec-HY-4A_C146064.html
  [3]: https://www.lcsc.com/product-detail/Wire-To-Board-Wire-To-Wire-Connector_BOOMELE-Boom-Precision-Elec-HY-4AW_C146068.html
  [4]: https://www.lcsc.com/product-detail/Wire-To-Board-Wire-To-Wire-Connector_BOOMELE-Boom-Precision-Elec-C161188_C161188.html
  [5]: https://www.lcsc.com/product-detail/Wire-To-Board-Wire-To-Wire-Connector_BOOMELE-Boom-Precision-Elec-C146060_C146060.html


message:
Interfacing accelerometer LSM303DLH with Arduino UNO using I2C

I am trying to connet a tri axis accelerometer LSM303DLH to arduino UNO using the libraries taken from the following links (https://github.com/adafruit/Adafruit_LSM303DLHC and/or https://github.com/ryantm/LSM303DLH) but none of them work.
Using the following connection:
SCL on A5,
SDA on A4,
Vin on 5V,
Gng on Gnd.

I should be able to see the values of the accelerometer but the serial monitor is empty.

I've tried inserting a few print in the libraries to understand where the execution stops, basically after a Wire.endTrasmission() the program doesn't go forward.
How can I connect the accelerometer using I2C?

body:
Are you using one module bought from Adafruit?

Make sure the connection is correct between the sensor and Arduino, then make sure that the script doesn’t get stuck when the Wire is begun.

Another thing that you need to make sure, is to have the correct address, it depends from board and each one can have a different one or a selector.

[This can be helpful to figure out what the wiring is][1]

  [1]: https://learn.adafruit.com/lsm303-accelerometer-slash-compass-breakout/assembly-and-wiring


message:
Arduino ADC read bad value

I have an Arduino device and I'm trying to read two voltages. The first one is the Arduino Vcc by using the bandgap value 1.1V (this requires raw access to registers since it's not implemented in analogRead). The other one is checking the battery voltage using the badgap as a reference. I want both of them because I'm doing a study on the battery life when using a step-up converter.

I'm using these pieces of code:

    // Read bandgap with Vcc as reference - this will give use the Vcc
    ADMUX = DEFAULT << 6 | 14;
    delayMicroseconds(250);
    bitSet(ADCSRA, ADSC);
 while(bit_is_set(ADCSRA, ADSC))
  ;
 word x = ADC;
 Serial.println(x);

    // Read A1 with 1.1V bandgap as reference - this will give battery voltage
    ADMUX = INTERNAL << 6 | 1;
    delayMicroseconds(250);
    bitSet(ADCSRA, ADSC);
 while(bit_is_set(ADCSRA, ADSC))
  ;
 word x = ADC;
 Serial.println(x);

The problem that I have is that separately they seem to work well, however when using them together the first piece of code ruins the reading for the second one. The culprit is the line `ADMUX = DEFAULT << 6 | 14`. This sets up the default reference (chip voltage) and reads channel 14 (which is the 1.1V). I can't figure out why after using this line changing back with `ADMUX = INTERNAL << 6 | 1` doesn't work.

body:
The datasheet says:

> The first ADC conversion result after switching reference voltage
> source may be inaccurate, and the user is advised to discard this
> result.

Then you could try to take each reading twice, looping over four ADC
readings:

1. Read bandgap with Vcc as reference, discard the value.
2. Re-take the same, keep the value.
3. Read A1 with 1.1V bandgap as reference, discard the value.
4. Re-take the same, keep the value.


message:
Continuous servo not setting speed correctly

I have two continuous servos connected to my Uno, and I'm running this code on it:

    leftServo.write(91);
    rightServo.write(102);
    delay(3000);

    leftServo.write(112);
    rightServo.write(81);
    delay(3000);

    leftServo.write(91);
    rightServo.write(102);
    delay(3000);

    int i;
    while(1) {
      i++;
    }

When I run the code, the wheels stop for three seconds (91 and 102 are the zero values for these servos) then they spin for three seconds, then the left servo stops, but the right one only slows down about half way, it doesn't stop, even though the exact same number is used as before.

I can't figure out why this is?

body: Issue was fixed by adding a delay of 100ms between servo writes, smaller values may work, but I haven't tried yet


message:
Timer1 arduino makes Serial not work

Running the code below, when I send any character in the Serial arduino is not printing "a" back. I think it's something wrong with the timer1 code but it should work cause this code was given by my teacher in C class.

    ISR(TIMER1_COMPA_vect){

    }

    void setup() {

        Serial.begin(115200);

        //http://www.instructables.com/id/Arduino-Timer-Interrupts/?ALLSTEPS
        noInterrupts();
        TCCR1A = 0;// set entire TCCR1A register to 0
        TCCR1B = 0;// same for TCCR1B
        TCNT1  = 0;//initialize counter value to 0
        // set compare match register for 1000000hz increments with 8 bits prescaler
        OCR1A = 1;// = (16*10^6) / (1000000*8) - 1 (must be <65536)
        // turn on CTC mode
        TCCR1B |= (1 << WGM12);
        // Set CS11 bit for 8 prescaler. Each timer has a different bit code to each prescaler
        TCCR1B |= (1 << CS11);
        // enable timer compare interrupt
        TIMSK1 |= (1 << OCIE1A);
        interrupts();

    }

    void loop() {

        if (Serial.available()) {

         Serial.println("a");

        }

    }

body:
This is a more complicated question than the standard Arduino questions, so I took a lot of time to look into it and find out the exact answer--since I was also curious. **I have posted a very thorough answer to your question here on Stack Exchange, so please look there: https://stackoverflow.com/questions/28880226/timer1-arduino-makes-serial-not-work/28887781#28887781**

I should also note that Gerben's comment is spot-on. I recommend a value no less than 20, since you configured the counter to increment once per 0.5us. This way, a value of 20 only calls the ISR every 10us, which should keep the ISR from occurring so often that it locks up your code.  As you'll see in my link above, the other main problem is you forgot to define your ISR function that is required when you enable the interrupt.

**If this meets your needs, please put a green check next to my answer to mark it as correct.**