text:
Is SoftwareSerial left out for the ATTiny85/84?
I want to use SoftwareSerial with my ATTiny85 and when I google it several projects claim that they are using it... I downloaded the hardware from https://code.google.com/p/arduino-tiny/, but when I try to add SoftwareSerial and compile I get:
fatal error: SoftwareSerial.h: No such file or directory

Switching the board to UNO makes the problem go away, so did they leave it out? How can I fix this?

Cannot duplicate.

I did duplicate with Arduino IDE 1.6.3 and found an answer (below).

Short answer - no. It's not left out, on the contrary.
But before addressing to the compiler error you mentioned, a small clarification:

I downloaded the hardware from https://code.google.com/p/arduino-tiny/

The link you provided is not hardware, but software called the ATtiny core files. It contains the necessary files that will help you compile and upload code from Arduino IDE to the ATtiny (even when using ArduinoISP as programmer).
The SoftwareSerial is a library that comes with the Arduino IDE zip/installation. If you have downloaded the latest version of Arduino IDE from the Arduino Website, you should be able to find the SoftwareSerial library files located at:
[Path to Arduino installation folder]\libraries\SoftwareSerial

Example for SoftwareSerial library files you should expect to find there are SoftwareSerial.cpp and SoftwareSerial.h.

fatal error: SoftwareSerial.h: No such file or directory

The compiler error you receive seems to imply that the compiler cannot find the header file (SoftwareSerial.h) for SoftwareSerial library. This indeed seems quite odd, since this library does not require any special installation, and as mentioned, is part of the libraries that are built into the Arduino IDE installation.
So, to mitigate this, I would recommend that you will:

Make sure the library folder exists in the location mentioned above
If it doesn't, then you should probably re-download the Arduino IDE installation, and after that install the ATtiny core files as per the instructions (important!). Installation instructions are located in the README file inside the ATTiny core zip file
(tiny\avr\README).
If it does exist, and you still get this compiler error, then you must have a corrupted installation (perhaps the compiler include folders is messed up). I would still recommend following the re-installation as mentioned in the previous bullet.
Make sure that you can find the ATtiny 85 in the board list, at Tools->Board and that it is selected.
Another angle that might shed more light on this error, would be to turn on the verbose output for the compiler (you can do it in the Arduino IDE, by choosing File->Preferences-> "Show verbose output during" and checking "compilation"). Verbose output can help you track down any compiler command line errors, like missing include folders.
Last but not least, if the SoftwareSerial folder exist, you could use the Arduino IDE to check if the IDE can identify its existance, by going to Sketch->Import Library, and looking for SoftwareSerial. If it's not there, then the folder is not located properly under the 'libraries', verify the path as mentioned above (did you move it?)

Finally, when you will be able to compile your code, try using the SoftwareSerial example that comes with the library to check it. Note that it is not going to work 'out-of-the-box' as with the Arduino Uno; The ATtiny does not have the same FTDI hardware for communicating directly with USB, so for sending and receiving serial messages using the ATtiny you will have to either use the Arduino Uno as a proxy (using the Uno's pins 0 & 1) or to use dedicated USB to Serial hardware similar to this one.

Switching the board to UNO makes the problem go away

As a side note, switching to the Uno will make most ATtiny problems 'go away' since the Uno is much more equipped than ATtiny85/4, both on the MCU level and on the breakout board level, which you get with the Uno (and which you don't get when working directly with a chip like ATtiny). Also, most of the code base out there is targeting the Uno and not ATTiny.
So if you are doing your first steps with the ATtiny, be prepared that many things that 'just worked' with the Uno will require extra/different code before they could work with the ATtiny (and some won't work at all).
You can use my simple Analog to Serial code :
/*
Takes an input on the AtTiny85 from the VERY TRICKY analogue input pin 2 (as labeled in HLT tutorial)
 and outputs these with Software serial to the arduino uno, or Duemillanove
 Hookup
 ATTINY85 pin 3 -> Arduino Uno pin 0
 ATTINY85 pin 4 -> Arduino Uno pin 1

http://www.instructables.com/id/Easy-ATTiny-Serial-Communication-with-Tiny-AVR-Pro/
 */

#include <SoftwareSerial.h>
// Definitions
#define rxPin 4
#define txPin 3
SoftwareSerial mySerial(rxPin, txPin);
int sensorPin = 7; //ACTUALLY PIN LABELED AS "2" on the HLT tutorial
int sensorVal = -1;

// the setup routine runs once when you press reset:
void setup() {
  pinMode(sensorPin, INPUT);
  mySerial.begin(9600);
analogWrite(0,1); // This is kind a heart beat to show the ATTINY is "alive"
}

// the loop routine runs over and over asensorpingain forever:
void loop() {
  sensorVal = analogRead(sensorPin);
  mySerial.print("Input Val: ");
  mySerial.print(sensorVal);
  mySerial.println();
}

Below you can find the code for a minimal bit-bang send serial implementation ideally suited for debugging. Code size is about 60 bytes.
It gives 38400 baud for 1 MHz or 230400 baud on 8 MHz Attiny clock.
I wrote it for an Attiny 85.
ArminJo/AttinySendSerial_1Mhz_38400Bd

Yes, in IDE 1.6.x, libraries are defined "per board", they reside in special folders and are provided by the atuhor of the board-bundle.
Digispark's library is named SoftSerial and is included. In IDE Check File/Examples/DigisparkSoftSerial. Also check https://digistump.com/wiki/digispark/tutorials/debugging
In short, you have to include:
   #include <SoftSerial.h>
   #include <TinyPinChange.h>

and then define RX and TX pins (could be also the same in special cases):
   SoftSerial mySerial(SOFT_RX_PIN, SOFT_TX_PIN); // RX, TX

Then use mySerial.println() & co.

will it allow to use more than one serial?

I had the same problem and it appears that with Arduino IDE 1.6.x, libraries are defined "per board" and not shared any more.  At least, not all libraries are shared, and SoftwareSerial appears to be one of those.
So the solution is to copy the SoftwareSerial library from the Arduino installation at [programs]/Arduino/hardware/arduino/avr/libraries/SoftwareSerial to your ATTiny hardware folder at [documents]/Arduino/hardware/tiny/avr/libraries/SoftwareSerial, and restart the IDE, as per [this thread].1


text:
Program arduino via USB while using a Bluetooth module (HC-06)
I have my Arduino Nano connected to the HC-06 module (with the RX/TX pins).
My issue is that when I try to upload new code to my Arduino (via the Arduino IDE, through the USB connection) the Arduino IDE doesn't succeed.
I get this error:

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

I believe that it is just trying to upload the code to the HC-06 (instead of the Arduino). Is there a way to overcome this issue?.
Thanks.
Note: I found this entry https://stackoverflow.com/questions/27175937/arduino-program-upload-while-btooth-module-connected-avrdude-stk500-getsync indicating that it wasn't possible (that I need to unplug the module). I am trying to confirm it.

Your code might not work on leonardos/micros, but in any case they don't use pins 0 and 1 to upload so I believe you should be able to upload while the HC-06 is plugged in with either of those.

You might be able to electrically "remove" the blueooth module if it has a distinct reset line you can hold asserted, but unplugging it would be conceptually simplest.

The link in question was correct... you do need to unplug it.
The Arduino's serial chip uses pins 0 and 1 to communicate with the ATmega 328 PU chip onboard, thus you have two independent devices connected to the same wires and both the Arduino main chip and the Bluetooth module are trying to communicate at the same time (rendering all data unreadable by the computer).

source: Stack Exchange

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

sort: votes


text:
How to "implement" an Arduino prototype?
I am starting with Arduinos, coming from the world of Linux (with the RPi as a bridge) and after having tested some setups I now wonder where to go next in implementation.
What I am trying to understand is whether it is recommended (time and cost-wise)

to create a standalone, circuit-board based version of whatever I prototyped on the breadboard, with a micro-controller with connections trimmed down to what is needed for that specific setup?
or rather just look at neatly packaging the Arduiono with the breadboard and wires in a case?

I expect to build 5 or 6 of the same simple setups (to put in various places in my house).
Note: there is a similar question (with almost the same title) but it deals with the legal aspects of commercializing a setup.

You might be able to make it cheaper with a PCB, but I gather you've probably never done a PCB layout before? In that case you'd probably need to pay someone (likely much more expensive) or have a large learning curve and probably a few failed PCBs along the way. Either way it might be worth adding a few more details on how complex it is (or even better a circuit), there might be a few proto board techniques that are somewhere in between.

A lot depends on how complex your breadboarded circuit is. The natural permanent version of a breadboard is stripboard/Veroboard; if you don't need "shield" compatibility then Arduino Nano and its clones are probably a good choice.

If you can wait ~10 days, 3 boards from someone like OSH park might cost you $20 or so, depending on how big you make them.

Unfortunately, this is yet another improper migration from EESE.  The question is about electronics fabrication, and so belongs there where it was quite correctly asked.  It has been dumped here, where it is cut off from relevant expertise, purely due to bias against anything which tangentially mentions arduino, despite the fact that it is not in any meaningful way an Arduino question.

@ChrisStratton 1. Fear not :-). 2. Arduino's look fine to me when used appropriately. and there seem to be many places where they are appropriate but not used. - I'm just finishing a one off "Bubble Tube" controller for a school to replace an old expensive obsolete one that disintegrated (and program code for IC used not available). No prizes for guessing what the controller is based on.

with the breadboard

That phrase right there makes the solution a non-starter. Solderless breadboards are good for prototyping, but are too fragile for use in a final project.
As for whether or not you should use an actual Arduino or reduce the circuit to a minimum, that is between you and your wallet. It is possible to make a basic AVR board (including MCU) for under $6 in parts, but the time investment is not entirely trivial.

I started using an Arduino (Uno), and a solderless breadboard, to do my prototyping.
After the 2nd project, I started programming the Arduino, then pulling the AtMega chip off the board (if you have a through-hole chip rather than a surface mount one) and plugging that into my breadboard (you will need some supporting circuitry for this - a clock and a powersupply e.g. batteries). The AtMega has a larger range of voltages than the Arduino, and can be run up to 20mhz. You will need to jiggle some constants for this, or be ready for your delays to run quicker too.
I have since bought an USBISP (see Google), which can be hooked up to the Arduino board (there is a 6 pin header made for this, on the opposite side to the USB), or can be hooked up to specific pins. With this, I have started programming AtTiny chips - smaller, easier to set up, fewer pins to interface with, and really, really cheap!
All my long-term projects are on veroboard (see Google) - solder everything on, then cut it to the size you need. It's worth spending time before you solder working out your layout.
If you want to produce these in bulk, I would suggest getting some prototypes on veroboard first (you will, invariably, make changes once you start testing!), then when you're happy, you can copy the veroboard design (possibly tweaking it to optimize for greater flexibility), and order PCBs from a company that does this sort of thing.
Good luck!

What I am trying to understand is whether it is recommended (time and cost-wise) to create a standalone, circuit-board based version of whatever I prototyped on the breadboard, with a micro-controller with connections trimmed down to what is needed for that specific setup? or rather just look at neatly packaging the Arduiono with the breadboard and wires in a case?

Given what is available in assembled form, using a complete commercial product per project would make most sense except where you are building in substantial volume.
Because ...
I am using Arduino Nano 3s from China which cost me $US3 each in quantities of 10 with free postage (takes 2 to 3 weeks to arrive here at the bottom of the world) and I see that the same people are now charging $2.85 each in 10's. There are numerous suppliers of similar products and I am only mentioning these as I have had good results from them and the quality is acceptable.
You would probably have trouble buying just the parts for the cost of a $3 assembled working Nano and you'd need to cost your time at $0/hour. Building your own for the experience, or if you are using many and you want a cut down subset and really must get the price well under $3 MAY make sense.
The same people also sell an Arduino Pro mini for $US1.85 in 10s free postage (ie $18.50 for TEN). You need to use a plug in USB module to program these via USB. I bought some of these as well - also good, but the convenience of the always available USB makes the Nano preferable (to me).
Note: USB cables cost extra !!! :-)

Related:
Some people have expressed reservations about buying Asian source Arduinos and suggest people should support either US fronted companies or the Arduino's originators.
I appreciate the merit of supporting the people who have put the effort into the system, but the system is very very consciously open source in all respects - and in fact code samples that come with the IDE are expressly Public Domain. (Documentation is CC by SA ...). If open source is to be truly meaningful it needs to be able to survive being truly so. Unlike many other products where Asian copies may have suspect IP legacies, the Arduino products are wholly legitimate (as far as I know).
I have not pored over them in detail (yet) but I note that the 5V voltage regulator on the Chinese ones is an LM1117 (LDO LM317-like) as opposed to the original LM2940. The USB bridge ICs are, as is well known, not "genuine" FTDI parts but Asian semi-equivalents which, with their own drivers, work well enough in this context.
You can certainly buy low cost rubbish versions from Asian sources, and part of the open source tradeoff is deciding where you do and don't get value for money overall.

"The same people also sell an Arduino Pro mini for $US1.85" I think you meant $18.5

@Marla - No & yes. They are $US1.85 each or $18.50 for 10 with free postage. The link is to a batch of 10.

I too have a box of Chinese Arduinos - they all work, perfectly, and are indeed cheap as, well, chips! I have some Italian ones too, I've lost track of which are which.

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


text:
Arduino software won't open in Mac OSX 10.10.1
I am having trouble opening the Arduino software on my mac, since I have updated Java to version 8 the Arduino software won't open. It does not give an error just closes instantly.
I have tried getting the newest version of the Arduino.cc site but no change.
Can anyone tell me how to open Arduino using an older version of Java?

Perhaps this should go on the Arduino Stack Exchange?

There are two versions available. One for java 6 and one for java 7. Did you try both?

Download and install the Apple version of Java (6): http://support.apple.com/kb/DL1572
If you need Java 8 SDK for some reason, the two can coexist because the Arduino IDE will explicitly ask for the (Apple Version) of Java 1.6 using 'JavaApplicationStub':
$ ./JavaApplicationStub
[JavaAppLauncher] Requested [1.5*], launching in [1.6] instead.
Experimental:  JNI_OnLoad called.
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7

Note however that if you have both Apple Java and Oracle installed, running 'java' or 'javac' form the command line will run the Oracle version.
$ java -version
java version "1.8.0_25"

If you need to switch the 'command line' version, change the symlinks in:
/System/Library/Frameworks/JavaVM.framework/Versions/

'JavaApplicationStub' will use the Apple version located in /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java.
As such, 'normal' java programs will generally use the Oracle version, while applications running in your browser or using JavaApplicationStub explicitly (like Arduino) will use the 'Apple' version.

Yeah that works sweet did have to open terminal to the Contents/MacOS of the Arduino app before JavaApplicationStub worked cheers

I just clicked on the apple icon => about this Mac => software update => Mac Sierra update.
now to get the USB port to work
numbatmark

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


text:
How to print a line with a variable in it?
I want to know if there is a way to write like in C programming:
  printf("the num is %d",num);

I know that to print a line or a variable the command will be Serial.println
when I write:
 Serial.println("the num is %d",num);

It's not working.
Is there a way to write it in just one line?

Serial.print("the num is "); Serial.println(num);

is how you do it with the Serial object. There is a printf in the library and it's a lot easier to use (as you already know) but a little bit more work to set up. Here is a simple program using printf:
// Define a file descriptor for the serial output:
static FILE uartout = { 0 };

// Declare our put-character function:
static int uart_putchar (char c, FILE *stream);

void setup() {
   // Fill in UART file descriptor with pointer to my char-out func.
   fdev_setup_stream(&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);
   stdout = &uartout;

   Serial.begin(9600);   // open serial port, sets baud rate
}

void loop( void ){
   printf("Run time: %ld\n", millis());
   delay(1000);          // wait 1 sec
}

// My char output function
static int uart_putchar (char c, FILE *stream)
{
   if( c == '\n' )
      Serial.write('\r');
   Serial.write(c) ;
   return 0 ;
}

That's a nasty way to print a single text line.

For just one line? Of course it is!

right; for some reason I really didn't consider it could be useful when called many times

I use:
Serial.println("The temperature is " + String(temperature) + " degrees C");

With this solution you can't format the variable's value but I find this quick and dirty for debug messages.

I use it too and i think it's the easiest way.

You can try "extending" the Print class to include a printf() function.  It requires modification of the Arduino core to add it, and it's something I have been meaning to suggest to the Arduino guys as a permanent modification, but I often manually add a function such as this:
void Print::printf(const char *fmt, ...) {
    va_list va;
    va_start(va, fmt);
    char temp[1];
    uint32_t slen = vsnprintf(temp, 1, fmt, va);
    va_end(va);
    char out[slen + 2];
    va_start(va, fmt);
    vsnprintf(out, slen+1, fmt, va);
    va_end(va);
    print(out);
}

to my core.
It's not wonderfully efficient from a processing point of view - it first runs a vsnprintf() to a single byte target.  This allows it to work out how long the formatted string will need to be:

If the output was truncated due to this limit, then the return value is the number of characters (excluding the terminating null byte) which would have been written to the final string if enough space had been available.

So it then knows how much memory is needed to store the formatted string.  It then goes ahead and allocates that much memory on the stack and re-formats the string again into that newly allocated memory.  It can then go ahead and send that data to the serial port.
It's a "quick and dirty" hack, but it works.  A better solution would be to re-write the printf() parser in the function and instead of formatting to memory then printing, to format the data stream directly to the Serial device, thus saving the double-processing and memory allocation.
You can then quite happily do things like:
Serial.printf("The temperature is %d degrees C\n", temperature);


text:
What's wrong with my ESP8266?
After trying to upgrade firmware of ESP8266, it failed. I am not finding any response from it. It's just blinking a red LED.
What will I do now?

I had tried to upgrade the firmwire in different ways...but couldn't.The result is that i am not finding any wifi signal response in the network connection ...What's now?

The upgrade firmware on the ESP8266 is hardcoded. Attempting to reflash it with known good firmware should restore functionality.

Make sure you have the correct firmware depending on the version of the board you have, the family seems quite big:
esp8266 wiki
There's nothing stopping you from experimenting and flashing different versions until you find the one that works.

Make sure that GPIO0 is not shorted to ground. Otherwise, try to reflash the firmware and when finished, leave GPIO0 floating to get out of firmware upgrading mode.


text:
Arduno Uno voltage in via VIN pin or DC power?
I have an Arduino UNO. It has VoltageIN on a pin. Is there any difference between powering my UNO through VIN or powering it through the DC port?
The docs only say this,

5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.

So it seems to imply VIN/USB/DC in all go through the voltage regulator? Is there any difference then?
Is there any advantage to running a variable power supply through an adapter like this:

Or should I just go through VIN?

DC Jack has a Reverse Protection Diode, that drops 0.7V at usable currents. The VIN does not. Both go through the on board LM7805 or similar linear regulator. The USB does not, but it does go through a P-Channel Mosfet used to switch between USB and DC/VIN power before connecting to the 5V rail. The 5V pin bypasses the regulator, Diode, and P-Channel Mosfet completely.
The advantage of the DC jack is that the Reverse Protection Diode is used, preventing reverse voltage problems if you wire it wrong.

It's odd/cheap that they didn't put a MOSFET-based reverse polarity solution. I guess they had to cut corners somewhere to meet the target price.

If you have a "variable power supply" just set it to 5.00v and connect to the 5v pins.  Eg like the this http://blog.unixbigot.id.au/2015/10/make-5-volt-battery-supply-for-any.html?m=1

The post you linked to seems to be talking about batteries and a voltage regulator, rather than connecting a variable power supply.

@NickGammon yes, but it's the same connection point.


text:
Installing a different firmware on Arduino
Is it possible to upgrade the firmware on an Arduino so that it can do more things such as change undervolting/ overvolting in order to provide more processing power. To do this you would have to most likely re flash the chip itself, so how would that be accomplished?

Most new functionality is provided by libraries and programming. What kind of "more things" are you talking about?

What TheDoctor said, what you mean by more things? Also, what are you referring to by "firmware"? The software/OS's onboard?

Should I just delete the question

@JVarhol If you can make it clearer, nah, keep it. Just explain to us what exactly you're thinking of...

I know you can install new firmware on the USB-serial chip so it can emulate a keyboard

Interesting to know

You can both over-volt and over-clock the ATmega328. With no active cooling, they will nearly all run at 6V and 30MHz. You can push the voltage further - 8V is possible sometimes, and you can get a few extra MHz out of them.
The point of this? Nothing. If you need more power, get a more powerful processor or stop using Arduino libs.

To answer the aspect of your question regarding the "firmware" on the ATmega328p MCU used in most of the Arduino boards:
There is no firmware on the ATmega at all aside from the bootloader. The programs you write are running directly on the hardware.
There are certain "fuse" settings which are set with a ISP programmer. However, there are only 24 of them (three bytes), and they largely relate to low-level configuration, and are not what I think you're asking:

There is also the Bootloader, which is a small program that sits in a separate segment of the MCU's program memory and allows it to update itself at startup (which is how all arduinos are programmed). However, it only runs for a short period of time at startup, and is completely removed from memory after the MCU has jumped to the main program.
Lastly, there are auxiliary MCUs (ATmega16U2/8U2) on most arduino boards that are used as USB-serial interfaces, that can be updated to behave differently (e.g. emulate a keyboard/mouse), but again, this isn't actually a change to the core processor, so whether it counts as "installing a different firmware" depends on how you define the arduino.
Really, I'd strongly reccomend reading the ATmega328P datasheet. This is the documentation for the MCU that basically forms the "Arduino". It should address what seems to be misconceptions.

Note the below chart, in regard to your under/over volting the device for different F_CPU, indicates the relationship. As a result you find most Arduino's run at 5V and a clock rate of 16MHz. While there are some 3.3V variants that run at 8MHz.

However, the core library provided with the IDE typically has specific #if's for both 8 and 16 MHz F_CPU speeds, not using a formula in most places.
Hence it is possible to do what you ask. However, you will find the core library limitations affecting. Tipping the cost vs benefit ratio, to that of the very intent. And then likely one would leave the Stock IDE and core libraries to a more makefile method.

Apparently it can be overclocked to 20 mHz

@TheDoctor - that's not overclocking. The ATmega328p is rated to 20 Mhz. Arduinos are actually underclocked to 16 Mhz.

@FakeName yes, I meant that you can modify an Arduino board to have the nessecary resonator to tun at 20 mHz

Oh, another side-note. You can generally exceed the safe-operating-area without major issues. I have a number of boards running 16 Mhz with 3.3V rails without issues. They may have stability issues at extreme temperatures, but it seems to work mostly fine at room-temperature.


text:
Is there a way to have more than 14 Output pins on arduino?
Is it possible to have more than 14 output pins on the Arduino, I am working on a project in which I need to light up several LEDs individually. I only have an Arduino Uno, and I don't want to get a Mega.

In the spirit of expandability, is I2C even an option with Arduino?

@ChrisO What do you mean by I2C? Because from what I understand Shift registers would be considered I2C.

Oh make me answer my question then ;-)  Here's a wikipedia article on this bus standard.  And I just found some support from Wire lib for I2C, so you could connect an I2C chain to your Uno.

@JVarhol Not quite. I2C, aka TWI is a a 2-wire interface while SPI may be considered a 3-wire interface.

Ahh, Makes sense now THX

@JVarhol have you selected a solution for your project already? If yes, it would be useful to edit your question and accept the answer that matches (or is the nearest) your solution.

A common way to expand the set of available output pins on the Arduino is to use shift registers like the 74HC595 IC (link to datasheet).
You need 3 pins to control these chips:

Clock
Latch
Data

In a program, you pass on the data one bit at a time to the shift register using the shiftOut() command, like so:
shiftOut(dataPin, clockPin, data);

With that command, you set each of the 8 outputs on the 595 IC with the 8 bits in the data variable.
With one 595, you gain 5 pins (8 on the IC, but you spend 3 to talk to it). To get more outputs, you can daisy-chain a series of 595 together, by connecting its serial-out pin, to the data pin of the next one. You also must connect together the clock and latch pins of all of the 595 ICs.
The resulting circuit (using one 595) would look like this:

The figure above was taken from this codeproject.com webpage:

Arduino Platform - Working with Shift Registers

The latch pin is used to keep the 595 outputs steady while you are shifting out data into it, like so:
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, data);
digitalWrite(latchPin, HIGH);

Thx, forgot to include how a shift register works. I had planned to, but I had to walk away from my comp and when I came back it had slipped my mind. :)

No problem, that's why we are a community. We complement each other's answers. But it's nice that you've added a few good tips in your answer, too, specially about the EZ-Expander shield. It allows those who cannot easily make their PCBs to expand the number of ports available to them.

Also it makes the programming easy, you do not have to shift the data in and Pulse the clock and then activate the Latch. I have known about the shield for quite awhile and I think it is perfect for beginners. Best thing is, is that because the code is opensource you can use the code even if you are not using the actually shield but have your own board, or are using a breadboard.

Don't forget that you can link them in line (theoretically) indefinitely, so 2 8-bit registers can become one 16-bit.

Thanks! Here is an archive link to the amazing codeproject description in case the link ever goes down https://archive.fo/1uvPE

There are two ways you can get more pins out of an arduino.
The first way is by using the Analog pins as digital output pins, which is really easy to do. All you need to do is refer to A0-A5 as pins 14,15,16,17,18,19. For example to write high to pin A0 just use digitalWrite(14, HIGH).
The other way to get more pins out of the Arduino is by using a Shift Register. To do this I recommend using the EZ-Expander Shield, which allows you to use digitalWrite([20-35], HIGH) when you import the EZ-Expander Library. This shield however only allows the pins to be used as outputs only and uses pins 8,12 and 13 to control the shift registers.
The great thing is, is that you can use both of the two methods above together, without any problems.

According to the Arduino reference, you can actually use the A0-A5 identifiers directly instead of using numbers 14-19. For example, digitalWrite(A0, HIGH).

@PeterR.Bloomfield Both are correct, however I recommend A0-A5 for simplicity and easy of reading. Not a big deal with a LED blinking but when you have large projects little habits add up.

Actually, whilst both will get the job done on UNO and compatible boards, digitalWrite(A0) is more correct than digitalWrite(14) since the former will always map to the correct physical (analog) pin. On a different board, pin 14 may in fact not be A0, eg pin 14 on the MEGA is Serial3 TX and will not influence the analog pin that you're after. ie, if using digitalWrite on an analog pin, use the A0-A5 reference.

I2C (Wire)
You can use the I2C protocol (Wire library) to connect to other devices such as port-expanders. For example, the MCP23017.
I used one of those chips to connect to an LCD board. The MCP23017 has 16 ports, which can be configured as inputs or outputs. As inputs they can raise interrupts if desired.
Example of connecting 13 of those 16 to the LCD:

Now we connect to the Arduino using only 2 wires (SDA/SCL) plus power and ground:

Some third-party manufacturers have made boards with 4 x MCP23017 on them, this gives you 64 inputs/outputs:

Multiplexers
You can use analog multiplexers like the 74HC4051 (8 ports) or the 74HC4067 (16 ports) to connect one pin to one of the 8/16 ports (but only one at a given time), like this:

These are bi-directional, so can be used as an input or output expander.

SPI with 74HC595
Using SPI you can send fast serial data to a shift register, such as the 74HC595. These can be daisy chained together. In this example I am controlling 32 LEDs with only 3 I/O pins (MOSI/MISO/SCK) plus power and ground.

I found inside a commercial LED sign that the 72 LEDs were driven by 74HC595 chips.

This had 9 chips driving the columns (9 x 8 = 72 LEDs) and one chip driving the rows, in a multiplexed configuration.

SPI with MAX7219
If you just want to drive LEDs you can usually multiplex them. The MAX7219 simplifies that by being designed to drive LED matrixes, for example 7-segment displays:

Or 64-LED matrixes:

In both cases these can be daisy-chained together, for example:

All those examples only use 3 pins of the Arduino (MOSI/MISO/SCK) plus power and ground.

SPI with MCP23S17
The 16-port port expander mentioned earlier (MCP23017) also comes in an SPI variant (MCP23S17), which does virtually identical things. It uses one more wire, but would be faster.

Other protocols
LED strips (like the NeoPixel ones) have their own protocols. There was a post on Youtube by Josh Levine where the author drove over 1000 pixels with a Duemilanove!

References

I2C and MCP23017
MCP23017 and graphical LCD
74HC4051 multiplexer / demultiplexer
SPI
Hacking a scrolling LED strip
Using a 74HC595 output shift register as a port-expander
Interfacing LED displays with the MAX7219 driver

You put a lot of work into this answer! Good job!

If you want to drive LEDs, then you can also use a MAX7219 that can drive 64 LEDs, without extra circuitry (no need for transistor to amplify signal).
Driving a MAX7219 requires only 3 output pins on Arduino.
Also, you can find a few Arduino libraries for it.
You can also chain several of them if you need to power more than 64 LEDs.
I have used it successfully for multiple 7-segment LED displays.
Downside: it is expensive (about $10).

I did forget about the MAX7219, Thanks for posting!

384 LEDs... whoah! Plus two pins for USB inference. Wonder what kind of annoying trinket you can create (with a sufficient power supply).

You can use Charlieplexing. With this technique you can directly drive n*(n-1) LED's from n pins. So with 3 pins you can drive 6 LED's, 4 pins - 12 LED's, 5 pins - 20 LED's and so on.
Exemple:
Six LED's on 3 Pins
PINS        LEDS
0 1 2   1 2 3 4 5 6
0 0 0   0 0 0 0 0 0
0 1 Z   1 0 0 0 0 0
1 0 Z   0 1 0 0 0 0
Z 0 1   0 0 1 0 0 0
Z 1 0   0 0 0 1 0 0
0 Z 1   0 0 0 0 1 0
1 Z 0   0 0 0 0 0 1
0 0 1   0 0 1 0 1 0
0 1 0   1 0 0 1 0 0
0 1 1   1 0 0 0 1 0
1 0 0   0 1 0 0 0 1
1 0 1   0 1 1 0 0 0
1 1 0   0 0 0 1 0 1
1 1 1   0 0 0 0 0 0

You can see a better tutorial here.

One thing to note is that this technique allows you to control more leds, but not simultaneously necessarily.

@kontur yes, you're right. But in terms of persistence of vision you can consider that they are. The question doesn't have such details.

Charlieplexing is not the ONLY way to multiplex LEDs without using shift registers.

@linhartr22 I've NEVER said that is the only way. Charlieplexing is just a common solution for this problem. And my answer was the 7th one. So other possibilities had already showed before.

@DanielGrillo I should have been more specific and explained how column and row multiplexing, which is typically used on LED cubes, can be done without shift register and without the limitations of Charlieplexing. A 4x4 row column matrix can individually control 16 leds with 8 I/O lines. A 4x4x4 cube can individually control 64 leds with 12 I/O lines (possible even on an Uno by using Analog A0-A5 as digital lines).

Shift registers have been mentioned in other answers, and they are definitely an excellent choice for many projects. They are cheap, simple, moderately fast, and can typically be chained together to add more outputs. However, they have the downside that they usually need exclusive use of several pins (between 2 and 4, depending on how you set them up).
An alternative is to use more advanced port expanders, such as the 16-bit MCP23017 and MCP23S17. These support I2C and SPI respectively, which means you can place them on a bus with several other devices (potentially of different types). Each device on the bus can be individually addressed, meaning you only need 2 or 3 pins to talk to all of them. The update speeds are typically extremely fast, so you're unlikely to experience significant latency (i.e. transmission delays) in an Arduino project.
At a low level, using I2C or SPI is substantially more complicated than a simple shift register. However, there is library code for Arduino to take care of that for you. See this question, for example: How do I use I2C devices with Arduino?

Wow, i never knew about those, thx, ill look into them!

Can you use I2C to control LEDs?

@ProQ You can't control standard LEDs directly using I2C. However, it is possible to get some LED products which have a built-in I2C driver. This is usually for products with lots of LEDs, such as strips or matrices.

In addition to Ricardo's answer, what Wikipedia states on shift registers:

One of the most common uses of a shift register is to convert between serial and parallel interfaces. [...] SIPO registers are commonly attached to the output of microprocessors when more General Purpose Input/Output pins are required than are available. This allows several binary devices to be controlled using only two or three pins, but slower than parallel I/O.

In the article Ricardo linked you can see the diagram of the shift register.

What happens here is that you put the data of the 8 pins in a sequence and for each clock tick the shift register will shift (move the binary data from each latch to the next one) until it "makes a circle" i.e. the first bit arrives to the last pin. Shift registers also have an input where you can turn on/off the shifting so the status can be kept after the data is shifted to the position. For a simple demonstration see the following animation.

Here the red light is the serial input and the green ones are showing the state of the latches in this simplified SIPO shift register. After the data shifted to place shifting can be turned off and you can read the pins. In this example I shifted out 10101011.
From these examples you can realize that serial transfer will be slower than parallel, because you have to wait for the shift register to shift the bits to their place. You will have to wait the same amount of clock tick as many bits you want to load. This is one of the many reasons why you can't chain them indefinitely, because loading would take forever.

+1 for the additional information AND for the pretty animated GIF and its didatic effect! Where did you find the GIF? Or did you make it?

@Ricardo I created the circuit with Digital Works, then print screen, edit, gif animator.

As you wrote already already, you can use all pins, including TX and RX as digital output. I did that a while ago for a demonstrator and recorded a video - 20 LEDS on 20 pins - of this rather nonsensical project.
As described by Peter R. Bloomfield here, you a have to disconnect TX and RX for upload. Moreover, you're out of pins to read sensors for possible interactivity and have to make sure that the total current limit isn't reached. Not to forget that you're limited to 5V leds if you drive them directly with your Arduino.
The use of shift registers in general and the 595, described by Ricardo is therefore highly recommended.

They are cheap!
It's rather easy to cascade them.
A lot of speed can be gained when you use hardware-SPI.

I used them a while ago when I realized the soldering and programming part of Kawaii me (text of the link is in German) of the upcycling artist Dominik Jais.
Here, just a bunch of 595 were used to drive a display of 8x11 leds. Since the leds were cut from a stripe of 12V SMD leds, an additional power supply and some UDN2803A Darlington arrays, hooked to the output pins of the shift registers, were necessary.
Other general methods would include the use of PCF8574(A) 8bit port expanders, which are controlled via the I2C bus.
Anyway, I'd give the 595 shift registers a try first.
If you need to control a couple of RGB leds, however, you might want to look for more specialized solutions. Some RGB leds come with their own WS2812. These fine pieces can be cascaded (1-Wire bus) and are addressed via their position in the chain.

I do not claim this method for my own, but I found this neat trick on the webpage MUX-DEMUX: CD4051 Parlor Tricks
Whatever method you choose to use to drive outputs or read inputs (shift registers, multiplexors or the straightforward direct use of the Arduino pins themselves) you can DOUBLE the number of outputs or inputs by a clever use of parallel circuit pairs (to form a dual input or output bank), employing diodes in opposing senses on each parallel branch, and switching the inputs/outputs to high and low.
To illustrate the method for outputs (LEDs in this case, note that the extra diodes are not required):

If you consider the pair of LEDs in this example to be a "bank", and
  you want to light LED_0, you need to set PIN 17 to HIGH, and PIN 18 to
  LOW. (The pin numbers are confusing, but they match the later example
  so bare with me). To light LED_1, you just reverse the PINS. The diode
  nature of LEDs keeps the current from flowing the opposite direction
  keeping the other one off.

To illustrate the method for inputs (CdSs in this case, note that the extra diodes are required):

This gets a little more complicated if you want to do an analog read
  on a CdS light sensor. First, you need to add a diode to each sensor
  to control the flow. Second, since you are reading values, you need to
  pull the inputs high or low to keep them from floating. Being a lazy
  person, I'm going to pull them high using the internal pull-up
  resistors. To read CdS_0, you set PIN 17 mode to OUTPUT and set it to
  LOW. This makes it the ground. Then you set PIN 18 mode to INPUT and
  set it to HIGH to engage the pull-up resistor. Now you are set to do a
  read on PIN 18 (a.k.a. analog pin 4). To access the other sensor, just
  switch the modes and outputs.

So, if you have a CD4051 8 port multiplexor, using 5 pins on the Arduino (instead of the usual 3), you can obtain 16 inputs or outputs, or a mix of the two.

Likewise, if you have a 4067 16 port multiplexor you can obtain 32 inputs or outputs, or a mix of the two.
An example sketch would be:
/*
 * Example of getting 16 i/o from 5 pins using a CD4051
 *
 * Based on tutorial and code by david c. and tomek n.* for k3 / malmö högskola
 * http://www.arduino.cc/playground/Learning/4051?action=sourceblock&ref=1
 */

int selPin[] = { 14, 15, 16 }; // select pins on 4051 (analog A0, A1, A2)
int commonPin[] = { 17, 18};   // common in/out pins (analog A3, A4)
int led[] = {LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW };  // stores eight LED states
int CdSVal[] = { 0, 0, 0, 0 }; // store last CdS readings
int cnt = 0;  // main loop counter
int persistDelay = 100; // LED ontime in microseconds

void setup(){
  Serial.begin(9600);  // serial comms for troubleshooting (always)
  for(int pin = 0; pin < 3; pin++){ // setup select pins
    pinMode(selPin[pin], OUTPUT);
  }
}

void loop(){
  flashLEDs();
  if (cnt == 0){
    for(int x; x < 8; x++){
      led[x] = random(2);
    }
  }
  cnt++;
  if (cnt > 100) { cnt = 0; }
}

void flashLEDs() {
  for(int pin = 0; pin < 2; pin++) {  // set common pins low
    pinMode(commonPin[pin], OUTPUT);
    digitalWrite(commonPin[pin], LOW);
  }
  for (int bank = 0; bank < 4; bank++) {
    for(int pin = 0; pin < 3; pin++) { // parse out select pin bits
      int signal = (bank >> pin) & 1;  // shift  & bitwise compare
      digitalWrite(selPin[pin], signal);
    }
    if (led[bank * 2]){        // first LED
      digitalWrite(commonPin[0], HIGH);  // turn common on
      delayMicroseconds(persistDelay);   // leave led lit
      digitalWrite(commonPin[0], LOW);   // turn common off
    }
    if (led[bank * 2 + 1]){     // repeat for second LED
      digitalWrite(commonPin[1], HIGH);
      delayMicroseconds(persistDelay);
      digitalWrite(commonPin[1], LOW);
    }
  }
}

Like I said in the first line, the full explanation can be found on MUX-DEMUX: CD4051 Parlor Tricks

If it's all about LEDs, what about WS2812B LED strips, or just the driver chips themselves? You can control a virtually unlimited number of LEDs using just one pin!
Although people are use to these in strips, they are available as standalone LEDs (known as neo pixels on Adafruit). Or if you're only driving a single colour, each WS2811 chip could control 3 LEDs by using each of the RGB outputs for a single LED each.
I recently just created created a project that uses 5 such LEDs: Door1 open/closed, Door2 open/closed, motor1 active, motor2 active and power. The "active" LEDs are dual purpose since I have red being the input from active motor and green being active flag inside the Arduino.
Point being, with 1 pin and the library installed, you can control any number of LEDs

For a class project I used a CD4024 and two Arduino pins to drive a 7-segment display.
There are some caveats to this approach. For example, to write a high value to the first output of a ripple counter only requires a reset and toggling the clock pin twice. But if you want to write high to all n pins requires toggling the clock pin 2n times, and during that time all the other pins are constantly toggling on and off.
If your application can deal with these limitations and you're short on pins, it's another option.
Bonus answer: there are a lot of examples of multiplexing inputs here, many of which also apply to multiplexing outputs.

Using a 7-stage counter to drive a 7-segments display seems a suboptimal approach, for the reasons you've yourself indicated.

With a bit of work (installing a different bootloader) an additional seven I/O lines are available on an Uno, on the ICSP1 and JP2 headers.  The replacement bootloader is called HoodLoader2.  It allows you to install sketches on both the Atmega328 and Atmega16U2 on an Uno.  Dealing with multiple processors would be the main complication from using this method.
On an Uno, the ICSP1 and JP2 headers connect to pins PB1...PB7 of the Atmega16U2.  In addition the Atmega16U2 has about 9 I/O pins with no connection to the circuit board.  A person working under a microscope might be able to attach wires to a total of 18 I/O pins on the 16U2, while leaving three other I/O pins attached to their ordinary connections.
HoodLoader2 also works on Mega boards.

There is a wealth of good answers here, but if you costed your time you'd find it cheaper to buy a Mega.
My 3/2-d worth.


text:
RF missing characters
I've got two arduino nano devices connected via RF 433 MHz. The modules are MX-05V and MX-FS-03V. I'm using VirtualWire for sending and receiving. The speed is set to 1000 bps.
One has got a pir sensor and sends "1:ON" when it detects movement and "1:OFF" when movement stops.
The other is just receiving these messages, but after a while (20 messages) the text is chopped off. I only receive "1". If I restart everything the same thing happens.
They are currently on my table (cca 20cm distance) and powered by my PC via USB.
What can I do? Is it because the modules are from ebay and probably not the best quality?
Receive part:
// recieve

int ledPin = 13;
int rcvPin = 13;

#include <VirtualWire.h>
byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message

void setup() {
  Serial.begin(9600);
  Serial.println("Device is ready");

  // Initialize the IO and ISR
  vw_set_rx_pin(rcvPin); // set pin for rx
  vw_setup(1000); // Bits per sec
  vw_rx_start(); // Start the receiver

  digitalWrite(ledPin,HIGH);
}

void loop() {
  // non-blocking receive
  if (vw_get_message(message, &messageLength)) {
    Serial.print("Received: ");
    for (int i = 0; i < messageLength; i++)  {
      Serial.write(message[i]);
    }
    Serial.println();
    digitalWrite(ledPin, LOW);
    delay(500);
    digitalWrite(ledPin,HIGH);

  }
}

Transmit part:
/*
SimpleSend
This sketch transmits a short text message using the VirtualWire library
connect the Transmitter data pin to Arduino pin 12
pin 11 to high for power
gnd connected to gnd
*/

// RF
int ledPin = 13;
int trxPin = 12;
int pwrPin = 11;

// PIR
int inpPin = 2;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status

#include <VirtualWire.h>

void setup()
{
  Serial.begin(9600);
  Serial.println("Starting...");

  // PIR
  pinMode(inpPin, INPUT);     // declare sensor as input
  // RF
  pinMode(pwrPin, OUTPUT);   // Set digital pin 11 as OUTPUT pins
  digitalWrite(pwrPin,HIGH);

  // Initialize the IO and ISR
  vw_set_tx_pin(trxPin);
  vw_setup(1000); // Bits per sec

  Serial.println("Device is ready to send.");
}

void loop() {

  val = digitalRead(inpPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion on seonsor 1!");
      send("1:ON");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
    digitalWrite(ledPin, LOW); // turn LED OFF
    if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended on seonsor 1");
      send("1:OFF");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }

}

void send (char *message)
{
  vw_send((uint8_t *)message, strlen(message));
  vw_wait_tx(); // Wait until the whole message is gone
}

In your first sketch, you have
int ledPin = 13;
int rcvPin = 13;

Did you mean both those to be assigned to the hardware LED on the Nano? (Pin 13 is the on-board LED). If so, why? With all the pins available to you.
The other thing I don't understand is your use of:
byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message

It will always just be one byte, won't it?
Why not use available()?
http://arduino.cc/en/Serial/available
I see this was posted six months ago - no doubt you have already solved it.


text:
Running an LCD keypad shield from a separate power source
I need to use a motor shield and an LCD keypad shield simultaneously hooked up to a single Arduino Mega Board. Since I can't physically stack them, I decided to reroute all the pins used for the LCD keypad shield. When I reroute all pins except the two power pins, the LCD and keypad work fine. But when I disconnect those 2 pins and connect them to any other power source than the Arduino Mega, it fails. The screen becomes either blank / jumble of illegible characters / brief moments of expected output followed by the same jumble.
This behavior is really strange since the power pins don't carry any information, they are just power sources. The LCD keypad shield shouldn't be able to discriminate whether the power is coming from the Arduino Mega or not - but it does. I checked with a voltmeter that all power sources I tried are DC 5V.
At first I thought this is because the lcd.begin() function is called only once, so I rewrote my code to re-initialize the lcd at every iteration. This doesn't solve the problem.
Here is a picture of the setup that works. (rerouting all pins except the power.) Ignore the location of analog input cable, since it doesn't do anything in the current code.

And one that fails. The only difference from above is the power source.

And my code.
#include <LiquidCrystal.h>

// select the pins used on the LCD panel
LiquidCrystal lcd(28, 29, 24, 25, 26, 27);

void setup()
{
  lcd.begin(16, 2);
  lcd.print("Hello World!");
}

void loop()
{
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.print("Hello World!");
  delay(1000);
  lcd.setCursor(0, 0);
  lcd.print("Hello Again!");
  delay(1000);
}

Any suggestions?

You can use a different power source, but the two circuit need to have a common ground, since all electrical signals are relative to ground. So connect a wire from GND on the LCD to GND on your Arduino and everything should work as expected.

Those little 16x2 LCDs are quite prone to power fluctuations.  Even powered solely by an Arduino I've seen them run OK for a few minutes than turn to showing gibberish.  Ensure you have good power connections, bring your power in as close as possible.
Maybe a capacitor across the power input to the display might help.


text:
arduino beginner documentation help
I plan to buy these 2 products to begin to play with arduino to learn.

Board with LCD touch
Yun board expansion

I have a mega 2560 which i bought with a starter kit and i love to play with. I have not played with the shield yet. I understand some shields can be used together, some not. and some with modification on the board and in the code.
I can't find pins specification for the touch screen and the support on the website doesn't respond.
If some one can help me find specifications for the touch screen, or help me choose some shields that will allow me to use a USB host, wifi, and a touchscreen it will be nice.
Thanks all.

The link you posted describes a TFT LCD Touch screen unit with the SPFD5408 controller, referenced in this Instructable for use with the Mega. You might start there and migrate to the Yun once you get the screen working.


text:
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?

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

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

Those examples are computer generated. In reality the contrast is a bit less, and the outlines aren't as sharp. But it's still a very cool effect.

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.
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.


text:
Understanding how methods and pointers inside a function work
After this question i starteted going deep with the theory, and started studyng step-by-step with the "Beginning C, for Arduino "
Jack Purdum.
I finished to study the functions chapter, but i still have some doubts on the code, i hope this will be not a dumb question.

Why there is a Method "Print" not a Data Type inside the Function Argument List?

static void printImuData(Print &printer, int16_t Time0,
        int16_t AcX, int16_t AcY, int16_t AcZ,
        int16_t GyX, int16_t GyY, int16_t GyZ)
{
    printer.print(Time0); printer.print(",");
    printer.print(AcX);   printer.print(",");
    [...]
}

[...]

printImuData(dataFile, Time0, AcX, AcY, AcZ, GyX, GyY, GyZ);
if (Serial_plus_SD)
    printImuData(Serial, Time0, AcX, AcY, AcZ, GyX, GyY, GyZ);

I though the answer was "because you can pass data to a function by-value or by-reference" in fact the first input in the argument list is the left value (memory address) of a Method, but i am very confused.
Function arguments are used to pass data to the function that it may need to perform its task.
I tried to answer to the following questions to understand the code.
1. What task does this function perform?
The function will print some data on a Serial Monitor or SD Card
2. What data do i need to send to the function?
I need to send one Method through the left value of a pointer and 7 intergers.
I can't understand why a method.
3. What data do I get back from it?
Nothing because is a void, it will perform some task inside the function (print inside the object thas is pointed?) but nothing will return to the caller.
In the book  basic example is a function that returns the value 0 or 1 if is a Leap Year.
The function argument is an int and returns an int.
void loop()
{
    if (Serial.available() > 0) {
        int bufferCount;
        int year;
        char myData[MAXCHARS + 1]; // Save room for null
        bufferCount = ReadLine(myData);
        year = atoi(myData); // Convert to int
        Serial.print("Year: ");
        Serial.print(year);
        Serial.print(" is ");
        if (IsLeapYear(year) == 0) {
            Serial.print("not ");
        }
        Serial.println("a leap year");
}
}
/*****
Purpose: Determine if a given year is a leap year
Parameters:
int yr The year to test
Return value:
int 1 if the year is a leap year, 0 otherwise
*****/
    int IsLeapYear(int yr)
    {
    if (yr % 4 == 0 && yr % 100 != 0 || yr % 400 == 0) {
        return 1; // It is a leap year
    } else {
        return 0; // not a leap year
    }
}
/*****
Purpose: Read data from serial port until a newline character is read ('\n')
Parameters:
char str[] character array that will be treated as a null-terminated string
Return value:
int the number of characters read for the string
CAUTION: This method will sit here forever if no input is read from the serial port
and no newline character is entered.
****/
int ReadLine(char str[])
    {
        char c;
        int index = 0;
        while (true) {
        if (Serial.available() > 0) {
        index = Serial.readBytesUntil('\n', str, MAXCHARS);
        str[index] = '\0'; // null termination character
        break;
        }
    }
    return index;
}

Like in my the last question, I have a civil engineer background and i am a self-taught, so is my first time with coding :)
Thank you for your patience.

I need to send one Method through the left value of a pointer and 7 intergers. The first arguments is actually a pointer to an object.

The example seems to be more about inheritance (polymorphism). You can pass any object of a class derived from the Print class to this function. HardwareSerial (the class of the Serial object) derives from the Print class. (Actually it derives from Stream which derives from Print).

"There are no stupid questions, just stupid answers"

Why there is a Method "Print" not a Data Type inside the Function Argument List?

There is no "Method" Print in the argument list.  There is a reference (not a pointer which would be a * not a &) to an object called printer that is of type Print.  The code you have provided doesn't define Print but its a could guess that it is probably something to do with printing.  By supplying the printer argument you can print this data to anything that inherits from the Print base class, Serial is a good possibility, but you could write a class that derived from Print and wrote the data to an LED matrix, etc.
I can tell its not a Method, because you are calling the print method of printer, so it has to be either a class or structure.

The function will print some data on a Serial Monitor or SD Card

I can see why you thought that but you are being too specific, it prints to anything that derives from Print, Serial and dataFile derive from it, but they might not be the only things.

I need to send one Method through the left value of a pointer and 7 integers. I can't understand why a method.

An example might help:
class CGPrinter : public Print
{
  // Some code....
  virtual void print (const char* input) {// do something}
}

void loop()
{
  CGPrinter cgp;
  printImuData (Serial, 1,2,3,4,5,6,7);
  printImuData (cgp, 1,2,3,4,5,6,7);
}

Serial is an object, a variable, a specific instance of type of class that can print data.
CGPrinter is my new super sexy printing class that will read the characters that you 'print'.  To print the 7 integers to CG's printer class is exactly the same call as the one to write it to the Serial Monitor, because both classes derive from Print.

What data do I get back from it?

Yes, correct on both points.
Does it make more sense now?  If not, just say and I'll try and clarify it.

In the argument list ex int16_t Time0 i have 1st the data type and then the rval of my variable. In the case Print &printer  i have something in the 1st place (an object that belong to the Print class) and a reference in the 2nd(something that inform the compiler about the lval of my variable referenced), but is not a Method.  A Friend of mine from CS told me that Print was a method, so i belive he was wrong, this is one reason of my confusion.

But is still not clear for me :( Inside the function you can put both a class and an object (istance of a class) that belong to that class, why? Why not only one of the two?

I'm not clear what you mean.  If you mean in the case of printImuData() you can't pass a class into the function.  A class is a type name, so try doing what you are saying with a char or an int.  If you have the function void DoStuff (int& a) can you call DoStuff (n); if int n = 4;?  Yes or course you can, but can you pass in int does DoStuff(int); make sense?  Its the same with classes if you have void OtherFunc(CHole& a); and then call CHole n; OtherFunc(n); calling OtherFunc(CHole) wouldn't make sense.

The & turns the function parameter means the variable is "passed by reference".  This means it is not copied, the address is passed to the function and it works on that memory address rather than the actual value.  This means the parameter becomes an IN/OUT value, any modifications made inside the function are passed back to the caller.  For example: void add (int a) {++a;} int a = 0; a = add(a); // a = 0 against void add (int a) {++a;} int a = 0; a = add(a); // a = 1  Note that (const int& a) in not modifiable.

Thanks for your patience. I made an error studying your answer, mea culpa, my question about the class inside the function was nosense :(
In the last comment you wrote this void add (int a) {++a;} int a = 0; a = add(a); // a = 0 against void add (int a) {++a;} int a = 0; a = add(a); // a = 1 but is the same. Maybe, if i understood , you will write this void add (int a) {++a;} int a = 0; a = add(a); // a = 0 against void add (int& a) {++a;} int a = 0; a = add(a); // a = 1 ? Thanks a lot @Code Gorilla it is very useful for me and  I'm very grateful to you :)

So, if i undestood, Print is not a method rather a data type. cgp and Serial are two objects from two different classes. I can invoke the method .print(Time0) on the two objects because they are "printable" a sort of operation like the operation of "sum" that i can do with int data types? :) Thanks :)

If you can spot my mistakes and correct them then I think you have got it :)  Sorry about that, yes you corrected it right.  Yes you are "correct" about Print.  By "correct" I mean you understanding is good enough for a beginner, but someone may come along and expand your understand later in life.  Good luck


text:
GPS Logger Error
I have created a GPS logger code using DFRobot SIM808 library. The tcp code and getGPS codes are working fine. but when integrating the both the code, it failed to upload GPS data to thingspeak. It gets the IP connect to the server, but the get command is not working; and also the GPS data shown as a string. Can anyone please tell me where the problem is?
/*
### Connect TCP and send GET request.
1. This example is used to test DFRobot_SIM808 GPS/GPRS/GSM Shield's connect TCP and send GET request.
2. Open the SIM808_TCPConnection example or copy these code to your project
3. Download and dial the function switch to Arduino
4. Open serial helper
5. Waiting for a few minutes, until serial has sent "Connect mbed.org success"
6. Serial will send "Hello world!"

create on 2016/09/23, version: 1.0
by jason
*/
#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

#define PIN_TX    10
#define PIN_RX    11
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

//make sure that the baud rate of SIM900 is 9600!
//you can use the AT Command(AT+IPR=9600) to set it through SerialDebug

//DFRobot_SIM808 sim808(&Serial);

char buffer[512];

void setup(){
  mySerial.begin(2400);
  Serial.begin(2400);

  //******** Initialize sim808 module *************
  while(!sim808.init()) {
      delay(1000);
      Serial.print("Sim808 init error\r\n");
  }
  delay(3000);

  //*********** Attempt DHCP *******************
  while(!sim808.join(F("hutch3g"))) {
      Serial.println("Sim808 join network error");
      delay(2000);
  }

  //************ Successful DHCP ****************
  Serial.print("IP Address is ");
  Serial.println(sim808.getIPAddress());

  //************* Turn on the GPS power************
  if( sim808.attachGPS())
      Serial.println("Open the GPS power success");
  else
      Serial.println("Open the GPS power failure");
  delay(2000);
}

void loop(){
//  gps();
  delay(2000);
  tcp();
  delay(2000);
}

void tcp(){
    //*********** Establish a TCP connection ************
  if(!sim808.connect(TCP,"api.thingspeak.com", 80)) {
      Serial.println("Connect error");
  }else{
      Serial.println("Connect mbed.org success");
  }

  //*********** Send a GET request *****************
    float lati=sim808.GPSdata.lat;
    float longi=sim808.GPSdata.lon;

    char http_cmd[100];
    sprintf(http_cmd, "GET https://api.thingspeak.com/update?api_key=FF19NVWMPZEWX0XK&field2=%s&field3=%s HTTP/1.0\r\n\r\n\0", lati, longi);

    boolean retValue = true;
    sim808.send(http_cmd, strlen(http_cmd));
    int ret = sim808.recv(buffer, sizeof(buffer)-1);
    if (ret <= 0){
        Serial.println("error receiving");
        retValue = false;
    }
    buffer[ret] = '\0';
    Serial.print(buffer);

  //************* Close TCP or UDP connections **********
  sim808.close();

  //*** Disconnect wireless connection, Close Moving Scene *******
  sim808.disconnect();
}

//void gps() {
//   //************** Get GPS data *******************
//   if (sim808.getGPS()) {
//    Serial.print(sim808.GPSdata.year);
//    Serial.print("/");
//    Serial.print(sim808.GPSdata.month);
//    Serial.print("/");
//    Serial.print(sim808.GPSdata.day);
//    Serial.print(" ");
//    Serial.print(sim808.GPSdata.hour);
//    Serial.print(":");
//    Serial.print(sim808.GPSdata.minute);
//    Serial.print(":");
//    Serial.print(sim808.GPSdata.second);
//    Serial.print(":");
//    Serial.println(sim808.GPSdata.centisecond);
//    Serial.print("latitude :");
//    Serial.println(sim808.GPSdata.lat, 6);
//    Serial.print("longitude :");
//    Serial.println(sim808.GPSdata.lon, 6);
//    Serial.print("speed_kph :");
//    Serial.println(sim808.GPSdata.speed_kph);
//    Serial.print("heading :");
//    Serial.println(sim808.GPSdata.heading);
//    Serial.println();
//
//    //************* Turn off the GPS power ************
//    sim808.detachGPS();
//  }
//}

First, I would assume you need to call sim808.getGPS() to update the GPS data. Not sure why you commented that out.
Normally, when building a GET command, you don't include the url (unless going through a proxy).
Last, you need to use %f with sprintf to format a floating point value.
Something like this might work:
void tcp()
{
    // Update the GPS data
    float lati, longi;
    if (sim808.getGPS()) {
        lati = sim808.GPSdata.lat;
        longi = sim808.GPSdata.lon;
        sim808.detachGPS();
    }
    else {
        // No gps, abort
        return;
    }

    //*********** Establish a TCP connection ************

    if (!sim808.connect(TCP,"api.thingspeak.com", 80)) {
       Serial.println("Connect error");
       return;
    }
    else {
       Serial.println("Connect mbed.org success");
    }

   //*********** Send a GET request *****************

    char http_cmd[100];
    sprintf(http_cmd, "GET /update?api_key=FF19NVWMPZEWX0XK&field2=%f&field3=%f HTTP/1.0\r\n\r\n\0", lati, longi);
    sim808.send(http_cmd, strlen(http_cmd));
    int ret = sim808.recv(buffer, sizeof(buffer) - 1);
    if (ret <= 0){
        Serial.println("error receiving");
    }
    else {
        buffer[ret] = '\0';
        Serial.print(buffer);
    }

    //************* Close TCP or UDP connections **********
    sim808.close();

    //*** Disconnect wireless connection, Close Moving Scene *******
    sim808.disconnect();
}

Thanks a lot, man! I 'll check this and let you know! Thanks again!


text:
How to extract latitude and longitude from GPS
I want to extract longitude and latitude from GSM/GPS module and then upload it to thingspeak. I am using sim808 GSM/GPS module and AT+CGPSINF=0 to get GPS location information sentence (CGPSINF: 0,6.823375,80.001038,36.300000,20170705124133.000,0,10,0.037040,47.410000
). I want to extract longitude and latitude from it. Does anyone know how to do it? I am not an expert in programming. someone told me to use strtok. But I don't know how to do it. Does anyone have any Arduino code to do this?
I tried DFRobot SIM808 library to collect GPS data. it works like charm. But the problem was, my upload code didn't work when i was using the library to collect longitude and latitude in the same code.
This is my web upload code.
#include <SoftwareSerial.h>
#include <String.h>

SoftwareSerial mySerial(10, 11);//(2,3)

void setup()
{
  mySerial.begin(2400);   // the GPRS baud rate 9600
  Serial.begin(2400);    // the GPRS baud rate 9600

  delay(1000);

  ShowSerialData();

}

void loop()
{
      Send2Pachube();
  if (mySerial.available())
    Serial.write(mySerial.read());
}
void Send2Pachube()
{
  mySerial.println("AT");//start with attention
  delay(1000);

  mySerial.println("AT+CPIN?");//check for the sim card
  delay(1000);

  mySerial.println("AT+CREG?");//check for registration and access technology of cell
  delay(1000);

  mySerial.println("AT+CGATT?");//check whether the device is attached to GPRS.0Detch,1Attch
  delay(1000);

  mySerial.println("AT+CIPSHUT");//shut packet data protocol context
  delay(1000);

  mySerial.println("AT+CIPSTATUS");// returns the current connection status
  delay(2000);

  mySerial.println("AT+CIPMUX=0"); //create multi-IP connection(0=single connection)
  delay(2000);

  ShowSerialData();

  mySerial.println("AT+CSTT=\"hutch3g\"");//start task and setting the APN,
  delay(1000);

  ShowSerialData();

  mySerial.println("AT+CIICR");//bring up wireless connection
  delay(3000);
  ShowSerialData();

  mySerial.println("AT+CIFSR");//get local IP adress
  delay(2000);
  ShowSerialData();

  mySerial.println("AT+CGPSINF=0");//get GPS
  delay(2000);
  ShowSerialData();

  mySerial.println("AT+CIPSPRT=0");//starts a TCP or UDP connection
  delay(3000);

  ShowSerialData();

  mySerial.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",\"80\"");//start up the connection
  delay(6000);

  ShowSerialData();

  mySerial.println("AT+CIPSEND");//begin send data to remote server
  delay(4000);
  ShowSerialData();

  String str="GET https://api.thingspeak.com/update?api_key=FF19NVWMPZEWX0XK&field1=100";
  mySerial.println(str);//begin send data to remote server
  delay(4000);
  ShowSerialData();

  mySerial.println((char)26);//sending
  delay(5000);//waitting for reply, important! the time is base on the condition of internet
  mySerial.println();

  ShowSerialData();

  mySerial.println("AT+CIPSHUT");//close the connection
  delay(100);
  ShowSerialData();
}
void ShowSerialData()
{
  while(mySerial.available()!=0)
    Serial.write(mySerial.read());
}

Since the library works in getting the data, maybe you should focus on getting that to work with your code.

First rather than just dumping it to the screen store the data in a char array
char dataBuffer[64];
int dataCount=0;

while ( (mySerial.available()!=0) && (dataCount<63) ) {
    dataBuffer[dataCount] = mySerial.read());
    dataCount++;
}
dataBuffer[dataCount] = 0;

then use strtok to split the string on the : and , characters
char *output;
output = strtok(dataBuffer,":");
// output will now point to everything up to the first : so "CGPSINF" for gps
int field = 0;
while (output != null) {
  field++;
  output = strtok(null,",");
// output will now point to each value in turn
// for CGPSINF:0,6.823375,80.001038,36.300000,
// when field == 1 output=="0"
// when field == 2 output=="6.823375" etc...
}


text:
Sending JSON message to web api via post. Why does HTTP 1.0 versus 1.1 make a difference?
I am sending a message to a web api call every xx seconds. I could not get it to work at all until I changed the header from HTTP 1.1 which is what I was using to HTTP 1.0. Then, it started working. Why would this affect things where I could not post and now I can?
This is what it was when it wasn't working:
client.println("POST /BoxLevel/api/BoxMeasurement HTTP/1.1");

And the change that fixed it:
client.println("POST /BoxLevel/api/BoxMeasurement HTTP/1.0");

Thanks!

HTTP/1.1 requires you to provide the host name of the server. And it will keep the connection open for some time unless you explicitly opt out of this. Thus, the equivalent of the basic HTTP/1.0 request in HTTP/1.1 language is
POST /the_uri HTTP/1.1
Host: foo.example.com
Connection: close

Thank you for the answer. One follow up question, with the host requirement in 1.1, does the host have to be valid? Meaning, will the client try to resolve the connection or check the host or can you populate it with anything?

@MichaelBedford: It's up to the server to interpret the Host header. It is very common for a single server to serve more than one Web site (it's called shared hosting). The Host header is then used by the server to know which Web site the client wants. If you provide an empty or a dummy name, you usually get a useless dummy page. A server serving a single site may just ignore that header, but it could also give an error if it's incorrect.


text:
CO2 sensor for arduino
I want to add CO2 measuring feature to my room weather station. Can someone please recommend a CO2 sensor easy to integrate with Arduino?

You could try the K30 CO2 sensor. There is also a guide using it to make an arduino CO2 detector here.
I've also seen people use the MG-811 module, you can buy them from dfrobot.com . There is also good documentation for how to use the MG-811 with arduino here.

Are these sensors good for external environment, not only to inside building?

Based on hands-on time with CCS811 CO2 sensors, I would recommend against them. They tend to drift high, sometimes way high, and then come back to their senses and provide reasonable readings when reset.
I've tried two batches of CJMCU-811 sensors, purchased months apart (hoping to get a different manufacturing lot), and they were all rubbish.

This worked well for me on a colour screen. A small delay for the sensor and a long burn (24hrs) required. But easy KIWI
#include <XTronical_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include <Adafruit_GFX.h>    // Core graphics library
#include <sSense-CCS811.h>
#include <dht.h>

#define SERIAL_SPEED  9600

#define TFT_SCLK 13         // SPI clock
#define TFT_MOSI 11         // SPI Data
#define TFT_CS   10         // Display enable (Chip select), if not enabled will not talk on SPI bus
#define TFT_RST   9         // Display reset pin, you can also connect this to the Arduino reset
                            // in which case, set this #define pin to -1!
#define TFT_DC     8
CCS811 ssenseCCS811;
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);
dht DHT;

#define DHT11_PIN 7

void setup()
{
  DebugPort.begin(SERIAL_SPEED);
  delay(5000);
  Serial.println("s-Sense CCS811 I2C sensor.");
  if(!ssenseCCS811.begin(uint8_t(I2C_CCS811_ADDRESS), uint8_t(CCS811_WAKE_PIN), driveMode_1sec))
    DebugPort.println("Initialization failed.");
  tft.init();   // initialize a ST7735S chip,
  tft.setRotation(0);
  tft.fillScreen(ST7735_GREEN);
  tft.setTextColor(ST7735_RED);
  tft.setCursor(0, 30);
  tft.setTextSize(1);
}

void loop()
{
  ssenseCCS811.setEnvironmentalData((float)(21.102), (float)(57.73));  // replace with temperature and humidity values from HDC2010 sensor
  int chk = DHT.read11(DHT11_PIN);
  if (ssenseCCS811.checkDataAndUpdate())
  {

    tft.fillScreen(ST7735_GREEN);
    tft.setCursor(10,10);
    tft.print("CO2 ppm  ");
    tft.print(ssenseCCS811.getCO2());
    tft.setCursor(10,40);
    tft.print("tVOC ppb ");
    tft.print(ssenseCCS811.gettVOC());
    tft.setCursor(10,70);
    tft.print("Temp C   ");
    tft.print(DHT.temperature);
    tft.setCursor(10,100);
    tft.print("Humid %  ");
    tft.print(DHT.humidity);

  }
  else if (ssenseCCS811.checkForError())
  {
    ssenseCCS811.printError();
  }

  delay(2000);
}

How about this one? http://cgi.ebay.de/ws/eBayISAPI.dll?ViewItem&item=380915024016&ssPageName=STRK:MESE:IT
The MG-811 is highly sensitive to CO2 and less sensitive to alcohol and CO.

This one:
http://sandboxelectronics.com/?product=mg-811-co2-gas-sensor-module
They also got a nice demo code there.
Here is a wiring scheme if you use the demo without modification:

Red - 5V
Black - GND
Yellow - Analog input 0
Green - Digital I/O 2

The easeir integration ever


text:
Keyboardmessage on Arduino UNO
Can an Arduino UNO and Arduino Leonardo do the same things?
Some of the examples in the Arduino software say to use Leonardo e.g. KeyboardMessage.

No, the Uno and the Leonardo cannot do the same thing.  The Leonardo is a single MCU directly connected to the USB port. It is down to the software on that MCU as to how it communicates (what it enumerates as) on the USB bus.
The Uno, conversely, is a dual MCU system. It has the "main" MCU (the ATMega328P) which is what you program, and that communicates to the USB port via another MCU.  The two MCUs are connected using TTL RS-232 (UART), so the only communication you have with your computer is through the Serial object.
There are benefits and problems with both approaches.  The benefits of the Leonardo are that you can emulate keyboards, mice, etc.  The down side is that the whole USB communication is more fragile and is at the mercy of the user.  The Uno's benefits are that the USB serial is always connected and available regardless of the state of the main MCU, which is much more friendly from the PC's point of view.  The down side is that it severely limits your communication options.

Yes you can, but not with that library. This method is a little advanced and requires you to upgrade a different type of firmware to your second MCU on your Uno.
(The full tutorial is available here)
Example code from the tutorial link shown above (for process outlined below):
uint8_t buf[8] = {
  0 };  /* Keyboard report buffer */

void setup()
{
  Serial.begin(9600);
  randomSeed(analogRead(0));
  delay(200);
}

void loop()
{
  int randomChar = random(4, 130);
  long randomDelay = random(1000, 10000);

  delay(randomDelay);

  buf[2] = randomChar;    // Random character
  Serial.write(buf, 8); // Send keypress
  releaseKey();
}

void releaseKey()
{
  buf[0] = 0;
  buf[2] = 0;
  Serial.write(buf, 8); // Release key
}

Here's what you need to do:

Get a DFU programmer

Windows: Download Atmel's flip programmer from here http://www.atmel.com/tools/flip.aspx
Mac: Install MacPorts following these instructions: http://www.macports.org/install.php#pkg Once MacPorts is installed, in a Terminal window, type sudo port install dfu-programmer
Linux: from a command line type sudo apt-get install dfu-programmer or sudo aptitude install dfu-programmer depending on your distribution

(Source: http://arduino.cc/en/Hacking/DFUProgramming8U2)
Download the Keyboard LUFA firmware
You'll have to solder a resistor on a non-SMD Uno (that's outlined in the Arduino link in the second step)
Connect the Uno to your comptuer and reset the 8u2 (short the farthest left pair of metal contacts in the upper left hand corner of the Uno)
Upload the firmware using the GUI in flip, OR for Mac/Linux go to the directory where the firmware is using the terminal then:

Type this line (Still, Mac or Linux only):
sudo dfu-programmer at90usb82 erase
sudo dfu-programmer at90usb82 flash [Replace-this-with-file-name].hex
sudo dfu-programmer at90usb82 reset

Unplug/plug in your board and enjoy! Note: you'll have to flash the standard firmware to upload a new sketch and the flash the keyboard firmware again to get this to work.


text:
Sending serial commands to yourself
Is it possible to "send" a serial command to the device itself to see the response?
I have written a little routine based on a couple of serial sends and receives and want to see if that works out like I want.
EDIT:
I have a device (an AVR with arduino boot loader) and as part of my program, the device exchanges phrases with peripheral devices over a serial connection. Since I have right now just the arduino itself and can't really test, if at least the logic behind the serial part of works out, I would like to get serial commands from somewhere and trigger 'continuous talking', so I want to monitor the response behavior of my module, if it gets a certain command (stability reasons). Instead of waiting for a second device, is it possible to "link the TX/RX line to itself" internally or externally to test my program with itself?

No idea what you are asking there, sorry.  Please flesh out your question with an actual example - your current description is impossible to interpret.

Welcome to Arduino SE! I've edited your extra content into the main question.

It sounds like you may be thinking of a serial "loopback" test.  On the hardware side, it can be as simple as shunting the transmit pin to the receive pin - just make sure nothing else is hooked up to that transmit pin.  Coming up with something useful on the software side may be more interesting; there is also the question of how you are going to monitor it.

But if I recall, there is a resistor between the USB-serial output and the ATmega input on the basic Arduino series, so if you jumper D1 and D0 the ATmega will hear its own transmissions, and a connected PC will passibly see all of it.  Just remove the jumper before you try to talk or program with the PC.

Yes, you can do that by cross-connecting the transmit and receive pins on the Arduino. But then your devices sits there silently murmuring to itself (or not...) and you can't really tell what it's saying, or if it's doing anything unless you can observe some other hardware - LEDs, a 'scope, f/ex.
But why not hand-type or script some messages to it on your PC? If the Arduino sketch would make some brief, coherent replies you could confirm what it's doing and debug it if necessary.
I've done just this in your situation: Two of us defined a serial protocol - the ASCII (for human readability!) commands and replies that either end could make or expect. Then each of us wrote the communication code for one of the two devices and proved that it met the protocol. Once both of us had finished and were confident in our respected communication code, we plugged the two devices together, and - they played! Nicely! :)  And if they hadn't we could have eavesdropped on the serial line and printed their attempted conversation to discover where it went wrong.

That's a good idea!


text:
Arduino to Raspberry Pi wired communication
I am new to Raspberry Pi (just brought mine before writing this post), and I am looking to see what is the most ideal way for two way communication between an Arduino and a Raspberry Pi (USB, SPI or I2C).
The reason I am asking is because I need to build a small, semi-autonomous robot and plan on using both the Arduino and Pi to control it, using the pins of the Arduino for the motor control and sensors and the Pi for video processing and autonomous part. Both will be on the robot itself. I am pretty good with the Arduino but never used a Raspberry Pi before.
So my biggest question is what would be the best form of communication for the two boards taking into account speed and safety (there is a voltage difference between the Pi and the Arduino).

Hands down, I can rule out the I2C. This post sums it all up:

SPI is faster.
I2C is more complex and not as easy to use if your microcontroller doesn't have an I2C   controller.
I2C only requires 2 lines.

Since speed is your first priority, either do USB or SPI. I'd personally go with USB, just for the reason that it's simple. Nearly any programming language can inference with COM ports, but that's not the case with SPI. Also, for SPI, you would have to either use a level shifter, or do a voltage divider for the Arduino to RPi wires (for RPi to Arduino wires, Arduino can still sense 3.3V as HIGH.)
Also, serial can be pretty fast. Technically, the Arduino can go up to 2 Mbps (not very fast compared to a lot of things, but fast enough for what the Arduino can even handle). One thing to note, the writer of the post stated that this is the highest you can practically achieve with the poorly optimized libraries:
Serial.begin(500000);

Firsr of all, When you say "there is a voltage difference", I assume you are referring to the raspberry pi being a 3.3v device vs the arduino's 5v, and not to some kind of ground potential difference. If theres a ground potential difference(which there shouldn't be in a robot), neither i2c or spi or usb will work without extra circuitry.
My short answer would be USB all the way because its easy and built into the arduino and pi. The only issue is that if anything mechanically bumps the usb enough to lose connection, sometimes linux is a little unpredictable with regards to naming serial ports, and when it reconnects it might give the arduino a different serial port name. But this isnt an issue if your cable isnt a cheap worn out one with a flaky connection like the one that bothered me for a hour today.
USB does have about a millisecond of latency because devices are usually polled at 1khz iirc. Using the raspberry pi hardware serial might be a good idea if milliseconds count which I doubt they do.
But on the software side, raspi hardware serial and USB serial are the same. So there should be no problem switching between them if you need to.
I wouldnt bother with i2c or spi. Why fuss around when serial works so well?


text:
Is there a transmission protocol library for SPI?
When communicating over SPI, one byte is sent at a time. Is there a library (C or C++) that allows for sending strings? Essentially it would be a protocol library handling the start and the end of a message, as well as integrity checking. (I'm using an Arduino.)

I have never used uart and have no experience with microcontrollers. But doesn't uart have integrity checking, in contrast to SPI?

I believe uart uses that. I would make a library myself to do integrity checking etc. But I thought this was already common to use and easily available.

@WoutervanOoijen Okay, I didn't know. Thank you for the information. I'm just getting started with microcontrollers (Arduino in my case), and there is a lot to learn! One big problem is of course The Arduino Language vs. C++. Later on when you don't use Arduinos anymore, C++ is the better language to know. However the Arduino language is easier in the beginning. But I have a lot of programming experience in preprocessed languages, so it makes the decision easier..

What do you need that a simple for loop won't provide?

@IgnacioVazquez-Abrams I thought the transmission was too unreliable to use it without doing integrity checking. If that is not necessary, a simple function containing a for loop will do the job. Thank you everyone who has commented.

@FriendofKim - if your goal was to have a reliable transport mechanism over SPI (with some sort of error check and correction or retries) then you should edit your question to say so, as that is not a typical problem and not one would conclude from reading your question as currently stated.

Each spi peripheral has its own protocol in the sense of commands and addresses if any and data.  Spi simply makes a common ground for chip select vs clocks and clocks vs data and separate miso and mosi data lines.
So a general purpose library doesnt make sense.
Also spi certainly is not limited to a byte, many peripherals and many spi controllers allow for long sequences of data, you are also not strictly limited to multiples of 8 bits either although that is the norm.
Your arduino spi master may have its limitations but that has nothing to do with spi in general.
Integrity testing is not part of the spi protocol, you get what you get.  Ideally all of the parts are soldered down on the same board or through known connectors and the margins have been designed in.  You would need to do something outside the spi protocol, for example if it is a spi flash then after you read a chunk of data you can do a checksum and compare it with a checksum you have embedded in the data (or crc).  If it is a spi ethernet part you may choose to leave the frame checksums in the frames and re-validate each frame yourself.  If you create your own peripheral (hardware design or cpld or fpga) then certainly you can add a crc or checksum to every transfer if you wish.

@NickAlexeev There are plenty of SPI peripherals which either send CRC together with the data (example), or also require the master to send CRC of commands. Of course, many lasy library implementations simply ignore the CRC in the first case.


text:
Which connection should I use (preferably wireless)?
For a (for now MIDI only) project I was planning to use multiple Arduinos and send messages around.
However, for the latency, I can have max 10ms (to prevent audible delay).
I hoped to use WIFI modules (ESP-01), however, according to a previous question in Question, one remark that due to HTTP overhead the time/latency would be 15 ms. So that means WIFI is not possible.
My requirements:

Latency of <= 3 ms (rationale: I need at least 5 ms for processing, and want to keep total latency < 10 ms)
Preferably a wireless solution (rationale: I want to add later more Arduinos and want to prevent cabling)
Preferably not using a hardware serial (low prio requirement) (rationale: the MIDI box which is a Mega, would preferably need 4 MIDI inputs, using a hardware serial would reduce one, software serial is unacceptable for MIDI).

Situation:

Arduinos are very close together, probably within centimeters (upto like 50 centimeters)
Messages are short (like 5-10 bytes max)
Burst of messages can be possible, but not so likely

Background/message flow:

Receiving MIDI input by Arduino 1
Sending (filtered/changed) message to Arduino 2
Arduino 2 process the manage, takes <= 5 ms
Arduino 2 sends message back to Arduino 1
Arduino 1 converts it to a MIDI message and sends back

This all needs to be done within <= 10 ms
My thoughts so far:
Wireless solutions:

WIFI: HTTP seems to result in 15 ms delays, which is against my requirement.
RF: probably overkill since my Arduinos will be very near to each other. Also I would need both a receiver and transmitter in both Arduino's.
IR: Due to out-of-sight problems not very convenient.

Wired solutions:

I2C: Might be possible, planning to use later also an I2C display possibly but should not be a problem
SPI: On Arduino 2, I'm already using an SRAM with SPI which I do not want to stress more (also a time-critical resource). Also an SD card via SPI is used (but this is not a time critical resource).
Wire: Not checked yet

Question
Is there any wireless (or wired) solution I can use (probably beyond the ones I analyzed)?
115200 baud is what I need for a Serial connection, probably a SPI/I2C (latter preferred) is also acceptable. Or I might have missed other communication possibilities.

NRF24L01+ transceiver, maybe.

You need a custom solution.  I was looking into wireless flash sync signals years ago and everything off the shelf took too long.  If you do go with Ethernet (I think you shouldn't) you probably need to understand the difference between UDP and TCP.  One is "get it there now no matter what the condition the packet is in" (skype).  The other is "keep trying until it is perfect" (bank transactions).

@Gerben: I checked and it seems 250KBPS is possible ... which is strange, since close WIFI has a max of 115baud... I don't need the long distance, but if the speed/latency is good, it might be a good candidate.

Also, keep in mind I2C and SPI are for chip to chip communications.  Neither were meant to go any distance.  The are really to keep the pin counts low on the integrated circuit packages.  Which is a good way to keep the MTBF (time between failures) down.

@st2000 I heard that default WIFI (and Ethernet probably) using HTTP request takes a lot of overhead. Currently I don't know much bout UDP/TCP and I do not want to spend TOO much time learning that (since my core project also needs to continue).

@st2000 I thought I2C was for connecting (many) devices (so distance is not so much a problem). But if needed, I will keep distance low (but still like 10-30 centimeters).

Yes, Ethernet is way more complex than most people make it out to be.  And on top of everything else, it is very possible that no two Ethernet appliances work alike adding to the frustrations.  Synchronization over Ethernet is not trivial.  I suspect Sonos and Logitech/SqueezBox both use an extensive bag of tricks to synchronize music played at multiple points off an Ethenet network.  I would stick to MIDI and investigate if there are wireless MIDI appliances available.  After all MIDI was created with music in mind.

@st2000 actually I do not want to send MIDI messages wireless, but my own messages (although they contain some of the MIDI info). However, maybe I can use it as a low-latency (using MIDI as protocol to send info, possibly even MIDI messages itself).

I2C can be used for multiple devices. But normally all are on the same board.  For example, you computer mother board may have several I2C temperature sensors all connected to a common I2C bus.

you can use a fiber optic link to connect IR and make it act more like a wire if you have line of sight issues. You can also just do 115200 serial between devices. The ESP8266 can use Serial, and Serial1 (for TX only), these are hardware, so you should be able to daisy-chain at high speed.

@st2000 ah ok ... well in my case I just need commands sending from one Arduino to another, so than I2C is maybe not so good.

@dandavis: a fiber optic link, never thought about that ... and plan 115200 serial might do as well. Do you mean that with an ESP8266 I can skip http and use Serial 'directly'?

that's exactly what i mean; they are very low overhead and latency

Beyond the nRF24L01's I also ordered an extra ESP-01 (ESP8266) so I can try to send messages between them and make the best choice.

I see the anonymous downvoter is back. For everybody else a nice christmas.

I would either use the ESP8266 as a standalone device and directly program it to work with UDP datagrams or a permanently established TCP socket, or the nRF24L01+.
Of the two I would most likely use the nRF24L01+. It's good enough for 99% of wireless keyboards and mice, so plenty good enough for a few MIDI style messages.

Well I might need quite some MIDI messages (like CC messages), but that sounds good ... need to analyze both in more depth (and need to order an nRF24L01+).

You'll want at least two nRF24L01 modules :P

I ordered 5 SE8R01's (they seem to be compatible) and 5 adapter plates (for NRF24L01+) ... together < 4 euro.