text:
HMC5883L - Tilt compensation without Accelerometer
Trying to get an HMC5883L to compensate for being installed in 90 degrees. Doesn't seem to me that it'll need too complex math or accelerometer. But I have no idea how to do the compensation for it. Any idea?
Using the Adafruit HMC5883L and its library.

You can always use the normal tilt compensation equations with a fixed value instead of a calculation from the accelerometer; Since you know the rotation beforehand the equations may not be as complex. For example, if the tilt is only on one axis, it's just one rotation matrix multiply (and you don't need to calculate the result z axis) instead of 3 in general.
If the tilt is constant and exactly 90 degrees, You just need to swap which magnetometer axis are put into the magnetic field angle equations. If one axis is pointed towards the center of the earth, you can use the other two axis to calculate the direction of the magnetic field without an explicit rotation transformation.


text:
Why doesn't the master branch BOSSA work on Arduino Due?
I have downloaded BOSSA for Linux, and have run bossash->scan. I have also tried erasing and resetting the board before scanning. It does not work. According to the Arduino website, the native USB port is connected directly to the chip.
Isn't the master branch BOSSA (Arduino IDE uses it's own modified version of BOSSA) working because of a problem with this specific board, or have Arduino modified something inside the chip which alters the behaviour of the native port?

No Arduino did not alter the chip, custom chips are massively expensive. If they are using their own modified version of BOSSA, then there must be a reason for it, probably the support of Arduino's hardware platform. To find out what the difference is, you have to find the code base used for Due and the original version when the code was forked. Often in such cases a project like Arduino can provide a patch to the BOSSA project, and that patch may or may not be applied to the master tree. Only way to find out is to check the BOSSA project repository / bug  reports and documentation.

I was thinking about the bootloader, but maybe it can't change the behavior of the native USB port? So what you are saying is that the native BOSSA should work if the native USB port is connected directly to the chip? Are you implying that they have added extra hardware in between that BOSSA needs to account for? Please bear with me, as I know very little about this subject. I'm trying to learn more about it.

@FriendofKim I am unfamiliar with BOSSA and Due. This is generally how open source projects work.

source: Stack Exchange

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

sort: votes


text:
C++ vs. The Arduino Language?
What are the advantages of each language when using the Arduino?
I'm thinking this is a good general question, but I'll add a bit about why I'm asking if anyone wants to give me a tip.
I'm experienced in preprocessed languages like JavaScript, PHP, and have fiddled with languages like Java and Visual Basic. In other words I know programming techniques and both classical and prototypal object orientation, but nothing about communicating directly with hardware.
I'm making an octocopter, and am thinking that an object oriented approach will be the easiest. (The software will have very many features...) However I have never written in C++.
Since this is a Q&A site that's supposed to help others, only the general question presented at the beginning is of much importance, but I'd appreciate any comments on my situation.

Avoid Arduino IDE as it does not deserve its IDE name, it is even a very poor editor: it may be good for beginners and simple sketches but one should rapidly go to something better .

Visual Micro (www.visualmicro.com) provides a plugin for MS Visual Studio 2013 - even the free/express edition. Visual Mirco is not itself free, but it does allow you to code with tools like intellisense and PROPER syntax highlighting, and even compile and upload to a processor (with a bit of wrangling to get set up).

This is a fairly succinct breakdown of what is meant by (and what's actually under the hood of) the "Arduino Programming Language."

C++ vs. The Arduino Language? - The "Arduino Language" is C++. There is a bit of preprocessing to save you doing function prototypes, but it most definitely is C++.

There is no such thing as arduino language. It is simply a library.

Not so related to the question as to the comments: Atmel studio is free and IMHO it is better than visual studio for arduino programming. Also supports Visual Micro plugin, although it is not necessary at all for programming and debugging arduinos.

There is no Arduino language.

The Arduino language is a subset of Processing which is a subset of C++, and it has a few extensions that are taken care of in the precompile phase.  It doesn't have a formal name.  It just is what it is.  The IDE environment is definitely not a true IDE because it does not allow stepping through the programs, setting breakpoints, etc.  But with practice and judicious use of Serial.println statements it is easy enough to use.  Meanwhile, this question makes no sense since there is no other choice.

There are definitely subtle differences between C++ and whatever language Arduino uses that will cause experienced C++ programmers confusion. The most obvious of these is the presence of identifiers that don't require declarations from header files. But I suspect there are other differences as well. I declared a C++ global object, and I'm not convinced that the constructor is called like it would be in a C++ program.

My personal experience as professor (programming, mechatronics) is that if you have previous programming experience and you are aware of concepts as OOP, it is better to go for C/C++. The arduino language is really great for beginners, but have some limitations (e.g. you must have all your files in the same folder). And it is basically a simplification of C/C++ (you can practically copy&paste arduino code to a C/C++ file, and it will work). Also it makes sense that you can go and use a full well known IDE as eclipse:
http://playground.arduino.cc/Code/Eclipse
Initially it is required a bit more of setup and configuration of your dev environment, but IMHO it is worth it for programmers with experience in any other language.
In any case, it won't harm you to start using the arduino language and the arduino IDE for a few days to get familiar with the arduino hardware and then move to C/C++ with Eclipse for really developing your project.

Thank you for your thoughts. I'll use the Arduino IDE to learn how to control all the different hardware pieces like sensors and LCD screens etc. Then I'll move up to C++ to make the software for the octocopter. Do you know a good and short book for people who know other languages? The "problem" with many books I've found is they include so much that I don't need because I'm on a small Atmel microcontroller rather than a UI computer.

There is a nice book "C Programming for Arduino" by by Julien Bayle which is useful. It is C not C++ language but should help you to understand the basis.

Thats a good request: a short and good book with the basics of C++ for programmers of other languages. Sorry I cannot give any recommendations, i am not aware of any good one. In fact, I wrote a book, with a practical focus (develop a videogame) for my students, but it is only in spanish. For a good and practical C++ book I would recommend Deitel&Deitel How to program C++, you could skip many advanced chapters.

C++ supports OO features, C language does not.

Why on Earth would you need folders for your Arduino code? It only has 32kb to work with. I really don't see why so many people dislike the Arduino IDE so much. It is fine for what it's meant for. I wish it had an integrated emulator though so I didn't actually need to wire up LEDs to test things and Intellisense would be nice but it is still as helpful as it needs to be.

"you can practically copy&paste arduino code to a C/C++ file, and it will work" Not just practically. Arduino code is written in C++, and if you examine the Arduino library source code you'll find that most/all the functions/classes in it are C++ wrappers around lower-level C libraries; I actually ended up modifying the library code for a project last year in order to use some more of the USARTs on a Due (the Arduino library makes assumptions about how many will be used and what mode they're in) while still being able to utilize the abstractions provided by the Arduino library.

@ChrisO OO features can be used (simulated) in C as well. However, you need to have a certain degree of familiarity with function pointers to be comfortable using this.

@JAB Huh? Are you implicating that all the UART ports can be used as both RX and TX if you modify the library? I mean, since there are 4 UARTs, could you actually get for example 8 RX instead of 4 RX and 4 TX?

@FriendofKim Not exactly what I meant (though technically you could, the Due is fast enough to support a software solution for non-megabit serial communication, and it does have 5 U(S)ARTS in total while the Arduino libraries only provide 4 of them but iirc the Due board does not provide pins for one of the USARTs anyway); the Arduino libraries configure the USARTs to use asynchronous mode, but I needed synchronous at up to 6Mbps (and I had to use SPI mode as the input had to be treated as a raw bitstream so no stop bits/etc.), which also involved modifying the default PIO controller config.

Do you know if there is a reason why they put these limits on the board, when the microcontroller actually supports it? Or is it just bad programming?

@JAB Forgot tag.

@FriendofKim For simplification; one of the purposes of the Arduino project is to make programming embedded systems accessible to a larger audience, so all the detail and nitty-gritty gets hidden from the casual user (similar to Processing, which the Arduino IDE is actually based on). More advanced users who don't need all the abstractions/simplifications provided by the Arduino framework can still use it as a base for their own work if they don't want to rewrite everything on their own.

As a professor you should know that there is no "Arduino language": It's C++ with Arduino specific libraries.

Yeah, you probably want to tell the Arduino maintainers to change their front page for the Arduino documentation: https://www.arduino.cc/reference/en/, in which they define it as the "Arduino programming language". Maybe they don't know it is C++ with libraries either.

In theory...
There isn't really an Arduino language as such. It's really just C++ with some domain-specific libraries. These add on various features, such as functions you can call to control the hardware. If you didn't have those functions, you'd need to fiddle directly with special registers to control everything. That's how embedded programming is usually done. It's fast, but it can be quite hard to learn and understand.
In addition to the functions, the libraries add alternative names for some types. For example, boolean and byte are not in the C++ standard. However, they are directly equivalent to bool and unsigned char.
All of these things mean you can probably port general C++ code directly to Arduino without difficulty. However, going back the other way may require some minor editing.
But note that not all features of modern C++ versions are available on all Arduino platforms. In some cases, they aren't realistically possible, such as std::thread on an 8-bit microcontroller. Others simply haven't been made available, such as std::array.
In practice...
Having said all of that, programming for Arduino isn't exactly the same as general C++ programming. A lot of the differences are common to all embedded programming though (such as limited memory and processing power).
It's also worth noting that if you're using the official Arduino IDE then there are all sorts of annoying quirks and limitations on how you setup your code. There are workarounds in all cases (as far as I'm aware), but they are sometimes quite frustrating.
For full flexibility, use a third-party IDE (such as Eclipse) with a plug-in to support Arduino. That should give you all the advantages of C++, along with the Arduino libraries.

Here's my setup for Eclipse, which works fine with Arduino. https://arduino.stackexchange.com/a/75491/7727. I don't use any Arduino plugins, just pure Eclipse for C/C++.

What are the advantages of C++ vs the Arduino language when using Arduino? I'm experienced in preprocessed languages like JavaScript, PHP, and have fiddled with languages like Java and Visual Basic.

First, the Arduino compiler/IDE accepts C and C++ as-is.  In fact many of the libraries are written in C++.  Much of the underlying system is not object oriented, but it could be.
Thus, "The arduino language" is C++ or C.
C++ is not garbage collected.  It does manage variables in scope - if you write:
int led = 13;

void blinkTimes(int value)
{
   int i;

   for(i=0;i<value;i++)
   {
      digitalWrite(led, HIGH);
      delay(1000);
      digitalWrite(led, LOW);
      delay(1000);
   }
}

Then you'll find that led and i don't grow or leak, no matter how many times you call blinkTimes.
If i were a class, it would similarly be disposed of once the function ended.  So as long as you aren't using new or similar memory allocation functions to create new objects, then you won't have to worry about leaks.
You may still run out of memory, if you create huge classes and use a lot of them in deeply nested functions, but in general you aren't going to run into trouble until you start dealing with new and free functions.
If you are using new, then you'll have to call delete at appropriate times.  C++, and by extension Arduino, has no automatic garbage collection, you have to explicitly manage your own memory.

Okay, if instantiated objects (with new) aren't garbage collected, I'll have to learn that as well. I suppose any book on C++ will cover that. Thank you for a good answer!

--- Update 170412
I wrote my original answer three years ago from the perspective of there existing a distinct "Arduino C++". The language used in the IDE is standard C++, because it is implemented by the GNU C++ compiler. "Apparent" differences creep in because the IDE will do some pre-processing to help newcomers to the language avoid a couple of 'gotcha's, by filling in some #includes, f/ex. But you can - and I do - write correct C++ to it and get just what you expect to get.
--- end update
Do limit your use of C++ language features to those whose implementation you fully understand. There are some features that compile to more resource-intensive code than is obvious from reading the source code. The optionally generated .lss (merged source and assembly) listing can give you some good insight into what the C++ compiler did when you weren't looking.
To your question about memory: C++ does not garbage-collect. Stack-based languages like C and C++ do allocate temporary storage on the stack for automatic variables at function entry, which then gets released when the function returns, but this is not true garbage-collection. Objects created in heap- or global memory live until you explicitly delete them. Make sure you know where, when, and for how long different kinds of objects will be created. You really don't want your code new-ing and delete-ing objects willy-nilly. They will be built in heap memory, fragmenting it and causing it to grow up into the stack. That's when your code - and your nice 'copter - will crash.
C does less for you so it can do less to you. It's not a bad choice. C with a few of C++'s features can be an even better choice, given you choose the extra features judiciously.C++, if those are your two choices:
[Original answer]
 - C++ is a standardized language. It is widely deployed in many environments including embedded systems and therefore is more thoroughly tested than the very-like-C++ language that is "Arduino". This is especially important for mission-critical / safety-critical applications such as you are planning. Crashed code means a crashed 'copter and even if it doesn't hurt someone, it will break your expensive machine.

Being standard, C++ is portable. Need to upgrade your processor? Everything but silicon-specific code will port to the new one. Need to change your toolset, development system, host OS? C++ will be supported everywhere. Though Arduino IDE will run anywhere Java is supported, it is the only tool that uses Arduino C++ and it is a very limited tool. If you want to use Eclipse, the AVR tools, go barefoot on the command-line, develop within Emacs, or whatever other environment you prefer, standard C++ will be supported.
The Arduino IDE does things behind your back - specifically, it #includes .h files when it thinks you need them. Even if it is correct, you really want to write, or at least see and understand, everything the compiler is going to see. Programming languages aren't made for computers (computers eat bits for breakfast); they're made for people, specifically the people who follow you on the project, the most important of whom may be ... you!, when 6 months after you wrote a module, you have to come back to enhance it, or more likely, fix it. You really want to be able to see everything the compiler sees.

This is a REALLY good answer. It seems clear that you like C++ and that I should like it as well! ... But seriously, I'll jump right onto C++ as soon as I've understood how the "communication" with the different sensors etc. work.

Do you know any good books on the subject? (Suited for me who have been programming for years in other languages, and only need the "embedded part" of C++.)

Do you think Accelerated C++ is a good book for this?

I wish I could help you with the 'right' book, but I came to C++ with a whole lot of C behind me and Kernighan & Ritchie's The C Programming Language is still my go-to book (bad pun) for anything not explicitly C++, and Ellis & Stroustrup's The Annotated C++ Reference Manual for C++. But for writing to hardware, you'll do well to look at some of the device libraries contributed by users at Arduino.cc. Start off tweaking I/O ports with pinMode(), digitalWrite() and digitalRead() functions, then their analog i/o counterparts, and eventually, ...

... plan to write directly to I/O registers for speed and memory-space improvements. Programs like blinky.cpp and hello.cpp are good places to start messing around with hardware. Add a simple multimeter, and a few LEDs with the right current-limiting resistors permanently soldered to one leg and you should be able to see real, if simple, results from your efforts. After that, read data-sheets for any hardware that interests you to learn what signals you can read / must write to them to make them play. Temperature sensors are easy to use and doesn't everyone need a fridge logger? Have fun!

Note that the Ellis & Stroustrup book is thorough and wordy with lots of discussion around the bare information, so maybe not your basic quick reference, but you'd learn a lot about C++ and why it is what it is and does what it does. Someone may know of a denser, more reference-oriented book.

I recommend moving your update to the top. Otherwise readers are under the false premise Arduino isn't C++ until they get to your update. See my answer here for additional insight. https://arduino.stackexchange.com/a/50839/7727

The Arduino language is C++, but it is very different from most C++ varieties. The Arduino language has a lot of abstraction built in, especially in the hardware interfaces, which makes it very simple to use. If you have a background in Java, C and C++ should be very similar.
The main differences between Arduino and C++ are in the memory storage. Usually a modern computer has more than 2GB of RAM, while the Arduino Uno has 2kB (1 million times less). The Arduino also uses 8-bit instructions in stead of the 32 bit ones a computer uses. This will mainly affect the amount of information you can store in a variable.
If you are very new to the Arduino world, you should look up a tutorial, as there are many good ones out there.

You mention memory. I have the Due which has got 96KB of RAM. But the last thing I want is for the copter to crash because of a memory leak (having a very expensive camera mounted on the copter).

Is memory in C++ handled automatically (like the garbage collector in Java) if not specified otherwise?

The C++ standard makes no guarantees about memory sizes - c++ already runs on embedded hardware without modification.

@MichaelThorpe I mean, do you have to specifically release memory when you don't need it anymore? Let's say you define 20 variables inside an infinite loop, will the memory be automatically released for every loop?

You are describing differences between the hardware platforms, not C++ there though.

@FriendofKim In C++, there are two different ways of instantiating variables/objects. If you instantiate them locally (e.g. int blah = 5;) then they will be destroyed automatically when they go out of scope (i.e. at the end of the loop or function). However, if you instantiate them on the heap (e.g. int *blah = new int(5);) then you need to release them yourself. It's not usually wise to use heap data in embedded programming though.

It IS c++ with Arduino libraries.

In my experience, it is best to avoid new and delete when running on machines with limited memory.

The memory management itself uses valuable program and RAM space
ISR vectors are set at compile tme. It is difficult (impossible?) for a class instance to claim an ISR at run time
Generally you will know at compile time what class instances you need - e.g. 3 button debouncers, a display driver and a 2-line display driver
Memory management introduces unknown delays when you use new or delete.

There may be cases where it is justified to use dynamic instance construction and destruction, but I suspect they are rare.

Being completely new to C++, I have a followup question regarding the STD. Is it a bad idea memory wise to use it? If not, how can it be added (Eclipse)? I've set up the AVR compiler and its working well.

All what you say is correct but I don't see how this is an answer to OP question. new and delete are available in Arduino IDE too.

It's not an answer, but very helpful information that I really appreciate.

As mentioned in several answers, if you are programing an embedded system in general you should avoid new unless you are managing your own memory heap and you really know what your object life cycles will be. Static allocation or stack variables are much safer. That said, one common trick to manage things like variable length buffers allocated for the duration of a function is to have an automatic variable (on the stack) that is an object that calls new in its constructor, and then put the delete in the destructor so when the object goes out of scope the buffer is released back to the heap. Again, this is usually of limited use in little micros but it is a nice pattern to remember.

In addition to the comments above, I would like to further stress the problems with working RAM that you have on Arduino boards, particularly with the Uno (and others that share the same microcontroller).  I recently wrote a simple Space Invaders game running on a 32x32 LED matrix and repeatedly ran into problems caused by low memory.
The Uno only has 2048 bytes of RAM.  The library for my matrix took over 3/4 of that leaving me with around 400 bytes for the game.  As it is my intention to "upgrade" the project at some point to run multiple games with the same program base on the more powerful Due, I designed the code with OO principals and a lot of class inheritance.  (The game class was inherited with virtual update and draw calls, the game entities were all inherited).
I pretty much ran out of memory just adding the invaders.  I tried to save memory by bit-fielding their member variables but ran out again when adding the shield objects.  After a bit more scraping I ran out adding the bombs/bullets.  At this point I scoured the code and removed all "virtual" tags (all my class prototypes are built from a Visual Assist snippet and destructors are all virtual automatically).  This halved my memory usage instantly, freeing enough to be able to complete the code.
Long story short, the end result is C++ code that doesn't really use any C++ features.  You might be as well just sticking to C and being very aware of your memory usage.  You get no help if you exceed the 2KB - particularly if you are using any dynamic allocation, the code just stops working and you are left scratching your head for a while until you consider the possibility of memory overflow.
PS - Bit fielding variables is bad.  Very bad.  Apart from adding processing overhead, I lost track of the number of times I'd add a new state to the game but the code wouldn't run and I couldn't understand why.  My state variable was not wide enough to hold the new state value so I was getting some unexpected state.

This is a pretty useful anecdotal answer detailing how OO C++ sucks for small embedded. I'll be sure to stick to procedural programming when using C++ on Arduino.

Arduino is C and C++ (it is a mix of the two, linked together); there is no "Arduino" programming language
The Arduino language is C++ (albeit usually implemented in a style more like "C with classes," which is actually fairly common in the embedded systems microcontroller world). End of story. Enough with people thinking it's a different language already! It uses the g++ compiler.
Proof:
Enable verbose output during compilation in the Preferences and upload and you'll learn a lot just reading those lines.
Here's some additional insight:
My own words:
Arduino code is C++. The Arduino core functions are simply a set of C++ classes and libraries you can use. It is built and compiled using the GNU gcc/g++ compiler. Your setup() and loop() functions are simply placed into the mandatory (meaning: required by both C and C++ in order to even be considered a valid program) main() function (right here actually--notice the file is main.cpp, which is a C++ source file) automatically for you and there is some extra preprocessing done to make sure it is a valid C++ program (ex: scanning for all function prototypes [aka: declarations] for you so you can use a function even though its prototype comes later in your .ino file). Much of Arduino is written in C, however, and therefore requires the # extern "C" {} braces around it to prevent C++ from "name-mangling" (also known as "name decorating/name decoration") function calls to C functions implemented by AVR-libc, which is the C implementation for the ATmega328 and other AVR-architecture microcontrollers.
Arduino's words:

"Can I program the Arduino board in C?
In fact, you already are; the Arduino language is merely a set of C/C++ functions that can be called from your code. Your sketch undergoes minor changes (e.g. automatic generation of function prototypes) and then is passed directly to a C/C++ compiler (avr-g++). All standard C and C++ constructs supported by avr-g++ should work in Arduino. For more details, see the page on the Arduino build process."

Source: https://support.arduino.cc/hc/en-us/articles/360018448219-Can-I-program-the-Arduino-board-in-C-
When to use the Arduino library vs pure C or C++?
So, use the Arduino language where it simplifies things, and write your own functions where you need more specialization. I do recommend getting away from the IDE quickly though for writing code--just use it for compilation. Set the IDE preferences to use "External Editor." Then use a professional source code editor/IDE such as Sublime Text 3, Atom, Visual Studio Code, or Eclipse CDT to write your code. You can then click back to the Arduino IDE to compile and upload. If you go with Eclipse, there are ways to do that in Eclipse (see the other answers here, and see the Arduino playground Eclipse article here too) so consider using those techniques too.
Update: Eclipse setup
See my answer here and my document here: Eclipse setup instructions on a new Linux (or other OS) computer. I wrote a detailed PDF to describe setup.

As of 2023Q3, the main function has moved to architecture-specific repos, here are two examples, one for AVR: https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/main.cpp#L33 and another for ESP32: https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/main.cpp#L40

@j0057, on the AVR core in the first link, you found the C and C++ required main function. In the 2nd link, for ESP32, the loopTask function still isn't the C and C++ required main function, rather, it is a FreeRTOS task (thread) being spun up and called in the xTaskCreateUniversal(loopTask... call later in that same file. Point taken, though, I'll update my links in the answer.

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

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


text:
How to connect 5V sensors to 3.3V digital input (Due)?
I'm completely new with Arduino and microcontrollers in general.
I have several 5V sensors, and need 3.3V because that's the max for the Due. Is it possible to use a resistor to connect it to the Arduino? Do I have to measure the current from the sensor and calculate the needed resistor like this?
$$\frac{5.0 - 3.3}{\text{Measured current}}$$
(5.0 - 3.3)/(Measured current)

It really depends on what you mean by sensor. An awful lot of boards can be given 3.3V instead of 5V

@Cybergibbons I'm talking about ultrasonic sensors, altimeters, accelerometers, gyroscopes, magnetometers, GPSes, bluetooth masters, SPI RF-modules and an LCD display. Wouldn't giving 3.3V to an ultrasonic sensor limit its maximum range?

I'm thinking generally anything that is connected to the Arduino Due. Some things will work with 3.3V, but is there an easy way of lowering the voltage? Being completely fresh to electronics, I can't see any other way of doing this with a cheap resistor than by measuring the current.

For bidirectional level shifting (like I2C) refer to this reply. For unidirectional level shifting you can use just a single diode with a pullup resistor, refer to the second part of this reply.

Well if you're not sure of what you're doing, you can always go with level-converters for your sensors (that does not apply to shields though)
Level-converters (sometimes called level-shifters) come in different flavors:

breakout board (the easiest to work with)
IC
DIY circuits with a few components

Some are "one-way": they have pin-pairs with converters 3.3V -> 5V, and other pin-pairs with 5V -> 3.3V conversion; others are bi-directional, i.e. you can use the same pair of pins in 2 directions 3.3V <-> 5V.
There are plenty of these converters, and they are rather cheap; here are just a few examples:

one-way breakout usable with 4 pairs of pins
bi-directional breakout usable with 4 pairs of pins
74HC4050 IC discussed here

I know 90% what I'm doing. There is so little power it's not dangerous. I'm not concerned about the components themselves, they can be replaced. However, I'm building an octocopter that's lifting my $2000 camera, and I don't want anything to break during flight!

Are these level-shifters simply variable resistors controlled by an IC?

Is my method of finding a suitable resistor wrong? If not, why not just use it?

No level shifter generally use active components (transistors , MOSFET, or CMOS), they are not just simple resistors.

A resistor will allow you to lower voltage from 5V to 3.3V but not to increase it. Also, there's a lot of energy waste using resistors to lower voltage, I guess power consumption is important for you if you build a copter.

So they will actually be more effective. Why do they use Arduino specific chips, instead of a general voltage lowerer? Of course the copter is short of energy, but wasting 0.03W isn't really much of a concern.

Why do you think those chips are Arduino-specific? The references I've given you are general and can be used anywhere you need 5V-3.3V shifting, i.e. almost everywhere in digital electronics where circuits are typically 5V or 3.3V.

I thought SparkFun was an Arduino only page. Thank you for your comments. The bidirectional one seems perfect!


text:
Can I compile c/c++ code on the linux part of the Arduino Yun?
Can I compile c/c++ code on the linux part of the Arduino Yun?
How complete is the linux part of the Arduino Yun?
Can I scp some c/c++ code onto the Atheros AR9331 chip compile it?
Or must I first crosscompile all software and then put them onto the Atheros?

The Yun's OS (Linino) is based on OpenWRT, and the official toolchain from OpenWRT does not appear to have changed much. It could probably be done, the question is if you'd really want to though.
The limited resources (storage, RAM, CPU) means you would most likely not fit all the parts of the toolchain for C/C++ compilation (perhaps with the exception of very basic programs without many dependencies). The YUN's package manager (opkg) should contain pre-built packackes if they exist, but given that even the list of packages is only kept in RAM to conserve space, I doubt the entire toolchain with libraries needed to compile useful stuff would fit.
The official way to build things for OpenWRT appears to be cross-compilation on a much beefier machine, if only because it takes a fraction of the time needed by a native compiler. All in all, you're also very likely to save time and resources by cross-compiling and have more resources left on the YUN itself.

https://github.com/arduino/openwrt-yun


text:
Changing the brightness on a Hitachi HD44780 LCD screen
I am finishing up a project- an LED game alarm clock. Seeing as this is a clock, I need to have a way to conserve power, which right now my Uno R3+ is eating up like a politician. My question is, how do I turn the screen off, or turn the back-light off using software only on a Hitachi HD44780 16x2 LCD screen? Or how do I set a sleep mode on one component? The way I plan on turning it off is with an ultrasonic range finder, if I get close it turns on the screen. If anything I say doesn't make sense, ask me to clarify, I'm in a bit of a rush.

Whether this can even be done is entirely dependent on how you have the LCD screen connected. The HD44780 command set has no provisions for backlight control. You would need to add some external mechanism of your own for controlling the backlight.

Place a transistor in series with a 33R resistor between the LCD pin 16 (backlight ground) and GND and switch the transistor on and off with a digital pin. That way you'll be able to turn the backlight on and off.
You can have a finer control over brightness if you put a PWM pulse on said pin. Just call analogWrite(D3, value) where value is the desired brightness.
The schematics is below. It's from Freetronics 16x2 LCD SHield.

+1 for the schematic, although I'm not sure why there are two resistors (R7 & R8).

@Madivad - I'm guessing it's to increase maximum dissipated power that the resistors can take. The two 68R resistors in parallel result in an equivalent 34R resistence but doubles the maximum power that can be dissipated through a single resistor. I don't remember what resistors were recommended by Freetronics, but in my case, I've used two 1/4W 68R resistors and the board is working ok. Also, I suppose that 68R resistors are more common. That certainly holds true for me as I have plenty of 68R resistors in my bins and no 33R ones.

I know this is "old", but hope someone will notice this... I'm having trouble understanding how the transistor connects (as i'm not familiar with the icon above for the transistor), where does the E, B, C connect to?

@wara -  That's a Field Effect Transistor (FET), not a BJT. So you'll be looking to connect its drain, source and gate. In any case, you'll get better help by asking a separate question, linking to this one.

Instead of tying the backlight directly to V+ and GND, connect it to a PWM pin (you may need to use a separate driver if the pin cannot source/sink enough current). This will allow you to control the brightness via analogWrite().
Turn the LCD display off (LiquidCrystal::noDisplay()) when not actively in use. The contents will remain in memory but the LCD segments will not be driven.
Set the various bits in the PRR register to disable any peripherals not it use.
And don't forget to sleep the CPU when it doesn't need to run. See the "Power Management and Sleep Modes" section of the datasheet for more information about this and the PRR register, as well as the <avr/sleep.h> documentation for AVR Libc.

Sleeping the MCU is pointless, since the rest of the parts on a common uno consume so much power it doesn't provide any meaningful reduction in overall consumption..

Really, if you want to actually get an arduino to be low-power, you need an arduino pro (or any other board with no onboard usb-serial), and then you'd need to put a regulator with decently low quiescent current draw on it. It's a bit involved.

Absolutely. Someone that wants to conserve every last bit of energy will design their own board and spec their components out accordingly.

Yep, but my point is that you can't even get meaningfully relevant power conservation on most any arduino boards, since even their vregs have horrible quiescent current (2 ma +, IIRC). Then there is the FTDI/ATmega16U2, which you can't turn off, etc....

@Mr.Floppy: IOW, pick something else. Something with fewer pieces.

@ConnorWolf Well, if you do actually measure the rail current of an Uno running the delay-based blink sketch vs a rewrite of the same based on timer interrupts and properly deep sleeping — you'll see that sleeping the MCU is not so pointless. In my case, the numbers were something like 30 mA vs 17 mA. Still quite a drain; but your point has been invalidated by an experiment.

43% is... less terrible, but still not great.


text:
Which type of Motor Drivers to drive Unipolar Stepper Motors?
I hope this question is specific enough. Basically I want to know if it matters a great deal what kind of Motor Driver IC(s) or pre-assembled kits you use to drive a Unipolar Stepper Motor.
For example: Can the following Driver be used to control this Stepper Motor?
Driver: https://www.sparkfun.com/products/9670
Motor: http://www.jaycar.com.au/productView.asp?ID=YM2754
Thanks!

You can abuse a L298 (like the one you link) to drive unipolar motors, but it's not the ideal tool for it. Really, you just need power transistors. Or get a bipolar motor.

Even if in this forum people may know and help, maybe you should try also in a more specific one, e.g.: http://electronics.stackexchange.com/ as this question is in fact not related at all with arduino

We already have a 12VDC Unipolar Stepper Motor as mentioned in the Question. This is specifically about Arduino-like boards and Stepper motor drivers.

It does matter.  There are pros and cons to each different driver setup.
If you wire the motor as a bipolar, which I'm not sure that you can, you can use the driver that you linked, but it is not very good for driving stepper motors.  https://www.sparkfun.com/products/11876 is a better driver for steppers for half the price.  (still have to wire it bipolar)
If you need to stick with unipolar wiring, PCBheaven.com shows an example using a CD4017, MOSFETs, and diodes to run a unipolar motor.  It will only turn one direction.  Instead you could use a micro-controller, such as an Arduino, in place of the CD4017 along with logic-level MOSFETs to go both directions.
A tutorial on the Arduino site uses a ULN2003A, which is not powerful enough to drive your motor to its full potential (does it need to turn, or turn well?) and doesn't have the diodes (important to protect your IC!), but the Arduino sketches would still work using the schematic from PCBheaven.
A couple of complete driver boards:
UNIPOLAR STEPPER MOTOR DRIVER
FANCY UNIPOLAR STEPPER MOTOR DRIVER

If you could add links to suitable pre-built Unipolar drivers that can be purchased I'll accept this. Finding any has proven difficult at best -- most are bipolar or micro-stepping drivers :/

I have edited my answer.  The first stepper I bought was a really cheap unipolar.  I learned many things by goofing around with it!  Then, when I was ready, I found a good bipolar driver/motor combination that is much more fun to play with. :)

A minor correction: The ULN2003A has the diodes built in.


text:
Which shield to use for GPRS?
I'm planning to build a device that would read some sensor data and send it via GPRS, eg. once per day. (Not that original, yeah.) But my problem is choosing a GSM/GPRS shield.
The official shield has a nice interface for doing an HTTP POST/GET. OTOH, the shield seems to be sold out (and would be quite expensive anyway).
There seem to be other shields available, but their code examples tend to look quite hacky: the device waits for an arbitrary moment and then hopes that the server is done. That's IMO both inefficient or unreliable.
My question: which GSM/GPRS shield would you recommend, with these features:
a sane library w/ examples, such as the official onean external antennabonus: a competitive priceanother bonus: hopefully a "real" shield, so no soldering required and a few pins still easily usable for the sensors.

I ended up ordering an Elechouse board which uses the M10 chip. Found one on eBay for 59 USD. It appears to work fine with the official library.
As the manual says, it must be given external power - the USB cable isn't enough!

did you find the elechouse board reliable, does it send/receive gprs ok?

Is 2G supported in your country? At least in europe there are plans to switch off the 2G network and the module you chosen does not support 3G

I would recommend the official Arduino GSM shield.

Which one do you recommend? Care to elaborate?

Arduino GSM shield. I am using this, Its working fine and its a official Arduino shield.

Sadly the official Arduino GSM shield is now discontinued.

That library should work with pretty much anything that has the M10 module on it.
I only have experience with the SIM900 modules. Found the cheapest one on EBay.
While interfacing with these things can be a challenge at first, you really just need to read the manual for all the AT commands and execute them. I've written a couple of functions that may help:
Note: you may safely replace all instances of DEBUG_PRINT and DEBUG_PRINTLN with Serial.print and Serial.println.
SoftwareSerial SIM900(7, 8);

/*
    Sends AT commands to SIM900 module.

    Parameter   Description
    command     String containing the AT command to send to the module
    timeout     A timeout, in milliseconds, to wait for the response

    Returns a string containing the response. Returns NULL on timeout.

*/
String SIMCommunication::sendCommand(String command, int timeout) {
    SIM900.listen();
    // Clear read buffer before sending new command
    while(SIM900.available()) { SIM900.read(); }

    SIM900.println(command);

    if (responseTimedOut(timeout)) {
        DEBUG_PRINT(F("sendCommand Timed Out: "));DEBUG_PRINTLN(command);
        return NULL;
    }

    String response = "";

    while(SIM900.available()) {
        response.concat((char)SIM900.read());
        delayMicroseconds(500);
    }

    return response;
}

/*
    Waits for a response from SIM900 for <ms> milliseconds

    Returns true if timed out without response. False otherwise.
*/
bool SIMCommunication::responseTimedOut(int ms) {
    SIM900.listen();

    int counter = 0;
    while(!SIM900.available() && counter < ms) {
        counter++;
        delay(1);
    }

    // Timed out, return null
    if (counter >= ms) {
        return true;
    }
    counter = 0;
    return false;
}

LinkitOne - ok not a shield but rather a compatible Arduino controller board with built-in GSM/GPRS/GPS/Wifi. comms library doesn't have as many diagnostic methods as e.g. the Adafruit one, but it was easy to setup and reliable. Main downside of the LinkitOne was that it uses a different processor from Arduinos so many of the Arduino libraries aren't compatible e.g. for I2C devices.
Adafruit Fona SIM808 2G Shield version. shield layout but stackable headers have to be bought and soldered seperately. Default pinouts work with Uno, but mods required for Mega. Library has lots of handy diagnostic methods (battery voltage, signal strength, etc). worked with giffgaff prepaid SIM but not vodafone for some reason. SMS worked ok. I could connect to GPRS but getting html from a website didnt' work.
DFRobot SIM808 GPS/GPRS/GSM Shield - Pre wired wirth stackable shield connectors, instructions to upload code and run the device are convoluted and vague. I Wasn't even able to get a basic connection to the Arduino to work. Either the library is very buggy or my device was faulty.
SEEEDStudio 113030009 GPRS Shield with Antenna and External SIM Holder V3.0 I'll probably tets this next..
Official Arduino GSM board DISCONTINUED
Sparkfun GSM/GPRS Module - SM5100B DISCONTINUED


text:
How to detect if running Arduino or bare Atmega328p?
I'm building something that will mostly run on bare ATmega328p at 8 MHz (as described eg. here), but sometimes I need to run the same code on an Arduino.
I need to initialize the DHT library depending on the clock frequency. For simplicity, I'd rather detect the running environment runtime, in the program itself.
So, is there a straightforward way to detect the clock speed (from fuses?) or some other difference between a stock UNO board and a bare ATmega328p using the internal 8 MHz clock?

Actually one thing I want this for is to test how the clock frequency (among other things) affects the RF range.

is F_CPU set? im wondering if you can read that

Bare vs Stock is nearly impossible to detect at compile time. Where it depends on what you think you are trying to determine versus detect.
The best I can think of is creating a different Board definition; one for your bare and the other being the stock (i.g. UNO). Where now in IDE 1.5 see github.com/arduino/Arduino/wiki/… the parameter uno.build.board=AVR_UNO, which provides is used to set a compile-time variable ARDUINO_{build.board} to allow use of conditional code between #ifdefs. So you can create bare board definition with e.g. bare.build.board=MY_BARE and then have some #ifdef's for ARDUINO_MY_BARE
Otherwise wrap some #ifdef's around F_CPU as @sechleen points out. This is viable and done often in the core libraries.

The easiest way to distinguish your bare AVR from the arduino board at run time is to build the bare AVR board with a distinguishing feature - such as a known
voltage on one of the D/A ports - that won't be present on your Arduino.


text:
Extract .hex from ATtiny45 using Arduino
As it is possible to program a ATtiny45 using Arduino as ISP Programmer, is there a way to backup an ATtiny45 program to a .hex file using Arduino?

You'll have to use the commandline for that. Inside the arduino program folder there is another executable called avrdude. You need to call something like avrdude -pattiny45 -cstk500v1 -Uflash:r:filename.hex:i

Assuming the lock bits on the device haven't been set, sure. Simply prepare the Arduino for ArduinoISP, hook up the ATtiny45, and perform a read using AVRDUDE instead of a write (-U flash:r:foo.hex:i).

Sorry, totally missed your mention of that.


text:
Powering Arduino with 110v and controlling relay
I've found a lot of tutorials about how to use an Arduino to control power supplies to lamps and things like that using a relay. However, I also need to power the Arduino with the same power that is going through the relay.
In other words, I'd like to be able to plug my device into the wall. The device would use the 110VAC to power the Arduino. My device would also have some outlets that I could plug something into. The Arduino would be connected to a relay and would decide when to enable electricity to the outlet. The important part being that I would like everything to be on one power source.
Do I need to have a step down converter to transform the power, in addition to the relay? Is there some sort of break out board that has both of these functionalities in one board? What is the best way to do this?

In these cases where power must come from mains, my preferred solution is to buy a cheap phone charger+usb cable from ebay. They are sealed and safer than do-it-yourself solutions. The power adapter is barely larger than a normal plug for mains.
If you absolutely need to reach the arduino with only one cable, you can still use the solution i gave, only use a power cord to reach the contraption, then use a socket expander for mains and very short usb cable.

I hope I'm not misunderstanding this. I think that would be a great solution to just power the arduino and I do that already. However, I also need to use the power from the mains to also run through the relays so that it can power anything that is plugged into it. One cable going in to power the arduino and one outlet going out that a regular plug can be plugged into.

My proposal is the following.
Use a box for the contraption - it deals with voltage levels that can be fatal, so it should be boxed anyway. Have a power cord going inside the box. Inside the box have a socket splitter (I don't know about where you leave, but at least in several countries in Europe they are pretty common). In one of the 2 sockets plug the phone charger, to power the arduino over usb. Use a relay shield on the Arduino. In the other mains socket, plug a power cord, going out of the box, through the relay. I't not optimized for space, but it should be pretty safe and sturdy.

And relatively cheap. I am not aware of shields that would be both power supplier and relay.

That's perfect!! Thank you so much for the help!


text:
How can I convert Arduino String to C string type?
I got a String which as I understand is an Arduino object, and got some C++ code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <string.h>

LiquidCrystal_I2C lcd(0x20,16,2);

boolean borrar = false;
String IP;

void setup()
{
  lcd.init();
  lcd.backlight();
  pinMode(13,OUTPUT);
  Serial.begin(9600);
  Serial1.begin(9600);

}

void loop() {

  while (Serial1.available()) {

    char caracter = Serial1.read(); //Comprobamos el caracter

    switch(caracter) {

    default:
                if (borrar) {
                              IP = "";
                              lcd.clear();
                }

                lcd.print(caracter);
                delay(125);
                borrar = false;

                IP.concat(caracter);
                break;

    case '\r':
    case 0x0F:
    case 0x0A:

                String res = "";
                borrar = true;
                int num= atoi(IP.c_str());
                if (num < 127)
                  res="Clase A";
                if (num == 127)
                  res="Direccion reservada";
                if (num > 127 && num < 192)
                  res="Clase B ";
                if (num >= 192 && num < 224)
                  res="Clase C ";
                if (num >= 224 && num < 240)
                  res="Clase D ";
                if (num >= 240 && num < 255)
                  res="Clase E ";
                break;

  } //fin switch

}//serial disponible

}//fin programa

However, this won't compile because of this line:
int num= atoi(IP.c_str())

As IP is a String and such method works for string. How can I make it compatible (convert it)?

Your code could be improved by removing the use of IP string altogether, and directly calculating its numeric value while characters come in through Serial1:
...
boolean borrar = false;
int IP = 0;
...

void loop() {
  while (Serial1.available()) {
    char caracter = Serial1.read(); //Comprobamos el caracter
    switch(caracter) {

    // NOTE it is better to replace default by the list of all digits...
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
                if (borrar) {
                              IP = 0;
                              lcd.clear();
                }

                lcd.print(caracter);
                delay(125);
                borrar = false;

                IP *= 10;
                IP += (int) (caracter - '0');
                break;

    case '\r':
    case 0x0F:
    case 0x0A:

                String res = "";
                borrar = true;
                int num= IP;
                if (num < 127)
                  res="Clase A";
                if (num == 127)
                  res="Direccion reservada";
                if (num > 127 && num < 192)
                  res="Clase B ";
                if (num >= 192 && num < 224)
                  res="Clase C ";
                if (num >= 224 && num < 240)
                  res="Clase D ";
                if (num >= 240 && num < 255)
                  res="Clase E ";
                break;

  } //fin switch

}//serial disponible

}//fin programa

This way would bring you 2 advantages:

a bit faster than working with String
no dynamic memory allocation/deallocation (String does a lot of these) which might lead your program to heap fragmentation and eventually crash.

Note that I have not further refactored your code as I guessed it was just a snippet, not the complete code for your program. Otherwise, I would have performed further refinement like:

remove num variable since it is the same as IP now
replace res from String to const char* (to further reduce heap fragmentation due to String usage)

Try
unsigned char z[100];
IP.getBytes(z, 100);
z[IP.length()] = 0;
int n = atoi(z);

To retrieve bytes inside the string. This assumes IP string's length is shorter than 100.

I tried and got:
BluetoothLCD.cpp:51:35: error: invalid conversion from ‘char*’ to ‘unsigned char*’ BluetoothLCD.cpp:51:35: error:   initializing argument 1 of ‘void String::getBytes(unsigned char*, unsigned int, unsigned int) const’

I have updated char to unsigned char

Something weird is going on, now I obtain:
BluetoothLCD.cpp:53:33: error: invalid conversion from ‘unsigned char*’ to ‘const char*’ BluetoothLCD.cpp:53:33: error:   initializing argument 1 of ‘int atoi(const char*)’

If it does not support, IP.toCharArray(z, 100); may be used.

How would code look like?

God, I think its done NOW

Try updating to the latest version of the Arduino libraries/IDE.
The c_str() method was introduced to the Arduino String class quite recently, I believe. That line of code certainly works fine for me on Arduino IDE 1.0.5.

I'm using Linux IDE how would I do it?

@diegoaguilar - I think you'd have to manually update your Arduino core libraries. You can get them from GitHub: https://github.com/arduino/Arduino

Version 1.0.5 has c_str() it can be downloaded for linux from the official Arduino site: http://arduino.cc/en/Main/Software


text:
How to catch the Enter key received by Bluetooth?
I got some code to receive characters from Bluetooth and code and print it back to the LCD display.
However, want to detect the Enter character to be the input signal, in other words, not to print nothing to the display until Enter is pressed.
An strange character is shown at display for Enter but I can't catch it.
This is my code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x20,16,2);

void setup()
{
  lcd.init();
  lcd.backlight();
  pinMode(13,OUTPUT);
  Serial.begin(9600);
  Serial1.begin(9600);

}

void loop()
{

  while (Serial1.available())
  {
    char dato= Serial1.read(); //Comprobamos el dato

     lcd.print(dato);

    switch(dato) {
    case '#':
      Serial.println("GATO...");
    break;
    case 'e':  digitalWrite(13,LOW);

    Serial1.println("Led apagado");
    break;
      case 'r':
      digitalWrite(13,HIGH); delay(200);
      digitalWrite(13,LOW); delay(200);

      Serial1.println("Led intermitente");
      break;
  } //fin switch

}//serial disponible

}//fin programa

How is this related to bluetooth?

It depends on what the enter key sends. It may be just CR (carriage return), LF (line feed), or both. You can check the ASCII table for the hex values for those characters.
LF is 0x0A and CR is 0x0D. Those are the characters you're looking for, you can add a if for these cases in order to guard the call to lcd.print(dato):
char dato= Serial1.read(); //Comprobamos el dato
if (dato != 0x0A && dato != 0x0F)
    lcd.print(dato);

I would use '\n' and '\r' instead of the ascii- if ( dato != '\n' && dato != '\r' ) ...

@imjosh yeah that's more readable.


text:
Matching Baud Rates
So I am working on speeding up a nixie tube speedometer, in this question: , but this brought up another question.  Would having matching baud rates for multiple external devices speed up processes.
In the case of the other question the OBD-II device is running at 38400 where the Nixie Tubes are running at 9600.  Since I'm taking the info from the OBD-II connector and doing a little math and sending it to the Nixie Tubes, would it be beneficial to have the same baud rate for both devices?
Now... before you down-vote this question for making some sort of "duplicate" this also answers a question about having a "master" serial hub and having communication between different "slave" serial devices.

It all depends on how often speed is being reported via the OBD-II connection. If the report rate is faster than the update rate of the tubes then yes, increasing the speed of the tube circuit (not necessarily the connection itself) can have an effect (as long as the tubes themselves can keep up, of course). If the speed is being reported slower than the tubes then don't bother unless you have other reasons for increasing it, since both bit rates are already so much faster than the human mind can see, much less process.

If you are using different serial ports for each device (eg: using software serial for at least one of them on a Uno, or using separate hardware serial on a Mega2560), then it really doesn't matter whether they use the same baud rate or not.
If you are somehow multiplexing the same serial port (eg: input only from one device, output only to the other; or some external multiplexing hardware) then there might be a slight gain in not needing to change the baud rate when switching between devices, but probably not noticable.
If either or both devices have some option to communicate faster, that might speed up your system - independent of whether they use the SAME rate.


text:
Seeed Studio motor shield
My goal is to have my Arduino fire two stepper motors.  They need not be simultaneous. I'm using an Arduino Uno with 2 motor shields - specifically, the Seeed Studio Motor Shield v1.0. I know this shield uses D8-13.
Question is, how can I get the Arduino to use both shields?  Is there a way to make one of the shields take D0-D7?  If I could do that that'd be great. As far as I can tell, there's no way. The motor shields cannot be physically mounted either.

Part of the problem is that you've picked a shield that uses the L298 and hence requires the Arduino to control the stepper in detail, and use much of the MCU time, and many signals, to do so. Other shields based on more sophisticated chips like A4988 or DRV8825, only require the Arduino to send Direction and Step signals, and one select line for each motor. See particularly the shields commonly used for 3D printer control, if you have an Arduino Mega, or smaller ones (eg: DF Robot DRI0023). (But note differing current capabilities.)

SoFly, thanks, but for some reason stepper #2 is not responding when i "connect" it to pins 2-7.  for code please see my comment to Karl B. below

Some shields let you use jumpers or something to change the pin assignments, but I don't believe the Seed motor shield does.  What you can use is a go-between shield between the two shields to remap the pins on the top shield.  Then in your code, you just initialize the second instance using different pins.  You just have to make sure the alternate pins have the features you need, like pwm.

Thanks! Tried effectively that by using breadboard. BUT, any motor shield thats connected to pins 2-7, which are PWM, output pins, won't work. Original Code below. I just subtracted 6 from each pin number to get pins 2-7. Why not working? Is the "~" sign next to pin 3,5,6,9,10 and 11 important?

#include <Stepper.h>
const int stepsPerRevolution = 340;
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8,11,12,13);
void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(60);
Serial.begin(9600);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
}
void loop() {
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(500);
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
delay(500);
}

Nevermind, I can't paste code into this window. Basically, it boils down to: Stepper myStepper(stepsPerRevolution, 8,11,12,13);      myStepper.setSpeed(60);      pinMode(9,OUTPUT);         pinMode(10,OUTPUT);         digitalWrite(9,HIGH);        digitalWrite(10,HIGH);


text:
Mega 2560 Doesn't Respond
When trying to upload to my Mega r2, it simply times out during uploading.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

I tried burning the bootloader, but that also gave an error.
Error while burning bootloader.
avrdude: usbdev_open(): did not find any USB device "usb"

I can see the arduino in my Devices and Printers in control panel, so I don't think the board is burnt.  The power light also is on.  Any ideas?

Right COM port and serial port selected?

@AnnonomusPenguin yep.

When you tried burning the bootloader, were you using an external programmer?

Your Arduino IDE (and the underlying avrdude inparticular) cannot communicate with the USB device on your Arduino. Your IDE is probably misconfigured, trying to access the wrong device. Mind you that device names can sometimes change, so you really want to double check how it is known to your system ,either in Device Manager (Windows), in dmesg (Linux), or similar on other platforms. On Linux/iOS you want to double check device permission settings.

Download the devel filter.exe file from this site. Install it and target your programmer (I assume you are programming via ISP if you're using avrdude)
http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.6.0/
This will eliminate the 'USB not found' problem.

I have seen this error numerous times before. I think the possibilities could be that either some external device is connected on RX, TX pins of arduino mega or mega is not getting sufficient power. Some connection from your board is trying to pull more than the limit current.
and off course the answers suggested above are also right. check out every possibility.

Check if you have selected the right board
Have you installed FTDI drivers? If you have installed them update them to the latest version. They can be found here (Also see http://arduino.cc/en/Guide/Howto)

If this doesn't work check if the device is getting recognized by the system by running:
dmesg | grep -i tty

If the device is not recognized then try using a different cable/USB port.
Just to make sure, check if the board is working properly by testing it on another computer.

If you uploaded a program that uses serial port too often you cannot upload program from arduino IDE. try to press reset button on mega2560 when you begin to upload program. Many times I solved like this.

When you try to upload a sketch do the Receive and/or Transmit lights on the Arduino blink?  If not you may not be getting serial communication.  Try a loopback test (connect D0 to D1 and see if stuff you type in Serial Monitor comes back as it should).
If not, go to My Computer>Properties>Device Manager and search for Ports(COM&LPT)>is there Arduino MEGA??? If not you have no drivers installed or they haven't been installed automaticly or your arduino is dead :)). If it is drivers you have to update them. In same Device Manager expand Other devices. There should be some Unknown devices. Update Mega drivers Update Driver Software, Browse my computer... and C:\...\arduino\drivers


text:
Arduino Yun does it have a RTC?
Does the Arduino Yun does it have a RTC?
And if so is it connected to the Atheros AR9331 or the ATmega32u4?
If there there is no RTC, can I connect a DS1307 to the Atheros AR9331?

the Yún doesn’t have a real time clock IC on board, so it can’t keep time when is powered off. Instead, it synchronizes with time servers automatically when it powers up and connects to a network using NTP.

(Arduino Blog)
Therefore, the Yun does not have a onboard RTC.

If there there is no RTC, can I connect a DS1307 to the Atheros AR9331?

Probably not. It comes in a LPCC package, which has the solder joints on the bottom. This needs to be soldered by reflow. The Yun does not have any pins connected directly to that chip. You're probably thinking of the ATmega32u4, the actual Arduino chip. The other one is for a router.
To get the time, you have two options:

Use the time from the time server
A few notes:

The Yún must be connected to a network to get the correct time. If you used the web-based WiFi interface to configure the Yún for the network, make sure you've selected the proper time zone.

Connect it to a DS1307 (I find this Adafruit tutorial helpful) You'll need only two pins to use this board. One note: there is a way to connect up to 121 I2C devices using these two pins. However, that gets a little more complicated.

I was thinking about putting some high level logic code on the Linux side and the a tight control loop on the ATMega. Therefore it would be logical to have the rtc close to the logic code.

What happens with your Arduino YUN is that it has an internal clock which sincronizes with a computer (at least this is what I do).
However I have read that it can be automatically but I could not do that; have you got a probable solution?

How is this a answer to the question?


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

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


text:
Arduino 1 can somehow support 32-bit audio?
I wanted to take the audio from a device such as the PC, insert it through different ADC in arduino, processing them with DSP and DAC REnter all through to the other speakers, reading here and there on the internet but some people were put in difficulty because Arduino has a data bus to 10 bits. What problems can cause this? I can not send the same 10 bits at a time, until you arrive at 32?

32 bit is high end audio electronics, don't expect to breadboard that with an Arduino at your desk at home. 16 bits is already a serious challenge, even in a professinal setting.

A processor can handle larger numbers one bit or word at a time, though you will soon hit the limit of the number of useful operations per second.  32 bits for a single audio channel is wasteful; limits of physics mean no circuit can be built without a noise level that would make many of them meaningless

First of all,what is the point of this? I'm afraid this is a XY question. You won't get that good of quality with Arduino. If you're hoping to create some sort of an amp, learn electronics and do that directly. Maybe you should just send data via serial.
Anyway, that aside, here's a chart I drew:

(Excuse my poor image alignment, PowerPoint was being a little mean today)
The bottom is all the "channels" the PC can send. The top is all the "channels" the Arduino can recieve. As you can see, there's a huge degradation in quality. Not to mention, I made this that 1 bit = 1 "channel," yet it's very much more than that.
A standard Arduino (Uno, Leonardo, etc.) has a 10 bit ADC that can read values 0-1023. The computer can output 0-4294967295! (It' exponentially grows due to permutations). You can see why I very much simplified my chart! :P
DSP won't really work well, unless you are trying to do some weird alien sounding modifications or a cheesy echo to. You probably will want to add an external 32 bit ADC. I would recommend, additionally, adding a Due or Galileo that can process 32 bit integers without emulating a bigger chip, thus greatly reducing performance and giving you a low framerate.
tl;dr: It'll work fine, but it'll have horrible sound quality. You can't send the same 10 bits until 32, since the computer changes that 32 bits into a voltage (sent to Arduino), and the Arduino translates that voltage into 10 bits.

The tl;dr is right on.  It's not a 10 bit data bus, it's a 10 bit ADC, so the additional bits go 'missing'  before your code ever sees them.  On the other hand, 10bit music might sound 4 times better than most chiptunes :)

@AShelly I'm pretty used to Bose products when I listen to music, so it sounds horrible IMHO :-)

thanks for your reply
I was talking to put an external buffer which "splits" the 32 bits into four groups of 10 and a buffer at the end that joins the 4 groups.
Or as you say, a 32-bit adc from outside, if I used it, arduino still could handle the computing power required to keep 4/5 digital filters together without any problems?

@Mario It really depends on what you're doing with the audio and how often you want to sample. If you don't mind sampling three times a second with external ADC and write directly after, you'll be fine. If you want to have 500 frames using a Uno and a 32 bit ADC and do complex computations, not so good. I'd recommend if you use a 32 bit ADC (not required, but significantly better quality), to use the Arduino Due since it has a 32 bit chip and a better architecture all around.

there is no such thing as a 32-bit adc!


text:
Cheapest way to connect android device to arduino wirelessly
I'm building a simple RC car which I want to control using android phone. The phone has bluetooth and Wi-Fi. My questions is what will be the cheapest way to connect the two devices at about 50-120m range? I have thought of the following:

Cheap bluetooth module (like this). Will this fit into my problem? What range I will archieve using this module.
Wi-fi module. I can set the android device to be "wi-fi hotspot", but the wi-fi shields are pretty expensive tho.

Any suggestions will be greatly appreciated.

Solution 1
If you don't want to change the coverage radius, sadly none of them would help you to achieve a coverage of 50m.
But if you are not using a camera feed and just want to control, I think RF transceiver would be best solution for you. But to implement this you mist connect an Arduino Mega ADK to your android device. Serially receive your directions to mega and then transmit the directions over RF transceiver.
Solution 2
If you are willing to change the coverage range to less than 15m, you can use Wi-Fi Module. This will also help you to get live camera feed from your RC car to your phone. Forget about Bluetooth module as they are slow, less range.
You can increase the coverage of Wi-Fi Module if you have a Wi-Fi AP with huge transmit power. As long as the module is able to receive the signal from AP, your car would do great.
P.S. :- Here is a cool tip. Record every turn instruction and the time after which it was given. When the signal from transmitter or AP is absent for more than a particular time, you can program the car to take a U-turn and reverse the directions. Your car will come home without any instruction.

a cool tip indeed :)

@Deamon if I get 2nd arduino board and attach a 443mhz(http://i.imgur.com/GjrvA2Q.png) tranceiver/transmitter, will I archieve my goal? I'm going to power the transmitter with 5V.

looks like its pair of transmitter and receiver. It would better to have a transceiver on both ends. This will help you to have a proper communication and acknowledgement process to implement. But if it satisfies your requirement, go ahead with it. Good luck.


text:
Raspberry pi -Arduino bridge
I am building a small wireless controlled robot using the Arduino and the raspberry pi. It works by the user wirelessly connecting through to the raspberry Pi (using vnc or some other form wirelessly) and using the user inputs to send a command to the Arduino which controls the motorised wheels. SO for example if the user presses the up button, a 'W" command is sent from the Raspberry Pi to the Arduino which then reads it and pushes the wheels forward.
I was looking to use one of the new Arduino-Raspberry Pi bridges to connect the two to make it easier to use, but I am not too familiar on how they work. Had a few question such as:
1) How exactly do they work (connection wise)?
2) is it possible to write one python code in the raspberry pi that when run can load the specific ino code into arduino?
3) which bridge would be the most suited for my project? (eg: Arduberry, alamode, gertduino, etc?)
Sorry really new to the raspberry pi and need to find a solution soon so any help would be awesome.
Cheers

1) How exactly do they work (connection wise)?

Physically they all sit on the GPIO sockets of the Pi, sitting on top of the pi. The Gertduino and AlaMode seem to have the same form factor as the Pi which makes them a little more appealing to me but I guess then is personal choice.
Communication appears to differ but it will use Serial, SPI or I2C. I would imagine that you'd be able to choose an alternate one but not read enough about them to know for sure. Serial appears to be fairly simple, and it would be easy to debug, however you might struggle if you wanted to receive data on the Pi without the communication being initiated by the Pi.  I2C would overcome this as you can run it in multi-master mode.

2) is it possible to write one python code in the raspberry pi that
  when run can load the specific ino code into arduino?

As you can call external programs with python I would say that even if you have to resort to this mechanism then it would be possible. You can turn on the debugging in the Arduino IDE to see what it actually does, then either script it or make the calls from your python program.

3) which bridge would be the most suited for my project? (eg:
  Arduberry, alamode, gertduino, etc?)

I'd go for either the gertduino or alamode purely on looks particularly the matched form factor.

Thanks Nick, this has been really helpful. I was really keen on buying the gertduino for that reason, but my lecturer gave me a arduberry to borrow for the project so probably will stick to that. Thanks again.

You're welcome, hope your project goes well.

Have you thought about using the Raspberry Pi to control the robot directly, instead of adding the complexity of having the Pi talk to the Arduino?
Python allows you to control the GPIO pins of the Pi, and as long as you connect a suitable motor driver (to protect your Pi), you should be fine.
If you want to connect the Pi to the Arduino, then you could also look at doing this using Serial communications and wouldn't need the complexity of a bridge - just need a logic-level converter to convert the 5V of the Arduino to the 3.3v of the Pi

Hey, that was exactly what I am doing atm but there are times when my robot goes over bumps and stuff and usb connections gets severed for a bit causing the whole robot to freeze which is why i was looking at these.


text:
Sending data from a GUI to an Arduino nano via USB
Can somebody point me in the right direction for information on sending data to an Arduino nano?
My project is to send data that is updated from a GUI (presently written in Python) to an Arduino nano that then makes adjustments to a number of servo motors.
I have the servo code working but am presently using potentiometers to control the servo positions & would like the control done via a GUI.
What libraries would I need to be looking at. Have any of you done anything similar.
Thanks
Nic

Arduino Nano supports FTDI i.e. Virtual Serial Port. So all you have to do is initialize the serial communication using pySerial.
When the data is entered into the GUI, store it in some variables. Send the data in variables to Arduino using Serial Communication. You might have design your own communication protocol on top of Virtual Serial Port in order to identify the data.
You can also use the same library to send the acknowledgement or some data from Arduino to PC, if you want.
Hope this helps you.


text:
How to convert frequency into db
I have made an Arduino circuit which outputs in terms of frequency(hz) and I need output in terms of db as well
So is there any formula which can I apply to convert frequency hertz to db or is there any reference link to understand the conversion process.
Any help will be highly appreciated

Sad to see both answers reversed the required capitalization of "dB"

My answer was written on my tablet that capitalises the first letter of a sentence for you automatically. Too much haastle to change it for just one symbol...  however the question doesn't have any capitalization, correct or otherwise ;)

dB is volume (sound pressure), frequency is pitch. The two are entirely different concepts and can't be converted. A bit like you can't convert the roundness of a doughnut into blue. Roundness and blueness (it has blueberries in it by the way) are two different properties of the doughnut.

dB it self just express in a logarithmic scale a ratio between two values and it self is unit independent (because is a ratio). Just because the most common uses of dB scales are linked to intensity or power doesn't necessarily mean that can't be used to represent other ratios of different types of quantities. Or at least I couldn't find any definition that restricts the use of dB in such cases. The formulas to express such ratio are present here you just have to figured it out what is really your ratio.
So, for example, if you have some kind of sensor that somehow the output is a frequency, let's say something like
f(x) = ax + f0  [Hz]

There is no reason why you can't express this function in a logarithmic ratio scale using dB something like, related to f0 or f(x=0)
L(x) = 10*Log10*(f(x)/f0) [dB]

which would give you the represented dB output of your equation with respect to x.
But since we are in arduino stackexchange and talking about sensor, the common use of dB in electronics is the representation of power ratio or (the more common) a frequency response of a circuit(or system) that is represented by a Bode Plot, so I advise you to really take a good look at both links and try to figure what you really are asked to represent.

Great answer! Not many would have thought about the real definition of dB.

Decibels (Db) are calculated using amplitudes and by definition decibels are the measurement of sound intensity or power level of electrical signal by comparing it with a given level on a logarithmic scale, which is independent of frequency.
You can measure the decibels though if you know the amplitude of your source which i'm guessing is ~5v .


text:
Arduino C++ library syntax
I am looking at modifying the H3LI331DL I2C library posted by Seed Studio for communicating with the H3LI331DL accelerometer. The library hardcodes the address for the accelerometer in the header file. My end goal is to make the library require a slave address input argument so I can talk to 2 accelerometers on the same I2C bus. The chip has a pin that sets the LSB of its address.
Now onto the question. The library's .h file has the following statement:
#define H3LIS331DL_MEMS_I2C_ADDRESS     0x18//0x32
Is the 0x32 simply commented out or am I missing something here?
Thanks,
Emach

It is indeed commented out. SeeedStudio is a great company but their code (including code prettifying) is pretty sloppy, and sometimes a little dumbfounding.


text:
Control RGB led using microphones, getting the right components
Sorry if this is too basic, but I am very new to arduino and electronics. I come from programming, I am trying to start a project where I can control an RGB led strip, I want to be able to control the light intensity and color of the light strip (something like this), using a microphone.
My goal is for frequency to control de color of the rgb light and the dB (Volume) to control the light intensity. I have found several microphones such as this ones. Can I get both frequency and dB input from this microphones?
Would I need some extra controllers for this project? Again I am very new with this, sorry by the basic questions.

It would be well worth having a look at ColorChord.

You are taking on two Arduino projects at the same time (controlling addressable RGB LED strips & frequency discrimination using a microphone).  Judging from past posts here, it would be better if you tried one of your projects first, then post questions about that project before moving on to the to the second.  For instance, many people fail at the RGB LED light strips because of unexpected power supply problems.  And, I am not entirely sure a Arduino Uno can do a good jobs at frequency discrimination.  I do not think it is fast enough to do a good job.

Thanks @st2000, I will do it that way in the future, if an Arduino-uno is too slow for that would you recommend something else?

@MarkSmith are you the creator of that program? can I contact you if I have questions about it's use?

When starting Arduino hacking I find it always best to find someone who's done it before.  @MarkSmith has found you the perfect example project.  I would research it to find out what hardware ColorChord uses.  And don't stop at the GIT web page, the ColorChord guy (I think Charles is his name) had made several YouTube.com videos the show off his work.

@MarkSmith you should flesh out your comment and make it the answer.  Derek, you should accept his answer and complete this question / answer entry into the arduino stackexchange website.

No, I'm afraid I'm not the creator. As @st2000 says, the guy who is has some fascinating projects - I've wasted, er, spent hours watching his youTube stuff. Really worth diving into. ColorChord uses an ESP8266 which is a great little device.

It would be worth checking out the ColorChord project.  It runs on an ESP8266, not an Arduino, but it ought to get you going.


text:
Using a 12V DC adapter to power Arduino nano, 12v Solenoid and an Hygrometer
First of all I am very novice in electronics so bare with me.
I am trying to make a self watering system using arduino nano, first I tried the fly fish hygrometer module with the 5V power of the Arduino, and that worked.
Then I wanted to add the 12V solenoid, so I changed to a 12V external power through the Vin.
My goal is to use only one power source.
This is what I have done so far:

And Schematics
My question is:
Can I power the hygrometer module using for the positive the 5V outlet of the Arduino nano and the ground from the 12V power source as shown in the figures?
Or will this burn the module or screw the readings?

yes the 5v out can run the module (hygrometers use next to nothing), although 12v is a little high for the nano, might get warm. but no worries, she'll be alright mate.

Thanks @dandavis, but my question is that if you see the schematics, the + of the hygro goes to the 5v and the ground goes to the 12V is that ok?

you mean 0v? that's fine, all grounds are typically commoned (connected together so they have continuity)


text:
When to use PROGMEM?
I believe PROGMEM is used to store large data (e.g. strings) that don't change. So it frees up the SRAM.
in the Ardunio Reference it is mentioned that.
"Using PROGMEM is also a two-step procedure. After getting the data into Flash memory, it requires special methods (functions), also defined in the pgmspace.h library, to read the data from program memory back into SRAM, so we can do something useful with it."
If I have to load the data into SRAM before using it then how is it efficient than directly stroing into SRAM by defining vaiable normally

... Because it doesn't stay in SRAM...

Say you have a string of 1000 characters in Flash, and you want to print it to Serial.  Yes, you need to load it into RAM in order to pass that data around the place for printing. But, do you need to put all of it in RAM at once?  No.  You only need one character at a time.  So instead of taking 1000 characters and allocating 1000 bytes of RAM and copying the whole shebang into RAM then printing it, you just need to allocate 1 byte of RAM* and copy each character in turn and print it.
Since you can only read one character at a time from flash there's no advantage in reading the whole lot anyway.

*Actually, because of compiler optimizations, this probably never even touches RAM and just stays in a CPU register.

If you have a constant c-string (char array) in your code without F macro or progmem, then the string is copied into RAM at start an stays there.
If in a function you use the F macro or you create a char buffer of some size and copy the progmem string into the buffer, on function return the variables are deleted from stack and the memory is released.
In case of some big array, if you put it into progmem and then in the code when you need to lookup a value in that array, you need to copy to RAM only one array item at time not the whole array.

Like Majenko said, you do not need to put everything you have in flash storage into RAM at once.  You can move items into SRAM as necessary, and reuse the memory once you're done.
However, you are not limited to moving one byte at a time.  There are functions defined in avr/pgmspace.h that can handle moving data for you.
For instance, you could do something like:
const struct mystruct_s my_value PROGMEM = { value = 1234 };

// ...

struct mystruct_s working_copy;
memcpy_P(&working_copy, &my_value, sizeof(struct mystruct_s));
int foo = working_copy.value / 2;

At the expense of using more RAM. Even if on the stack it may be too much (worst case).

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


text:
SocketIO Arduino TCP Port ISSUE
Initially I was sending sensor data to NodeJS using socketIO and this worked perfectly. I had to add a function to control an RGB LED using this. This also works but I'm unable to perform these two functions simultaneously.
I have tried to use two different ports on my Arduino. One to send data and another to control the LED but one overrides the other.
Question: Is there a way around this ? Is it practical to use two different ports?
arduino sketch
if (client.connect(server, 4000)) {
    Serial.println("connected");
  }
  else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }

  pinMode(pin, OUTPUT);
}

void loop()
{

  //if you are connected and data is available
  if (client.available()) {
    char c = client.read();
   // Serial.print("Message is :  ");
    Serial.print(c);

    // '1' was received, return '1' for HIGH
    if (c == '1') {
      pinVal = HIGH;
    //  client.print("ON");
    }
    else if (c == '0') {
      pinVal = LOW;
    //  client.print("OFF");
    }

    //turn led pin to new position
    digitalWrite(pin, pinVal);

  }

int chk = DHT.read11(DHT11_PIN);
  int t = DHT.temperature;
  int h = DHT.humidity;

          // send data to the server
        sendData(t, h);

  Serial.print("Temperature = ");
  Serial.print(t);
  Serial.print( "," );
  Serial.print("Humidity = ");
  Serial.print(h);
  Serial.print("\n");
   delay(6000);

}

void sendData(int temperature, int humidity)
{
  if(!client.connected())
  {
    if (client.connect(server, 3000)) {

      Serial.println("Sending data...");
      // send the HTTP PUT request:
      client.print("GET /weatherserver/");
      client.print(temperature);
      client.print("/");
      client.print(humidity);
      client.print("/");

      client.println(" HTTP/1.1");
      client.println("Host: localhost");
      client.println("User-Agent: arduino-barom");
      client.println("Connection: close");
      client.println();
      client.stop();
    } else {
       Serial.println("Could not connect.");
       client.stop();
    }
  }
  delay(6000);
}

I'm not sure what you are doing, but you seem to be using two different protocols on two different ports.  So does you server side code open two ports? and does it accept the two different protocols?
If I was you I would change the RGB control to use REST (like you are doing with the DHT)  So you would send something like GET /RGB/<id>/<state>.
I'm not sure how your temperature is arriving at the server since you have sent a GET command rather than a PUT command (this could be the bug you are looking for).

Thanks for responding. This is how i'm sending my temperature to my server. However you're right I am using two different protocols on two different ports. My server accepts two ports perfectly. But my Arduino doesn't initiate both connections. From my server side i'm sending my commands to the LED using a TCP protocol. Do you think if I change this I can achieve my goal? Do know if any documentation that shows how I can implement this?

I'm trying to implement you solution you suggested. I really can't find anything to help. Would you be kind to show me a link that could guide me?

This page explains what to do, it has all the code you want, but it is not doing exactly what you want, it should help you understand though.  https://learn.adafruit.com/a-rest-api-for-arduino-and-the-cc3000-wifi-chip/overview I don't know if you can open two sockets, but even if you can I don't think the temperature will work because you are using GET, you should use PUT, you'll understand why when you read the link.

Thanks Matt! I believe I mentioned in my post that I'm using NodeJS. However your solution isn't related to the NodeJS platform. That being said, I thank you for taking your time to help. I was able to find a better solution.

I implemented a better solution differentiating the client as EthernetClient clientA & EthernetClient clientB

Client A handles TCP port and Client B handles HTTP GET Request.


text:
Multiple SoftwareSerial ports - how to handle the limitations
I am building an access control project which uses two SoftwareSerial ports. One will be used for communication with an RFID reader and another one to receive serial messages via an Xbee (e.g. remote commands). The hardware serial port is used for a cabled serial connection to another remote "server"-Arduino, which then actuates the relays.
According to the Arduino website, the SoftwareSerial Library has, amongst others, the following limitation:  - "If using multiple software serial ports, only one can receive data at a time."
My plan is to poll constantly / on regular intervals both SoftwareSerial ports, e.g. by checking RFID_Serial.available() and XBeeSerial.available(), and if it turns out that data is available, to read it out and parse it accordingly. This obviouosly has to be done in an alternating fashion, i.e. one after the other. My questions are the following.
(1) Can I initialise the ports in void setup()
RFID_Serial.begin(..);
XBeeSerial.begin(..);
... and are they then both actually active simultaneously (i.e. ready for commans like xxxxSerial.available(), or xxxxSerial.read(), or is in this case only the XBeeSerial active, because I it was the last one to be initialised?
(2) If I want to poll one after the other, do I have to "close" one SoftwareSerial port, e.g. by RFID_Serial.end(); and open the other (XbeeSerial.begin(..)) before I can do XBeeSerial.available() or read out by XBeeSerial.read()?

softwareSerial uses interrupts (rather than hardware) to acquire data. Because you cannot run two interrupts at the same time, 2 software serials' cannot receive both at the same time. I'm listing some options below.

Take a gamble. Hope they won't occure on the same time (bad idea)
Manage the flow. Make the other device not send data while one is sending. (Maybe impossible)
Check the priorities, make the XBee's priority vector lower as the RFID, and when you do not get a full/known RFID key, give feedback (with a light/buzzer) so the person will try his RFID key again.

You might want to use the XBEE with the hardware serial. And use the RFID on software serial. IF you're not receiving a lot from the master (since you only send the master which relays he has to actuate?) Why would you actually use two arduino's? The "slave" could, itself, actuate the relays?

@FuaZe: Thanks for your comments. Well, even if both, the RFID and the Xbee generate (the RFID)/receive (the Xbee) data at the same time, is it really a problem, because doesn't the data remain in the respective buffer until it gets read out during the next polling?

@Fuaze: There are several reasons why I use two arduinos. I have a limited number of available wires (3) between the slave and the master and I need a two-way communication. The master actuates three relays (door and two alarm systems), and needs to send the status to the slave, which, upon activation through the RFID tag, displays the status of the alarm system (on/off). The activation of the unit also activates three buttons to toggle the three relays.

The problem is that those buffers are filled by software, and your arduino can only do one software task at once (generally). So if two things send info to your arduino at the same time, there will be a problem. But you're explaining that the master sends the status after an RFID tag? So these van be two software serials as it's not on the same time?


text:
What pins to use to externally power an Arduino Fio (without battery)
I need to power an enclosed Arduino Fio project with 12V. The intention is not to attach a battery because there is no need as this is a fixed installation with a 12V DC available (for a pair of relays which will be controlled by the Fio).
My question is what Pins should I use. The Fio page (https://www.arduino.cc/en/Main/ArduinoBoardFio) on the Arduino web site says...
Input Voltage   3.35 -12 V
Input Voltage for Charge    3.7 - 7 V
Unfortunately, there is no indication what pins these specs refer to. I assume that the "Input Voltage for Charge" refers to the mini-USB port and unlike other Arduino boards, there is no Vin pin to supply the board externally. Looking at the board layout on the same web page, I think the only possible option is via the two pins in parallel to the battery port which I suppose are then going into the voltage regulator on the board.
Any comments or suggestions? Has anyone done something similar?

Check the schematic. You can connect the voltage the the JST battery connector, or JP3 (I'd double check those two holes are connected to the JSP using a mulimeter). But I'm slightly doubtful about that 12v rating they give on the webpage. The voltage regulator can handle that, but I don't think the battery charger IC (MAX1555) can handle 12v on the BAT pin, looking at the datasheet.

Max1555 can only handle of 7v input (see datasheet). Based on the schematic, I won't trust the info on the website. I think it will be better and easier for you to find a power supply of 5V with micro USB. Even if you use the 12V supply applying to JP7, there will be too much voltage drop on the 3V regulator that it will generate heat than it should be.

I used the external switch input JP7-1 for 12v, any GND hole, and make sure the switch is off.  This bypasses the charge circuit which doesn't like 12v.