body:
I have an problem, which at first thoughts (and being new to Arduino) I though was a perfect application for an Arduino. However, after trying and failing to implement it I am doubting myself!

Simply - I need to control many LEDs independently, many of which will have their own individual patterns - for example "5 seconds on - 5 seconds off". "continuous flashes" - or sequences such as "2 flashes, pause, 1 flash". Obviously without the luxury of threads I am becoming a little unstuck. Be great to hear if a) Arduino is the best choice and b) if it is - how can I go about this!

Thanks in advance :)

title: Multiple independent LED patterns

Answers: 3

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

Handling multiple patterns at the same time is certainly possible with a platform like Arduino, and there are a number of ways you could go about it.

One method I would consider is writing functions which effectively represent each pattern mathematically. You'd just pass it the total time that's elapsed in your program so far, and it will do the appropriate action for that specific moment in time. It will return immediately afterwards (no delays or anything).

To do that, you'll first need to know how long a single cycle of the pattern lasts. You can then use the modulo operator to figure out how far through the current cycle you are. From there, all you need to do is have some `if` conditions to determine what to do at any given time.

Here's what it might look like for your "5 seconds on, 5 seconds off" pattern:

    function pattern5on5off(unsigned long totalTime)
    {
      // Calculate how far through the current cycle we are
      const unsigned long cycleTime = totalTime % 10000;

      // If we're in the first 5 seconds of the cycle then turn the light on.
      // Otherwise, turn it off.
      if (cycleTime < 5000)
        digitalWrite(3, HIGH);
      else
        digitalWrite(3, LOW);
    }

Admittedly, constantly calling `digitalWrite()` when you don't technically need to isn't very efficient. It shouldn't cause any harm though, and is fairly easy to optimise if necessary.

To use the above example in a sketch, you'd just need to call it in `loop()`, and pass the number you get from `millis()`; e.g.:

    void loop()
    {
      const unsigned long totalTime = millis();

      pattern5on5off(totalTime);

      // call other patterns here...
    }

Other patterns will be more complex, but follow the same principle. You'd just to use appropriate `if` statements to express your logic.

The vital thing to remember is that the function represents a specific moment in time. It should never pause or delay the program, otherwise it will prevent the other patterns from running.

**Edit: Timing on the first cycle**
As jfpoilpret noted in the comments, the very first cycle will start at a random point. This is because the first time you call `millis()` in `loop()`, it won't start at 0 (the device will already have been running for a short time before `loop()` gets called). It's easy to resolve though, if necessary.

You would do it by offsetting the `totalTime` value by the whatever value you got on the very first time around `loop()`. For example:

    unsigned long g_startTime = 0;

    void loop()
    {
      unsigned long totalTime = 0;

      if (g_startTime == 0) {
        // This is the first cycle.
        // Store the start time so we can compensate later.
        g_startTime = millis();

      } else {
        // This is not the first cycle.
        // Compensate for the start time.
        totalTime = millis() - g_startTime;
      }

      pattern5on5off(totalTime);
      // etc..
    }

body:
Arduino is a fine choice for the task - easy to get started with. The key is to write non-blocking code. You could take a look at the BlinkWithoutDelay example.

I made a suggestion for your task:

    // Timing suquences for the LED's in milliseconds
    // First value is on time, second value is off time,
    // third value on time and so on (up to 10 values)
    // One row for each LED
    unsigned int led_timing[][10] = {
      {5000, 5000},
      {100, 1000},
      {100, 100, 100, 1500, 100, 1500}
    };

    // The pins the LED's are connected to
    byte led_pins[] = {11, 12, 13};

    // Keep track of timing sequence
    // Array size taken from led_pins
    unsigned long last_change[sizeof(led_pins)/sizeof(led_pins[0])];
    byte timing_i[sizeof(led_pins)/sizeof(led_pins[0])];

    void setup()
    {
      // Initialize LED's as output
      for (byte i = 0; i < sizeof(led_pins)/sizeof(led_pins[0]); i++)
      {
        pinMode(led_pins[i], OUTPUT);
        digitalWrite(led_pins[i], HIGH);
      }
    }

    void loop()
    {
      // Current timestamp
      unsigned long now = millis();

      // Keep track of sequence for each LED
      for (byte i = 0; i < sizeof(led_pins)/sizeof(led_pins[0]); i++)
      {
        if (now - last_change[i] >= led_timing[i][timing_i[i]])
        {
          digitalWrite(led_pins[i], !digitalRead(led_pins[i]));
          timing_i[i]++;

          // Start over at the end of timing sequence
          timing_i[i] %= sizeof(led_timing[i])/sizeof(led_timing[i][0]);

          last_change[i] = now;
        }
      }
    }

body:
I know the post is old, but I checked the example with the array based approach and in my opinion:

    sizeof(led_timing[i])/sizeof(led_timing[i][0])

will always yield the allocated size (number of elements) of the array - in this case 10. So the timing won't restart until you reached the "end" of the array, using undefined elements. For LED "0":

    int led_timing[0][10]:
    5000,5000, <undefined>, <undefined>, <undefined>, <undefined>, <undefined>, <undefined>, <undefined>, <undefined>

Greetings
 Tommy


body:
I have an arduino duemilanove with ATmega328.

Been doing several experiments with multiple peripherals

I had no problem uploading at all

But when i try to upload a big program (27,074 bytes (of a 30,720 byte maximum))
it compiles fine, then says uploading...

After some time passes i get this error

    avrdude: stk500_getsync(): not in sync: resp=0x00

The board and serial port connections are fine.
Any ideas?

PS: Then i tried to upload the blink example, but i get the same error for some reason
Everything worked fine before i uploaded my "big" program

title: Problem uploading big program to arduino

Answers: 1

body:
The sync error is a common issue that doesn't have one simple solution (as shown [here][1])

It means that the computer can't communicate with the processor, but it recognizes that it's there (out of sync). This is probably due to something (a peripheral, stray wire) interfering with the transmission from computer to device.

Solutions that have worked in the past:

 - Unplugging the Arduino for 30 seconds, then plugging it back in.
 - Removing any wires connected to Rx and Tx pins during upload.
 - Soldering components connected to Rx or Tx to the board (in this case, I was using a shield that allowed me to do this)

There are lots of solutions available from different sources on the internet, but I have not come across one that names program size as the reason.

  [1]: https://arduino.stackexchange.com/questions/17/some-dude-named-avr-wont-let-me-upload-my-program-aka-avrdude-stk500-getsync


body:
I have a brand new board which is a clone of the Mega2560.  I need to install the USB firmware on the 16U2 and the bootloader on the 2650 chip.  I have Atmel Studio and a JTAGICE-3. Using those, I can download HEX files compiled with the Arduino  IDE, and they run successfully.

But I'm having trouble finding Mega-specific instructions for getting the firmware installed so that I can use the Arduino ISP protocol for downloading new sketches. I can find much more information about the Uno than the Mega. And much of the information I do find seems to be dated.

1) Which are the right files to download?
   I've tried to install the 'MEGA-dfu_and_usbserial_combined.hex' to the 16U2 and the 'stk500boot_v2_mega2560.hex' to the 2560.

 But the IDE won't connect via AVR ISP, and I get no serial communications from a serial sample sketch downloaded with the ICE.

2) What are the correct Fuse settings after I flash those files?

3) Is there a good way to confirm that the 16U2  USB converter is working correctly in isolation from the 2560 chip?

title: How do I install the firmware on an Arduino Mega clone?

Answers: 1

body:
Let focus on one thing at a time, that is flashing the 16u2. You can see if you've successfully done that when you can see the Arduino in your device-manager.

First of, `MEGA-dfu_and_usbserial_combined.hex` is, as stated on the github page, for the 8u2, not the 16u2. Since you already have a ISP programmer you don't need the dfu functionality.  You can just flash the precompiled [Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex](https://github.com/arduino/Arduino/blob/master/hardware/arduino/firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex) file.

The fuses can also be found in the [readme.txt on github](https://github.com/arduino/Arduino/tree/master/hardware/arduino/firmwares/atmegaxxu2): `-U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m`. I don't see any difference in the fuses between the 8u2 and 16u2, so they should work for the 16u2 too.

Hope this helps.


body:
I need to communicate my arduino by bluetooth but I'm living in a small town recently so I can't buy a bluetooth shield for my arduino.

Here is my question: Can I use a usb bluetooth dongle on my Arduino **without a shield?**
PS: There is no need to re-use that bluetooth dongle with usb again.

title: Using Bluetooth Dongle on Arduino

Answers: 2

body: Unless your Arduino is based on a AT90USBXX7, no. Bluetooth dongles are highly integrated and have no accessible interfaces other than USB.

body:
You'll most likely need a USB host shield ([like this][1]) for the Arduino to be able to communicate with the dongle, so that doesn't help. You may (this is a long shot) be able to crack open the dongle, look up some datasheets, and possibly find a serial interface inside that you could connect to Arduino... but like I said, it's a long shot.

  [1]: https://www.sparkfun.com/products/9947


body:
**UPDATE:** The issue turned out to be with my work laptop. Our IT department has them configured in such a way that the assignment of serial ports is different somehow. When I plugged in on my personal Macbook Pro it all worked perfectly.

----------

I just got my first Arduino. Its an UNO R3. I'm running OS X 10.8.5 (Mountain Lion) and the Arduino IDE 1.0.5

Under **Tools>Board** I have Arduino Uno selected

Under **Tools>Serial** Port my options are:

  -  /dev/tty.Bluetooth-Serial-1
  -  /dev/cu.Bluetooth-Serial-1
  -  /dev/tty.Bluetooth-Serial-2
  -  /dev/cu.Bluetooth-Serial-2
  -  /dev/tty.Bluetooth-Modem
  -  /dev/cu.Bluetooth-Modem
  -  /dev/tty.Bluetooth-PDA-Sync
  -  /dev/cu.Bluetooth-PDA-Sync

I've tried all of them, but when I try to upload a sketch it fails. Most give the following error:

    avrdude: stk500_recv(): programmer is not responding

The two "modem" options return this message:

    Serial port '/dev/tty.Bluetooth-Modem' already in use. Try quitting any programs that may be using it.

I'm at a loss. None of these serial ports seems correct but there aren't any other options.

Also under **Tools>Programmer** which option should I be using?

title: No valid serial ports for Arduino UNO on Mac

Answers: 2

body:
Have you hooked up your Arduino prior to pulling down the tools>Serial Port menu? I only see the port for my Arduino listed when it's actually connected and running. (And it's never one of the bluetooth ports.) I don't have my Arduino with me at the moment so I can't tell you exactly what it is.

Also note that on my MBP (running 10.9.4) I have to be sure to plug the USB cable into the CORRECT USB port. The other port maps to a different port in the list of serial ports.

body: The issue turned out to be with my work laptop. Our IT department has them configured in such a way that the assignment of serial ports is different somehow. When I plugged in on my personal Macbook Pro it all worked perfectly.


body:
I have 10 Arduino Pro Minis and one Arduino Uno. Via breadboard, if I connect Pro Minis in parallel, can I program all of them at same time?

Is it possible?

title: Is it possible to program a few Arduinos at the same time?

Answers: 2

body:
Arduino Pro Mini is programmed through serial, using a bootloader. It uses `STK500` protocol, which is described by [Atmel][1].

In theory, it can be possible to program multiple boards if only one TX Arduino pin is connected to USB-Serial converter, and all RX are in parralel, but this is an unreliable method. Only the board with TX pin connected can send its status back to programmer.

Arduino Mini also requires a physical reset before uploading. Make sure that all Reset pins are connected together when reset button is pressed.

  [1]: http://www.atmel.com/Images/doc2525.pdf

body:
In this case I would recommend considering using multiple USB-to-Serial Ports and simply replacing the ".\arduino-1.5.6-r2\hardware\tools\avr\bin\avrdude.exe" with a batch file that then called 10 (or any number of Serial Ports) of your choice.

----------

I would recommend reading my answer from [Programming Arduino's from a centralized location](https://stackoverflow.com/questions/24688215/programming-arduinos-from-a-centralized-location/24688854#24688854).

Where that solution may be a bit more complicated, then needed. But the same pieces would allow you to create a custom programmer that can specifically call the custom avrdude. Allowing the original methods to still exist.

----------

Additionally worth noting. Is that you can turn on verbose for the compiling and uploading from the IDE's preferences. This will display the temporary directory that contains the exact location of the bin file and command executed to upload. Which can then be easily re-executed your convenience. Noting the temporary directory is not immediately destroyed. Where you can also change the arguments to execute different ports and sending it to the background. To call others. So that you can simultaneously upload many devices.


body: Before I install the Arduino IDE, I was just wondering whether I could just use notepad++ to write the files and move them into correct location. I assume notepad++ doesn't support Arduino code, but I suspect there will be a mod for it, even though sketches are a low-end version of C++, which is supported.

title: Can I use notepad++ for writing sketches?

Answers: 4

body: Its fine,  you have to start asking questions somewhere right? You could use notepad++ to write your files and move them to a correct location, but it would be pointless, because you would need a mod to compile and upload it to your Arduino. I would recommend just using the native Arduino IDE, because it does all the work for you, all you have to do is write your code, upload it, and sit back and watch.

body:
The Arduino files are just text files with the *.ino extension, so it is OK to edit them with a text editor.

The Arduino IDE is needed to compile them (easily) however. To make an Arduino project without the IDE, create a directory e.g. MyProject, and create a file inside it called MyProject.ino. They have to have the same name. Adding extra *.ino files inside the directory will result in extra tabs in the Arduino IDE for those files when you open MyProject.ino.

body:
You can easily use notepad++ or any text editor to edit arduino code files (.pde or .ino). I use the sublime text editor for all my arduino coding.

As you noted, the arduino syntax is c++, so setting the syntax highlighting mode to c++ is all that you need to do; no mod should be necessary.

Arduino includes a "Use external editor" option in the preferences menu that will make it reload the file every time you compile or upload. It also disables editing in the editor window. In this mode, just save your file in any editor, change to the arduino window, and hit upload.

Since 1.5, arduino has had command line support. most editors allow making the "build" button execute arbitrary commands in the current directory. by setting build to run "arduino --verify" or "arduino --upload" you can code in any editor you want even without having an arduino window open.

body:
You can use any editor to write Arduino code. @BrettM has already detailed it.

Instead of the external editor option, you can do away with the Arduino IDE completely using `Makefile` and build and upload your code yourself.

> Arduino IDE sucks. Ok, I admit it’s nice for beginners and for the
> click-and-forget kind of programmers, but it needs the full Java stack
> and hides to the user the fundamental steps involved in compiling and
> uploading programs to the arduino board.
>
> I (like many other software developers) prefer to understand what I’m
> doing and running a Makefile from the command line is the way to see
> the individual steps and choose which to run and when. Finally, I’m
> not going to drop my favourite editor just to write arduino programs.

[Here][1]'s how to do it.

  [1]: http://www.itopen.it/2012/02/12/arduino-1-0-development-with-a-makefile/


body:
I have wired up a small project with a shift register (see below), but depending on how I put the [74HC595][1] IC (8-bit shift register with 3-state output register), the green and yellow LEDs of the Arduino stop shining.

What are these LEDs for? Do they tell something about a possible damage of the IC/short circuit in the setup?

![Enter image description here][2]

  [1]: http://www.ti.com/lit/ds/symlink/sn74hc595.pdf
  [2]: https://i.stack.imgur.com/juRGS.jpg

title: What purpose does the yellow and green LEDs have on the Arduino?

Answers: 4

body:
The green LED is marked with `ON`, and it indicates that the Arduino has power.

The yellow LED is marked `L` and is just connected to pin 13. So when you set pin 13 to HIGH the LED lights up. You can however still use pin 13 for other things.

When the green LED stops shining you most likely have a short somewhere. As the short will drain all power away, so the Arduino has no power left to light the LED(s).

body: Also note that there is the TX and RX pins on Uno (orange/yellowish) are for the USB connection. When the LED labeled TX is lit up, the Arduino is transmitting data to the computer. When the RX is lit up, it is receiving data from the computer.

body:
Also be warned that the `L` LED (the one activated by pin 13) may light up if pin 13 is high-impedance (set to input), and is not connected to anything.

On my Uno, a trivial sketch like this lights up the `L` LED:

    void setup ()
      {
      }  // end of setup

    void loop ()
      {
      }  // end of loop

This is because the LED is not driven directly by pin 13, but by an op-amp (U5B) which -- if the pin is configured as an input -- may pick up enough stray voltage to activate and light up the LED.

This can be confusing because you might look at your board and think "huh? I didn't command that LED to come on".

body:
Just wanted to re-iterate that On the MEGA 2560 Revision 3 you can't change the L led pin 13 due to the op-amp like Nick Reported.

Spent a couple hours on this scratching my head only to find this out


body:
When doing RF, you have many options.
Three of the most basic are in the title box

1. WiFi
2. Xbee
3. NRF24L01

What are the practical differences in using them. What is the purpose of each other and the pros and cons. What would you use depending on the application you had?

I do not have a project in mind, but i want to start learning about Rf. I searched ebay for wireless devices. but i couldnt understand the differences. My goal is simply learning

title: Whats the difference between RF options (wifi, xbee, NRF24L01)

Answers: 1

body:
There are many different type of RF networks with various advantages and disadvantages. The main things I consider when choosing a wireless communication method are network topology, data rate and power consumption.

**WiFi:**

High data rate (54Mbit/s +) but also high power consumption. Used when you need to connect directly to the internet, such as an internet-of-things device, and have an external power source.

**XBee:**

Low data rate (250kbit/s) and low power consumption. Used to make mesh-type sensor networks; each XBee device can communication with each other, and *through* each other via the mesh to devices that are out of range. Used for networks of devices, particular home automation and sensors. [link][1].

**Bluetooth:**

Medium data rate and medium power consumption. IEEE standard has different device profiles to enable interoperability between devices. 'Pairing' type network however, so not useful for sensor networks, but good for controlling devices using a laptop or phone which usually have Bluetooth on board. Communicates with Arduino via serial RX and TX pins. [link][5].

**Bluetooth Low Energy, ANT, etc:**

Very low data rate and very low power. These RF chips can run for years on an AA battery and so are used for things like heart rate sensors. The data rate is quite low so only good for transferring a small amount of data such as sensor readings. Most devices are setup as peripherals and can only connect to one 'central' device, so no good for sensor networks. Bluetooth low energy is supported by the latest mobile phones and laptops however. Useful to enable control of a device using a phone or laptop, for example a LED lamp. (See redbearlab for some Arduino options)

**GSM**

Phone connection. TODO

**nRF24L01** **/** **RFM12B** **/** **RFM22B(SI4432)**

Popular proprietary transceivers. They can connect via SPI and have a lot of fancy features like low power modes, multiple channels, channel hopping, frequency calibration, CRC, retransmit and so on. The nRF24L01 from Nordic Semiconductor [link][2] operates in the 2.4GHz band, others use the ISM band 433/470/868/915Mhz.
These are todays state of the art highly integrated and low cost hardware for  reliable telemetry and consumer applications. The range is between 10m and 150m. The SI4432/RFM22B has the range of about 1.5Km.

**Other RF modules**

Simple and cheap serial devices. Single transmitter/receiver or transceiver that operate in the ISM band [link][4]. Often used as garage door opener. Useful for sensor network where interoperability with other devices is not required and you can implement your own protocol. [link][3]

[1]: https://en.wikipedia.org/wiki/Xbee
[2]: http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01
[3]: https://en.wikipedia.org/wiki/RF_module
[4]: https://en.wikipedia.org/wiki/ISM_band
[5]: https://en.wikipedia.org/wiki/Bluetooth


body:
I know the Arduino is a nice quick and dirty prototyping board. You quickly test your idea, and if you want to proceed you can do so with AVRs.

Your options are:

1. Upload the program to Arduino, then remove the AVR chip and make a PCB (with the bootloader)
2. Start from scratch with AVR (not always feasible because many libs are in Arduino)

Now what is the purpose of a system that has processors that cannot be removed? For example the Arduino Galileo.

Sure, you can do many things with it, but bottom line, you cannot remove the processor and do something with it.

As an example, imagine you are prototyping a system you wish to, then, market and sell. That is feasible with the Arduino Uno family.

But what if you did in in Galileo? Even if it worked, you couldn't sell your system because you rely on the prototyping board. You cannot remove the processor.

Am i missing something?

title: What is the purpose of Galileo (or other unremovable chips)

Answers: 4

body:
Edit: As Chris points out, this answer is more about the simple AVR Arduinos. For comment on the Galileo and other more complex MCUs, please refer to Chris' answer.

For Arduino compatibility you can program the Arduino boot loader into the microcontroller using the ICSP pins. You do not need a chip from an Arduino board, you just solder a blank one in. Once the boot loader is on there you can use the Arduino IDE to upload sketches via the UART.

It is not necessary to use the Arduino system to write programs. You include the Arduino library files in a normal C++ project in many different IDEs and use the avr toolchain to compile and avrdude to upload.

Update:

Here is an example of a board I just got back from PCBA. (The picture was sent by the PCB company for checking). Initially I made the board using an Arduino Pro Mini 3.3V, SD card breakout board, LSM303DHLC accelerometer breakout from Pololu, and Real Time Clock (RTC) breakout. Once everything was working I drew up a PCB in Eagle CAD, using the core of Arduino Pro Mini board plus the individual SD card, LSM303DLHC and RTC chips. I also added a 3.3V boost converter so I could get a constant 3.3V off 2 AA batteries.

![enter image description here][1]

The board has the ICSP pins broken out. Actually, you will find they are broken out on most Arduino boards. Using another [Arduino as ISP][2] I can program the Arduino boot loader via the ICSP pins, and then sketches can be uploaded via the UART using the Arduino IDE. In the IDE the board that is selected is "Arduino Pro Mini 3.3V 8MHz".

The Arduino boot loader is a small piece of firmware that runs on startup. It allows you to send a program over the UART which it stores into FLASH memory itself. It is not absolutely necessary. You can program the chip using the ICSP as well. It is really convenient however. Using software like [xloader][3] you can upload Arduino programs without the IDE. Really handy when other people are using the board and you don't want to share your code. Alternatively, you can write a script for avrdude to do it.

This project is for a university so I'm leaving it as Arduino compatible. In a commercial engineering environment, I would choose a more appropriate MCU (one with lower power consumption for a battery device) and rewrite the program to be more efficient and not rely on the Arduino and third-party libraries.

  [1]: https://i.stack.imgur.com/meINZ.jpg
  [2]: http://arduino.cc/en/Tutorial/ArduinoISP
  [3]: http://russemotto.com/xloader/

body:
You are right. There are however people that use an arduino for hobby, and don't want to invest more time into learning to make PCB and programming bare AVRs. For some people getting some leds to blink is already very hard.

Also look at the amount of Arduino shields that are available. The target group of Arduino's has shifted from hobby electronics people to just regular people wanting to get some project working. People are okay with sacrificing an entire arduino board, adding some shields and putting it inside a Tupperware box. As long as it solves their problem, or does something cool.

body:
Arduino boards, with or without removable chips, provide a lot of facilities ready to go for experimenters, prototypers, students, artists and other tinkerers who aren't necessarily interested in the electronics but just want a programmable controller to get a job done. They can often be the cheapest way to build a one-off system once you consider the labor to build a less expensive board.

It's really easy to program AVR chips on a breadboard or, in most cases, right on the custom project board. You don't need Arduino to do that. I've built up and programmed ATMega328p projects without ever taking my Arduino out of the box.

This is a project I prototyped on an Arduino Mega2560 and later ported to the project board with soldered-in chip. The cable is a USB FTDI serial cable, a stock item that connects any chip with a TTL UART directly to a computer USB port. (The green daughter board is an X-10 RF transmitter and the reason I prototyped this project on a larger CPU).

![enter image description here][1]

Often I develop project code solely on the project board; it's just about as easy. About the only advantages I get from using the larger board is multiple serial lines so I don't have to keep switching my terminal app off and on to allow down loading, and I can include lots of extra debugging code and libraries that I won't need in the project.

Your favorite tool set will work either way. The Arduino IDE, Eclipse, or bare-nekkid ARVdude at the command line. If your project code needs the Rx/Tx pins, you may need to build one board with jumpers to disconnect the project's serial hardware while you're downloading.

  [1]: https://i.stack.imgur.com/ewRb1.jpg

body:
The pentium-class x86 based Galileo mentioned in the question title appears intended to meet project needs which have (memory, compute, or interface) requirements beyond the capability of the simple AVR (or perhaps even ARM) based Arduino boards.   It's not uncommon in the Arduino realm to see people trying to use the little processors for tasks which exceed their capability, and it appears intended to address that problem.

While one can breadboard the equivalent of the AVR based Arduinos, or duplicate the functionality of those or even the simpler ARM-based boards on a hobbyist-designed 2 layer PCB, implementing something like the Galileo would require a many-layer board designed by an experienced PCB designer.  **For low-volume uses, someone would probably just buy the existing boards and use them** (there is a longstanding market of embedded control modules intended for such use) - only at high volumes would it be cost effective to re-implement the board or its equivalent.


body:
I'm flying out for vacation, and I want to take some of my half-done arduino projects with me to work on.  I'm concerned that aiprort security might mistake my devices for something sinister or at bare minimum 'suspicious' and be confiscated.

Has anyone ever had any negative experiences taking arduino-esque wiring projects through airport security?

title: Any problems taking arduino(esque) devices through airport security?

Answers: 4

body:
It will depend on your particular country of course. Check the rules on cabin baggage.

In Australia, Arduino boards should pose no problem. It is best to not take any batteries or tools with edges (screwdrivers) or heavy tools (wrenches). In case they do want to have a look, place the boards at the top of your bag for easy access.

I have traveled to Europe from Australia with half a suitcase full of large PCBs with no problem. The only time my bag was opened was when I was carrying a tea pot stand, which was in the shape of a tea pot. Apparently it looked like a gun.

body: I don't think that is a problem. I have taken my arduino several times with me when I travel by plane and have never had any problems. I have even carried an oscilloscope and I only was warned about the pointy probes. I have taken international flights with it without any problems. However, always verify the airline baggage restrictioins.

body:
I personally haven't taken my Arduino through security, but here are a few things I'd look at before flying:

 - International flights might be more secure, so keep that in mind.
 - (Like already mentioned) check your bags whenever possible
 - Go extra early in case you do have to explain to the TSA (or equivalent). You don't want to miss your flight!
 - Take it out of your bag so it doesn't look like you're hiding anything. The more open you are about it, the less suspicious they'll be.
 - Bring any original packaging for your Arduino/parts.

A few other things I've read to do:

 - Take tickets if going to some event like a Maker Faire, especially if they can look it up online. If they seem skeptical, you could always pull it up on your phone.
 - Don't make [it look like a bomb](http://www.instructables.com/id/Explosive-Alarm-Clock/) (i.e. **don't be stupid!**)
 - Don't take tools unless needed
 - Be patient and calm if they stop you. You have nothing to hide from them (Right? ***Right?***)

body:
Real world example:

I have just flown from  JFK - New York to GRU - Sao Paulo (Brazil) (October 2016) with this 'RIAspire UNO R3 Master Beginner Starter Kit for Arduino DIY Discovery - 25 Sensors with RFID, Ultrasonic, Temperature, HC 05 Bluetooth, ESP8266 Wifi' on my hand luggage.

There were a lot of wires, detectors and everything.

Nothing happened.


body:
I am using the following components to build simple motobot:

- Arduino Uno
- Arduino motor shield,
- servo,
- sonar HC-SR04,
- magician chessis,
- DC adapter with 4 AA batteries.

All works fine while USB cable is plugged. As soon as I unplug USB cable servo and sonar stop working, although motors connected to motor shield continue rolling.

From what I read around internet motor shield operates with 7-12V voltage. I need 5V for sonar and servo. So they both are connected to 5V pin on the shield board.

How could I overcome this issue?

title: Sonar and servo stop working when usb cable unplugged

Answers: 3

body:
Add an extra 2-4 AA batteries in series. 4 x AA is 6V for fresh batteries, 4V when the batteries are at the end of their life, which is not enough.

An alternative is to get a boost converter, e.g. [this][1], so you can supply 5V with less than 5V.

  [1]: http://www.miniinthebox.com/0-9v-5v-to-5v-600ma-dc-dc-step-up-boost-module_p508927.html?currency=AUD&litb_from=paid_adwords_shopping

body:
Because I use nodejs with help of [johnny-five library](https://github.com/rwaldron/johnny-five) I asked the question on the project wiki. This is the answer from Rick Waldron:

You can't unplug the USB, doing so kills the communication between the program and the board. Those components that continue functioning only do so b/c they are still receiving power. To free the bot from tethers, check out the guide at the bottom of this page: https://github.com/rwaldron/johnny-five/wiki

body:
Sonar modules are notorious for pulling so much instantaneous power during their brief pulses that they often reset the processor, causing the Arduino to start all over from the beginning.

Do you have any way of knowing whether your program is executing more-or-less normally, or if your program in the Arduino is getting reset?
If not, you need better debugging tools.

(tangential rant about debugging tools)
---------------------------------------

Many people debug by sprinkling their code with print(F()) statements that get sent to a LCD screen or a serial port.
Other people debug by sprinking their code with statements that turn on and off a series of LEDs of various colors, or at least a single LED with a (hopefully easy-to-decode) blink code.
Some kinds of problems are much easier to track down with an oscilloscope.

dealing with high-current pulses
--------------------------------

My best guess is that the sonar is pulling very brief high-current pulses from the battery, which causes the battery voltage to droop low enough to reset the Arduino.
When the USB cable is plugged in, (I'm guessing that) the additional power supplied by the USB cable somehow keeps the Arduino from resetting.

Many sonar modules (very briefly) pull 1 A or 2 A, far more than a USB cable or a handful of AA batteries can supply.

There are many ways to solve that problem, but if I were you I would first see if that is really the problem in this case.
Possibly the quickest way to tell is:

* Use at least 2 separate battery packs.
* Hook all the grounds of all the battery packs and all the devices together.
* hook the positive power of one battery pack to the Arduino and nothing else.
* Hook the power lead of all the other devices to some other battery pack (ideally a different battery pack for each device).

Then run the test again.
This should give you a clue as to whether the problem is the Arduino seeing power-supply droop (which separate battery packs should "fix"), or something else.

If the problem really is power supply droop, there are a variety of ways to fix it:

* (a) Many people recommend: use a large 1000 uF capacitor directly across the power pins of the sonar, and a 10 Ohm or 100 Ohm resistor between the battery positive and that capacitor. [(a)][1] [(b)][2] [(c)][3] [(d)][4] [(e)][5] [(f)][6]
* (b) Use a large capacitor directly across the power pins of the Arduino, and a diode from the battery to that capacitor so that normally the diode allows the battery to charge the capacitor, but when the sonar or whatever briefly drags the battery voltage to a low level, the diode blocks the sonar from pulling energy "backwards" out of that capacitor, and the capacitor is large enough to run the Arduino during the sonar pulse.
* (c) Get a dedicated "logic" battery array to power the Arduino and a few LEDs, etc., and a separate (often much larger) "dirty power" battery array to power the sonar, motors, etc.

  [1]: http://diydrones.com/forum/topics/sonar-noise-reduction-update
  [2]: http://forum.arduino.cc/index.php/topic,146260.0.html
  [3]: http://www.societyofrobots.com/sensors_sonar.shtml
  [4]: http://www.uoxray.uoregon.edu/polamod/
  [5]: https://www.zagrosrobotics.com/sonar.htm
  [6]: http://david.carybros.com/html/ultrasonic.html


body:
I purchased several nRF24L01+ (RF24) radios to use with my Arduino Uno and Micro.

Using the [GettingStarted][1] sketch and nRF24L01+ connected to my Uno, I get nice debugging info in my serial monitor. However when I connect the nRF24L01+ to my Micro, upload the sketch and open the serial monitor I get no debugging information. There is no info displayed in the serial monitor.

Also the Arduino Uno when set to Transmit, does not see the other nRF24L01+. Any help would be appreciated.

Here is my pinout to connect the nRF24L01+ to the Micro:

    Line  From Arduino Pin  To nRF24L01+
    GND     GND                 1
    3V3     3V3                 2
    CE     9                   3
    CSN     10                 4
    SCK     SCK                 5
    MOSI MOSI             6
    MISO MISO             7

Here the nRF24L01+

![Nrf24L01+][2]

Sketch

    /*
     Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>

     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License
     version 2 as published by the Free Software Foundation.
     */

    #include <SPI.h>
    #include "nRF24L01.h"
    #include "RF24.h"
    #include "printf.h"

    //
    // Hardware configuration
    //

    // Set up nRF24L01 radio on SPI bus plus pins 9 & 10

    RF24 radio(9,10);

    //
    // Topology
    //

    // Radio pipe addresses for the 2 nodes to communicate.
    const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

    //
    // Role management
    //
    // Set up role.  This sketch uses the same software for all the nodes
    // in this system.  Doing so greatly simplifies testing.
    //

    // The various roles supported by this sketch
    typedef enum { role_ping_out = 1, role_pong_back } role_e;

    // The debug-friendly names of those roles
    const char* role_friendly_name[] = { "invalid", "Ping out", "Pong back"};

    // The role of the current running sketch
    role_e role = role_pong_back;

    void setup(void)
    {
      //
      // Print preamble
      //

      Serial.begin(57600);
      printf_begin();
      printf("\n\rRF24/examples/GettingStarted/\n\r");
      printf("ROLE: %s\n\r",role_friendly_name[role]);
      printf("*** PRESS 'T' to begin transmitting to the other node\n\r");

      //
      // Setup and configure rf radio
      //

      radio.begin();

      // optionally, increase the delay between retries & # of retries
      radio.setRetries(15,15);

      // optionally, reduce the payload size.  seems to
      // improve reliability
      radio.setPayloadSize(8);

      //
      // Open pipes to other nodes for communication
      //

      // This simple sketch opens two pipes for these two nodes to communicate
      // back and forth.
      // Open 'our' pipe for writing
      // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)

      if ( role == role_ping_out )
      {
        radio.openWritingPipe(pipes[0]);
        radio.openReadingPipe(1,pipes[1]);
      }
      else
      {
        radio.openWritingPipe(pipes[1]);
        radio.openReadingPipe(1,pipes[0]);
      }

      //
      // Start listening
      //

      radio.startListening();

      //
      // Dump the configuration of the rf unit for debugging
      //

      radio.printDetails();
    }

    void loop(void)
    {
      //
      // Ping out role.  Repeatedly send the current time
      //

      if (role == role_ping_out)
      {
        // First, stop listening so we can talk.
        radio.stopListening();

        // Take the time, and send it.  This will block until complete
        unsigned long time = millis();
        printf("Now sending %lu...",time);
        bool ok = radio.write( &time, sizeof(unsigned long) );

        if (ok)
          printf("ok...");
        else
          printf("failed.\n\r");

        // Now, continue listening
        radio.startListening();

        // Wait here until we get a response, or timeout (250ms)
        unsigned long started_waiting_at = millis();
        bool timeout = false;
        while ( ! radio.available() && ! timeout )
          if (millis() - started_waiting_at > 200 )
            timeout = true;

        // Describe the results
        if ( timeout )
        {
          printf("Failed, response timed out.\n\r");
        }
        else
        {
          // Grab the response, compare, and send to debugging spew
          unsigned long got_time;
          radio.read( &got_time, sizeof(unsigned long) );

          // Spew it
          printf("Got response %lu, round-trip delay: %lu\n\r",got_time,millis()-got_time);
        }

        // Try again 1s later
        delay(1000);
      }

      //
      // Pong back role.  Receive each packet, dump it out, and send it back
      //

      if ( role == role_pong_back )
      {
        // if there is data ready
        if ( radio.available() )
        {
          // Dump the payloads until we've gotten everything
          unsigned long got_time;
          bool done = false;
          while (!done)
          {
            // Fetch the payload, and see if this was the last one.
            done = radio.read( &got_time, sizeof(unsigned long) );

            // Spew it
            printf("Got payload %lu...",got_time);

            // Delay just a little bit to let the other unit
            // make the transition to receiver
            delay(20);
          }

          // First, stop listening so we can talk
          radio.stopListening();

          // Send the final one back.
          radio.write( &got_time, sizeof(unsigned long) );
          printf("Sent response.\n\r");

          // Now, resume listening so we catch the next packets.
          radio.startListening();
        }
      }

      //
      // Change roles
      //

      if ( Serial.available() )
      {
        char c = toupper(Serial.read());
        if ( c == 'T' && role == role_pong_back )
        {
          printf("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK\n\r");

          // Become the primary transmitter (ping out)
          role = role_ping_out;
          radio.openWritingPipe(pipes[0]);
          radio.openReadingPipe(1,pipes[1]);
        }
        else if ( c == 'R' && role == role_ping_out )
        {
          printf("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK\n\r");

          // Become the primary receiver (pong back)
          role = role_pong_back;
          radio.openWritingPipe(pipes[1]);
          radio.openReadingPipe(1,pipes[0]);
        }
      }
    }

  [1]: http://maniacbug.github.io/RF24/GettingStarted_8pde-example.html
  [2]: https://i.stack.imgur.com/VkpaI.jpg

title: nRF24L01+ (RF24) radio with Arduino Micro

Answers: 2

body:
Perhaps you use the wrong pins. This is really a pitfall [link][1].

You have the Atmega Pins, the consecutive pins of the headers and the pins written on the PCB, i.e. 9 could be 9 on the PCB which is A9.

I have a Chinese 'Micro Pro' and I switched to (2,3) instead of (9,10).

[1]: http://arduino.cc/en/Main/ArduinoBoardMicro

body:
Of course, `9` means `D9` and not `A9`.

Everytime Arduino projects assign a pin with no prefix, it is denoted as data I/O and if the Analog pins are used then it would say `A9`.

The nRF24L01 handles data I/O and not analog input.


body: I am making an arduino game and the requirement is that my arduino reads 4 analog values from the pots. I dont know whether I should use an external battery supply or the 5V from the duino' itself. I dont want my ICs to get fried or nothing happening at all.

title: How do I attach 4 input pots to arduino?

Answers: 2

body: It doesn't really matter as long as the the voltage across your pots doesn't exceed the ARef or IORef voltage, which is usually equal to Vcc (3.3V or 5V) for the Arduino boards. It's best to use the 5V from your board. The ADC inputs are relatively high impedance so very little current flows through. Don't use very large value pots or you might not get the correct values from your analog inputs.

body: Set up 4 pins as inputs. Wire the pots as voltage dividers (center wired to the input through a small-value resistor. One of the ends of the pot wired to +5V from your Arduino, and the other end wired to ground.)


body:
I want to reclaim the space reserved for the bootloader on my ATMega32u4 (Leonardo chip).
But the lowest boot flash size I can see is BOOTSZ=11 which is 256 words (512 bytes). Is it not possible to completely disable it?
Basing this off of this: http://www.engbedded.com/fusecalc

title: Disable Boot Flash completely on ATMega

Answers: 1

body: It is not possible to set the bootloader space to 0, but it is possible to unlock the bootloader space entirely by unprogramming the lock bits as well as to enable normal booting by unprogramming BOOTRST in the high fuse byte. Access to the entire chip will then be fully unrestricted.


body:
***Update**: I started playing with a genuine Deumilanove and exactly same problem happened to it - d13 led blinking, but avrdude says `stk500_recv(): programmer is not responding`*

I uploaded a largish sketch ~15kb to Arduino Nano v3.0 (clone) and that left the board in an unusable state. When connected to USB, a power LED goes on immediately and 1-2 seconds later the yellow "L" starts blinking really fast.
[Here's the board I use][1], it's a cheap clone, but it worked really well before today.

Now, when I try to upload a new sketch I get an error:

    avrdude: stk500_recv(): programmer is not responding

I tried making and ISP programmer out of genuine Duemilanove, using [nano's ISP pins][2] and tried following [official instructions][3] (didn't use any capacitors/resistors).
Either way when I click "Burn Bootloader" result is the same error:

    avrdude: stk500_getsync(): not in sync: resp=0x15

I have connected "debug" leds to D7,8,9 and heartbeat fades in and out in idle, others stay dark.
When I click "Burn Bootloader" all leds go dark then it does few quick blinks on 7, then similar pattern for 8, and then heartbeat resumes. Sometimes this sequence is repeated twice.

I also tried editing preferences.txt to bypass bootloader, but that didn't help.

**How do I restore this board or do a low level reset?**
It seems to be in some failure mode, with pin 13 oscillating, but I don't know what that means.

  [1]: http://www.ebay.com/itm/161091236453
  [2]: http://letsmakerobots.com/content/make-arduino-isp-programmer
  [3]: http://arduino.cc/en/Tutorial/ArduinoISP

title: Arduino Nano not responding with yellow led blinking fast

Answers: 4

body:
I successfully restored both boards using the reset button:

 1. Power off the board (I disconnected the USB cable from computer)
 2. Press and hold the reset button
 3. Connect USB cable (keep holding the reset button)
 4. Click "Upload Sketch"
 5. Wait a second or two until Arduino software says "Uploading..." in the status bar
 6. Release the reset button

Use these steps to upload any small sketch, Blink example is a good choice.

body:
There is bug related to watchdog in original old Arduino bootloader. You can switch to different bootloader, e.g. "Optiboot".

Explanation of issue from [ATmega48A/PA/88A/PA/168A/PA/328/P datasheet][1], section **10.10.5 Watchdog Timer**, page 48:

> If the Watchdog is accidentally enabled, for example by a runaway pointer or brown-out condition, the
device will be reset and the Watchdog Timer will stay enabled. If the code is not set up to handle the Watchdog,
this might lead to an eternal loop of time-out resets. To avoid this situation, the application software should
always clear the Watchdog System Reset Flag (WDRF) and the WDE control bit in the initialization routine,
even if the Watchdog is not in use.

Reset from button is not helping, only power off/on reset give device change to boot again (and flash new software). Explanation of this, from **11.9.1 MCUSR – MCU Status Register**, page 54:

>Bit 3 – WDRF: Watchdog System Reset Flag
This bit is set if a Watchdog System Reset occurs. The bit is reset by a Power-on Reset, or by writing a logic
zero to the flag.

  [1]: http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf

body:
Use "upload.verbose=true" in the preferences.txt of the Arduino IDE (File->preferences-> Click on the file), this helps you to find the right moment to release the reset button (Step 5 of Paul's method).

    avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
    .
    .
             Using Port                    : COM19
             Using Programmer              : arduino
             Overriding Baud Rate          : 57600
    release here ^^^^

body: Try changing processor type to ATmega328(old bootloader) in Tools->Processor. My Nano board blinked led like it had bootloader but I couldn't upload sketch and that helped.


body:
I'm fairly new to this and I need some help before I buy anything...

If I understand correctly I can buy an arduino, couple of shields and just stack them one onto another if they are compatible...

I'll be doing some work with an arduino and I would need both WiFi and GSM shields but I'm not sure if they're compatible... On the arduino.cc I saw that they both use pin 7 (GSM as modem reset and WiFi as "handshake")

Is there any way I can use both of the shields even though they use the same pin?

Thanks

title: Arduino stacking wifi and gsm shield

Answers: 2

body:
You can still use both of them although you'll need to buy another piece to make it work.

[This is called the Go-Between Shield][1] and it basically lets you re-route a pin to a different one.  You will need to change the pin number in your code to the one you re-assign that signal to but it will still work.

The signals you listed that go on that pin are very incompatible, as in if you try to do it, you'll have problems.  Every time your Wifi shield will try to connect to something, your GSM shield will reset.

  [1]: https://www.sparkfun.com/products/11002

body:
If you will be using Wi-Fi, instead of buying a Wi-Fi shield and a GSM shield, simply buy an Arduino Yún (which will substitute the Arduino and WiFi shield) and connect the GSM shield to it.

From [How to use the Arduino GSM shield with Arduino Leonardo, Arduino Yun, and Arduino Mega][1], it shows you how to connect the Arduino Yún with a GSM shield and to use them without any problem with the help of jumper.

  [1]: https://www.arduino.cc/en/Guide/GSMShieldLeonardoMega


body:
I've been programming and testing an Arduino based quadcopter for the past 4 months. Until now I did not need to use an external power source for my sensors. Now I want to use the 'BEC' power from my electronics speed controllers.

Each of the 4 ESCs gives 5V @ 2A. I would set these up in a parallel circuit, which would give me 5V @ 8A (theoretically).

I also want to use a cheap chinese voltage sensor to sense the voltage from my 5000mAh 25-50c 11.1v battery. I'm not sure if it is safe to connect my batteries wires to my sensor with the 125A that it can put out.

My question is whether or not it is safe to have a common ground on Arduino with an 8A power supply AND if it is safe to use a 5V 8A power supply with these sensors.

Here is a problem that I've encountered before:

while powering my IMU off the BEC and sending motor PWM signals, my sketch would run for about 10 seconds then freeze. It was not until I powered my IMU off the Arduinos 5V power that I was able to run the sketch flawlessly. What could have been causing that?

I've made a diagram of my circuit in Fritzing (not actually tested yet due to fear of ruining my sensors). I'm using an Arduino Mega.

![Fritzing diagram][1]

  [1]: https://i.stack.imgur.com/ZLogT.jpg

title: Autonomous Quadcopter power distribution and sensing concerns

Answers: 1

body:
Your question is quite long. I've broken it up into several parts:

> whether or not it is safe to have a common ground on arduino with an 8 amp power supply

Yes. In fact, if you have any electrical connection (even a signal) between those two, you'll *need* a common ground to ensure integrity of the data being sent.

> if it is safe to use a 5 volt 8 amp power supply with these sensors.

I didn't see how much they drew. Without a lot of information, I'm going to say *yes*. If you don't need that much current, consider removing one of them so you only have 6A or 4A, since 8A is quite a bit if you aren't using it (and you might waste electricity in the conversion process). Make sure to have a thick enough wire for it. A best practice scenario would be to use each ESC separately or use two of the ESCs in parallel (with all  of the grounds connected!). This would isolate the current to either 4A or 2A.

> while powering my IMU off the BEC and sending motor PWM signals my sketch would run for about 10 seconds then freeze. It was not until i powered my IMU off the arduinos 5 volt power that I was able to run the sketch flawlessly. What could have been causing that?

I'm not quite sure what would be causing that without seeing the code/circuit for that. The only thing I can think of is the grounds weren't connected and the signal got corrupted.


body:
I was wondering if someone could try and solve a major problem I've been having with a brand new [Arduino Robot](http://arduino.cc/en/Main/Robot) (similar to an Arduino Leonardo). Any input would be very much appreciated!

I've been working with an Arduino Robot on a summer internship for the last week with no major problems. However, a couple of days ago, it stopped running programs and couldn't be detected when being plugged into the computer.

When plugged in or turned on, the LCD turns on with nothing displayed on the screen and the power LED also switches on. However, no program is run (I had a working program involving the LCD uploaded at the time it stopped functioning, which would normally run). Also when plugged in, the Arduino is completely undetected by the computer, with the 'Serial Port' option under Tools grayed out, the device not showing up in device manager, and no signs that a device has been plugged-in. I've tried 3 different USB cables - one of which I tested on another device - and 3 different computers (with Windows 7, 8.1 and Linux Ubuntu installed). On the Linux computer, I ran lsusb before and after plugging in the device and saw no change. I've also tried various solutions such as re-installing the drivers and the Arduino software, using MProg and various rebooting/unplugging-replugging variations.

So I think the problem is almost definitely with the Arduino Robot itself. I'll give a little information about the problems I encountered previously, to see whether something I did affected it or not.

Problem 1:

The first problem I had with the robot was entirely by my own fault and was pretty foolish of me (I'm new to electronics - this being my first project involving it). I ran code from [this website](http://www.dfrobot.com/wiki/index.php?title=Arduino_LCD_KeyPad_Shield_(SKU:_DFR0009)) (the first set of coding on the page) to try and see whether I could get the LCD to work - not realizing that it wouldn't work for a different type of LCD. After uploading the code, the speaker made a loud constant buzzing noise. Fortunately after uploading a different code, the problem was resolved. I'm doubtful that this could have affected the robot, but since I'm so new to this I'll leave it to one of you to decide.

Problem 2:

The next problem was one to do with uploading. The robot worked fine for a couple of days after the first problem until I came across this one:

When uploading programs, there would be a 'device disconnecting' sound from the computer and the program would fail to upload (I can give details on the error messages if you need them). I managed to solve the issue using an odd solution involving hitting the reset button at just the right time while a program was uploading.

After this, the robot worked for a few hours. In this time I tried to play with the 'turn' function, which didn't seem to work very well at all (the robot would turn angles very different to the ones given) and started creating programs playing around with the LCD. It was at this point the robot stopped functioning properly.

So does anyone have any idea what might be wrong? I have no idea how to fix this problem and I've been trying to find a solution for almost 2 full days now. Any input at all would be greatly appreciated.

title: What's wrong with my undetected, unresponsive Arduino Robot?

Answers: 4

body:
I'm pretty sure and sadly to announce you that the usb communication of your Arduino Leonardo Compatible is dead and the arduino is connecting to the computer just like an alimentation Source no more.
And since Arduino Leonardo based on The ATmega32U4 which has built-in USB communication ,so the Atmedga32U4 is dead(u-processor) too.

It's not a software matter but hardware one.

body:
You should try to connect to the board using an in-system-programmer. If you have another Arduino lying around, you can upload the ArduinoISP sketch to and use it as a programmer. Alternatively you can buy a cheap programmer on ebay for a few dollars, just search for "avr programmer". You should look up the placement of the MOSI, MISO,SCK, and RESET pins on your board and connect them appropriately(GND connection is also needed and VCC unless you have another power source).

For ArduinoISP you can run avrdude like this:

    avrdude -c avrisp -p atmega32u4 -b 19200 -P [serial port, eg. /dev/ttyUSB0 in Linux]

If avrdude can read the chip signature, then at least part of the chip is probably OK. Try to upload a sketch. If it works, you should locate the Leonardo bootloader and flash it to the board. See if it brings back the USB connection.

If you don't have any luck with these methods you might want to look into high voltage programming.

body:
Try this:

 - Bring up a very simple sketch like blink or bare-minimum.
 - Select the right board and serial port from the tools menu.
 - Then click upload
 - As soon as the IDE says 'Uploading' double tap the reset button on the board that you are
   programming.
 - Hopefully the sketch should upload.
 - You should then be able to upload any other sketch to the Robot like wheel calibration or
   line follow.

It works for me (since I had the same problem) for a few days until it stops working again. It's Just a design flaw with the ATMega32u4.

body:
This incident exactly happened for me just now.
I solved it by upload simple sketch and double click on the reset button (the board will be detected for around 8 seconds. once the sketch uploaded successfully, the board should be fixed that time.


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

title: Mega 2560 Doesn't Respond

Answers: 5

body:
 1. Check if you have selected the right board
 2. Have you installed FTDI drivers? If you have installed them update them to the latest version. They can be found [here](http://www.ftdichip.com/Drivers/VCP.htm) (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.

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

body:
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`

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

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


body: Basically I want a contact to a socket (keep open) for sending strings and characters as well as receiving them. I do not want anything to do with web. I am writing my own server in vb and actually have that working. I also have working the Arduino ethernetshield. I just wanted an alternative wifi solution.

title: Client or WiFiClient wrapper for adafruit CC3000 wifi other than web

Answers: 0


body:
I am trying to write to a XML file.

I can write some values but limited. When I add an extra line or value the xml file stop updating and all commands I have after the xml.close(); aren't executed

      File xml = FileSystem.open("/mnt/sda1/Data/data.xml", FILE_WRITE); // open the file
      if(xml){
        Serial.println("XML Opened");
        xml.println("<?xml version=\'1.0\' encoding=\'UTF-8\'?> ");
        xml.println("<sea>");
          xml.println("\t<temperatures>"); //ASCII control codes (TAB)
            xml.print("\t\t<water>");
              xml.print(waterTmp);
            xml.println("</water>");
          xml.println("\t</temperatures>");
        xml.println("</sea>");

        xml.close();
      }
      else{
        Serial.print("XML Error");
      }

For e.g if I add

    xml.print("\t\t<air>");
    xml.print(airTMP);
    xml.println("</air>");

If this lines of code are alone in a sketch everything is good.
Another strange thing is if I add the same line twice or more times it can write them to the file.

Do you have any idea how this problem could be solved?

title: Arduino Yun. Write to XML file problem

Answers: 0


body:
I bought an Arduino-compatible Freaduino board atmega8 (I selected the board type as Arduino ng or older atmega8). I installed the Arduino IDE on Mac OS X and the FTDI drivers. But my serial port looks like this when I connect the board:

![screenshot 1](https://i.stack.imgur.com/Qjd7o.png)

And when I try to upload the program, this is the error I get:

![screenshot 2](https://i.stack.imgur.com/w97Vv.png)

Can someone tell me what is the mistake? I am clueless.

**UPDATE**: the problem was I had not installed the driver properly (I guess). I uninstalled and reinstalled them and it worked perfectly. Also made a YouTube tutorial regarding the same. http://youtu.be/BwatajQO_88

title: Arduino compatible's serial port not showing Mac OSX

Answers: 4

body:
http://arduino.cc/en/guide/macOSX

That link should almost definitely get it working for you.  Ensure (as in Step 7) that the board you have is the same one that is selected in Tools->Board.

And in step 8, since you have connected via a USB cable, it should be one of the USB named options.

body:
From the OSX System Report we learn that your board is based on an SiLabs CP2102 converter (or workalike), but according to your question you installed the drivers for an entirely different product from FTDI

(Arduino.cc has used FTDI in the past and CDC/ACM today, I don't believe they have ever used SiLabs so their instructions probably don't cover that, but other vendors obviously have)

Install the CP2102 drivers and it should work if you use the /dev/tty.XX device which then appears when you plug in the board.

SiLabs appears to provide the drivers at

http://www.silabs.com/products/mcu/pages/usbtouartbridgevcpdrivers.aspx

Just for sake of completeness, there are *at least* 5 distinct protocols/chips in use for serial-like USB communication with embedded devices:

FTDI

CDC/ACM Virtual Com Port

SiLabs CP210x

Prolific PL-2303

ch340

(Additional possibilities could include actual RS232 serial or serial-over-bluetooth)

body:
just to add to the list - some cheaper boards use **CH340** chipset

here is a blogpost on how to install the drivers on OSX
http://javacolors.blogspot.ie/2014/08/dccduino-usb-drivers-ch340-ch341-chipset.html

From that post:

You can find drivers for this chip on the web site of the chinese manufacturer, here :

http://www.wch.cn/downloads.php?name=pro&proid=5

body:
If you still have problems, like me after following the above, this might help:
From this thread: http://forum.arduino.cc/index.php?topic=292284.msg2229300#msg2229300

>  the problem is in the spaces of the device name. To fix that you have to manually edit two (2) txt files of the arduino installation.
>
> Go where you have installed it. In my case the path is:
>
> /Users/MY_USERNAME/Downloads/Arduino.app/Contents/Java/hardware/arduino/avr
>
> Inside this directory you can see files platform.txt &
> programmers.txt.
>
> Inside these files replace -P{serial.port} with "-P{serial.port}". So
> you simply have to add the quotes.

Then restart.


body:
I have a problem regarding Seeedstudio Bluetooth shield http://www.seeedstudio.com/depot/Bluetooth-Shield-p-866.html

I can't detect its presence by any other devices.

The code I uploaded to Arduino is a standard example for slave device from the library:

    #include <SoftwareSerial.h>   //Software Serial Port
    #define RxD 6
    #define TxD 7

    #define DEBUG_ENABLED  1

    SoftwareSerial blueToothSerial(RxD,TxD);

    void setup()
    {
        Serial.begin(9600);
        pinMode(RxD, INPUT);
        pinMode(TxD, OUTPUT);
        setupBlueToothConnection();
    }

    void loop()
    {
        char recvChar;
        while(1)
        {
            if(blueToothSerial.available()){//check if there's any data sent from the remote bluetooth shield
                recvChar = blueToothSerial.read();
                Serial.print(recvChar);
            }
            if(Serial.available()){//check if there's any data sent from the local serial terminal, you can add the other applications here
                recvChar  = Serial.read();
                blueToothSerial.print(recvChar);
            }
        }
    }

    void setupBlueToothConnection()
    {
        blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
        blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
        blueToothSerial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave"
        blueToothSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
        blueToothSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
        delay(2000); // This delay is required.
        blueToothSerial.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
        Serial.println("The slave bluetooth is inquirable!");
        delay(2000); // This delay is required.
        blueToothSerial.flush();
    }

I've uploaded it to Arduino UNO, connected the shield.

LED marked as D1 is blinking green, and D2 is switched off. The device is not detected by none of the  devices I've tried

Please Help Me

title: Arduino Uno R3 Bluetooth Shield is not discovering in any of the device

Answers: 1

body:
As per this site: http://www.rjanick.com/2012/11/26/seeed-studio-bluetooth-shield/

Try switching the `#define rxd` and `#define txd` pin numbers in the code, inversely corresponding to the ones that the jumpers are connected to on the board.

For instance: my pins are jumped from the BT_TX line to digital 6 (and BT_RX to pin 7), so in the code I write `#define TxD 7`, and `RxD 6`. This made the board's LEDs blink differently (red blinks on D2 until connection).


body:
Im a newbie on this arduino thing and I would like to build a curtain remotecontrolled from a local webpage with 2 buttons... a up an a down...

I got the connection via my phone the the local page with the buttons. :D

My problem on this one is that the buttons' if statement (command == on); doesnt work or in other words the client.println(command); get the "on" command and write it on the page... but it dont do the function in the if statement (the button)...

Can anybody help me...? it should be simple..:D

        #include <Bridge.h>
        #include <YunServer.h>
        #include <YunClient.h>

        int LEDPIN = 3; // your LED PIN
        YunServer server;

        String readString;

        void setup() {
      // Start our connection
      Serial.begin(9600);
      pinMode(LEDPIN,OUTPUT);
      digitalWrite(LEDPIN,HIGH); // turn on Led while connecting
      Bridge.begin();

      // Show a fancy flash pattern once connected
      digitalWrite(LEDPIN,LOW);
      delay(150);
      digitalWrite(LEDPIN,HIGH);
      delay(150);
      digitalWrite(LEDPIN,LOW);
      delay(150);
      digitalWrite(LEDPIN,HIGH);
      delay(150);
      digitalWrite(LEDPIN,LOW);
      delay(150);

      // Disable for some connections:
      // Start listening for connections

      // server.listenOnLocalhost();
      server.begin();

    }

    /* ------------------------------------------------*/
    /* --------------- End WIFI connection ------------*/
    /* ------------------------------------------------*/

    void loop() {
      YunClient client = server.accept();
      if (client) {
          process(client);
        client.stop();
      }
      delay(50);
    }

    void process(YunClient client) {
      String command = client.readStringUntil('\\');

      client.println("Status: 200");
      client.println("Content-type: text/html");
      client.println();
      client.println("

");
      client.println("ON

");
      client.println("OFF

");
      client.print("Command: ");
      client.println(command);
      client.println("");

    /* ------------------------------------------------*/
    /* ------------------- Buttons --------------------*/
    /* ------------------------------------------------*/

      if (command == "on") {
        digitalWrite(LEDPIN,HIGH);
        digitalWrite(13,HIGH);
      }

      if (command == "off") {
        digitalWrite(LEDPIN,LOW);
         digitalWrite(13,LOW);
      }
    }

title: Wifi server to control led on and off from local webpage.. - ..if statement doesnt work...

Answers: 1

body:
Pretty sure your problem is coming from the fact that you chose to use the backslash as your terminator character. The backslash requires special handling when encoded as a URL. You can observe this by Googling for "\" and and the results page you'll see your query in the address bar assigned to the "q" variable:
q=\
my entire URL looked like this, you may have something a bit different:
https://www.google.com/?gws_rd=ssl#q=\

Ok - so if you want a quick fix, stop using the \ to terminate your commands, since backslashes are often used to help sort out special characters (like "TAB" as \t) it's a a really bad choice, but an honest mistake.

If you change your code to generate links terminated with dashes you can get around the issue

    client.println("ON

");
    client.println("OFF

");

and of course change your readStringUntil invocation too

    client.readStringUntil('-');

Edit:
You might want to use the "_" if the hostname part of your URL contains a space:
http://my-web-server.com/on_

And one more alternative, seek the "%" instead since that's going to be used to encode the backslash. In that case you just need to change the readStringUntil()


body:
When I am trying to compile the following code,

    int delayTime = 1;
    int charBreak = 2.1;
    #include <MemoryFree.h>

    int rled1 = 1;
    int rled2 = 2;
    int rled3 = 3;
    int rled4 = 4;
    int rled5 = 5;
    int gled1 = 6;
    int gled2 = 7;
    int gled3 = 8;
    int gled4 = 9;
    int gled5 = 10;
    int bled1 = 11;
    int bled2 = 12;
    int bled3 = 13;
    int bled4 = 14;
    int bled5 = 15;

    void setup()
    {
      Serial.begin(9600);
    }

    int ra[] = {4,288,18464,288,4};
    int ga[] = {2,144,9232,144,2};
    int ba[] = {1,72,4616,72,2};
    int rb[] = {18724,16644,16644,2080,0};
    int gb[] = {9362,8322,8322,1040,0};
    int bb[] = {4681,4161,4161,520,0};
    int rc[] = {2336,16388,16388,2080,0};
    int gc[] = {1168,8194,8194,1040,0};
    int bc[] = {584,4097,4097,520,0};
    int rd[] = {18724,16388,16388,2336,0};
    int gd[] = {9362,8194,8194,1168,0};
    int bd[] = {4681,4097,4097,584,0};
    int re[] = {18724,16644,16644,16388,0};
    int ge[] = {9362,8322,8322,8194,0};
    int be[] = {4681,4161,4161,4097,0};
    int rf[] = {18724,16640,16640,16384,0};
    int gf[] = {9362,8320,8320,8192,0};
    int bf[] = {4681,4160,4160,4096,0};
    int rg[] = {2336,16388,16420,16416,2084};
    int gg[] = {1168,8194,8210,8208,1042};
    int bg[] = {584,4097,4105,4104,521};
    int rh[] = {18724,256,256,256,18724};
    int gh[] = {9362,128,128,128,9362};
    int bh[] = {4681,64,64,64,4681};
    int ri[] = {0,16388,18724,16388,0};
    int gi[] = {0,8194,9362,8194,0};
    int bi[] = {0,4097,4681,4097,0};
    int rj[] = {32,4,16388,18720,16384};
    int gj[] = {16,2,8194,9360,8192};
    int bj[] = {8,1,4097,4680,4096};
    int rk[] = {18724,256,2080,16388,0};
    int gk[] = {9362,128,1040,8194,0};
    int bk[] = {4681,64,520,4097,0};
    int rl[] = {18724,4,4,4,0};
    int gm[] = {9362,2,2,2,0};
    int bm[] = {4681,1,1,1,0};
    int rm[] = {18724,2304,36,2304,18724};
    int gm[] = {9362,1152,18,1152,9362};
    int bm[] = {4681,576,9,576,4681};
    int rn[] = {18724,2304,36,18724,0};
    int gn[] = {9362,1152,18,9362,0};
    int bn[] = {4681,576,9,4681,0};
    int ro[] = {2336,16388,16388,2336,0};
    int go[] = {1168,8194,8194,1168,0};
    int bo[] = {584,4097,4097,584,0};
    int rp[] = {18724,16640,16640,2048,0};
    int gp[] = {9362,8320,8320,1024,0};
    int bp[] = {4681,4160,4160,512,0};
    int rq[] = {2336,16388,16420,2336,36};
    int gq[] = {1168,8194,8210,1168,18};
    int bq[] = {584,4097,4105,584,9};
    int rr[] = {18724,16640,16672,2052,0};
    int gr[] = {9362,8320,8336,1026,0};
    int br[] = {4681,4160,4168,513,0};
    int rs[] = {2048,16644,16644,32,0};
    int gs[] = {1024,8322,8322,16,0};
    int bs[] = {512,4161,4161,8,0};
    int rt[] = {16384,16384,18724,16384,16384};
    int gt[] = {8192,8192,9362,8192,8192};
    int bt[] = {4096,4096,4681,4096,4096};
    int ru[] = {18720,4,4,18720,0};
    int gu[] = {9360,2,2,9360,0};
    int bu[] = {4680,1,1,4680,0};
    int rv[] = {18432,288,4,288,18432};
    int gv[] = {9216,144,2,144,9216};
    int bv[] = {4608,72,1,72,4608};
    int rw[] = {18688,36,2304,36,18688};
    int gw[] = {9344,18,1152,18,9344};
    int bw[] = {4672,9,576,9,4672};
    int rx[] = {16388,2080,256,2080,16388};
    int gx[] = {8194,1040,128,1040,8194};
    int bx[] = {4097,520,64,520,4097};
    int ry[] = {16388,2080,256,2048,16384};
    int gy[] = {8194,1040,128,1024,8192};
    int by[] = {4097,520,64,512,4096};
    int rz[] = {16420,16644,16644,18436,0};
    int gz[] = {8210,8322,8322,9218,0};
    int bz[] = {4105,4161,4161,4609,0};
    int reos[] = {0,4,0,0,0};
    int geos[] = {0,2,0,0,0};
    int beos[] = {0,1,0,0,0};
    int rque[] = {2048,16420,16640,2048,0};
    int gque[] = {1024,8210,8320,1024,0};
    int bque[] = {512,4105,4160,512,0};
    int rexcl[] = {0,18692,0,0,0};
    int gexcl[] = {0,9346,0,0,0};
    int bexcl[] = {0,4673,0,0,0};

    void displayLine(int line)
    {
      int myline; myline = line;
      if (myline>=16384) {digitalWrite(rled1, HIGH); myline-=16384;} else {digitalWrite(rled1, LOW);}
      if (myline>=8192) {digitalWrite(gled1, HIGH); myline-=8192;} else {digitalWrite(gled1, LOW);}
      if (myline>=4096) {digitalWrite(bled1, HIGH); myline-=4096;} else {digitalWrite(bled1, LOW);}
      if (myline>=2048) {digitalWrite(rled2, HIGH); myline-=2048;} else {digitalWrite(rled2, LOW);}
      if (myline>=1024) {digitalWrite(gled2, HIGH); myline-=1024;} else {digitalWrite(gled2, LOW);}
      if (myline>=512) {digitalWrite(bled2, HIGH); myline-=512;} else {digitalWrite(bled2, LOW);}
      if (myline>=256) {digitalWrite(rled3, HIGH); myline-=256;} else {digitalWrite(rled3, LOW);}
      if (myline>=128) {digitalWrite(gled3, HIGH); myline-=128;} else {digitalWrite(gled3, LOW);}
      if (myline>=64) {digitalWrite(bled3, HIGH); myline-=64;} else {digitalWrite(bled3, LOW);}
      if (myline>=32) {digitalWrite(rled4, HIGH); myline-=32;} else {digitalWrite(rled4, LOW);}
      if (myline>=16) {digitalWrite(gled4, HIGH); myline-=16;} else {digitalWrite(gled4, LOW);}
      if (myline>=8) {digitalWrite(bled4, HIGH); myline-=8;} else {digitalWrite(bled4, LOW);}
      if (myline>=4) {digitalWrite(rled5, HIGH); myline-=4;} else {digitalWrite(rled5, LOW);}
      if (myline>=2) {digitalWrite(gled5, HIGH); myline-=2;} else {digitalWrite(gled5, LOW);}
      if (myline>=1) {digitalWrite(bled5, HIGH); myline-=1;} else {digitalWrite(bled5, LOW);}

    }

    void displayChar(char c)
    {
      if (c == 'ra'){for (int i = 0; i <5; i++){displayLine(ra[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rb'){for (int i = 0; i <5; i++){displayLine(rb[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rc'){for (int i = 0; i <5; i++){displayLine(rc2[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rd'){for (int i = 0; i <5; i++){displayLine(rd[i]);delay(delayTime);}displayLine(0);}
      if (c == 're'){for (int i = 0; i <5; i++){displayLine(re[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rf'){for (int i = 0; i <5; i++){displayLine(rf[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rg'){for (int i = 0; i <5; i++){displayLine(rg[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rh'){for (int i = 0; i <5; i++){displayLine(rh[i]);delay(delayTime);}displayLine(0);}
      if (c == 'ri'){for (int it = 0; it <5; it++){displayLine(ri[it]);delay(delayTime);}displayLine(0);}
      if (c == 'rj'){for (int i = 0; i <5; i++){displayLine(rj[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rk'){for (int i = 0; i <5; i++){displayLine(rk[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rl'){for (int i = 0; i <5; i++){displayLine(rl[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rm'){for (int i = 0; i <5; i++){displayLine(rm[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rn'){for (int i = 0; i <5; i++){displayLine(rn[i]);delay(delayTime);}displayLine(0);}
      if (c == 'ro'){for (int i = 0; i <5; i++){displayLine(ro[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rp'){for (int i = 0; i <5; i++){displayLine(rp[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rq'){for (int i = 0; i <5; i++){displayLine(rq[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rr'){for (int i = 0; i <5; i++){displayLine(rr[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rs'){for (int i = 0; i <5; i++){displayLine(rs[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rt'){for (int i = 0; i <5; i++){displayLine(rt[i]);delay(delayTime);}displayLine(0);}
      if (c == 'ru'){for (int i = 0; i <5; i++){displayLine(ru[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rv'){for (int i = 0; i <5; i++){displayLine(rv[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rw'){for (int i = 0; i <5; i++){displayLine(rw[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rx'){for (int i = 0; i <5; i++){displayLine(rx[i]);delay(delayTime);}displayLine(0);}
      if (c == 'ry'){for (int i = 0; i <5; i++){displayLine(ry[i]);delay(delayTime);}displayLine(0);}
      if (c == 'rz'){for (int i = 0; i <5; i++){displayLine(rz[i]);delay(delayTime);}displayLine(0);}
      if (c == 'r!'){for (int i = 0; i <5; i++){displayLine(rexcl[i]);delay(delayTime);}displayLine(0);}
      if (c == 'r?'){for (int i = 0; i <5; i++){displayLine(rques[i]);delay(delayTime);}displayLine(0);}
      if (c == 'r.'){for (int i = 0; i <5; i++){displayLine(reos[i]);delay(delayTime);}displayLine(0);}
      if (c == 'ga'){for (int i = 0; i <5; i++){displayLine(ga[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gb'){for (int i = 0; i <5; i++){displayLine(gb[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gc'){for (int i = 0; i <5; i++){displayLine(gc2[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gd'){for (int i = 0; i <5; i++){displayLine(gd[i]);delay(delayTime);}displayLine(0);}
      if (c == 'ge'){for (int i = 0; i <5; i++){displayLine(ge[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gf'){for (int i = 0; i <5; i++){displayLine(gf[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gg'){for (int i = 0; i <5; i++){displayLine(gg[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gh'){for (int i = 0; i <5; i++){displayLine(gh[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gi'){for (int it = 0; it <5; it++){displayLine(gi[it]);delay(delayTime);}displayLine(0);}
      if (c == 'gj'){for (int i = 0; i <5; i++){displayLine(gj[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gk'){for (int i = 0; i <5; i++){displayLine(gk[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gl'){for (int i = 0; i <5; i++){displayLine(gl[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gm'){for (int i = 0; i <5; i++){displayLine(gm[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gn'){for (int i = 0; i <5; i++){displayLine(gn[i]);delay(delayTime);}displayLine(0);}
      if (c == 'go'){for (int i = 0; i <5; i++){displayLine(go[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gp'){for (int i = 0; i <5; i++){displayLine(gp[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gq'){for (int i = 0; i <5; i++){displayLine(gq[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gr'){for (int i = 0; i <5; i++){displayLine(gr[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gs'){for (int i = 0; i <5; i++){displayLine(gs[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gt'){for (int i = 0; i <5; i++){displayLine(gt[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gu'){for (int i = 0; i <5; i++){displayLine(gu[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gv'){for (int i = 0; i <5; i++){displayLine(gv[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gw'){for (int i = 0; i <5; i++){displayLine(gw[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gx'){for (int i = 0; i <5; i++){displayLine(gx[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gy'){for (int i = 0; i <5; i++){displayLine(gy[i]);delay(delayTime);}displayLine(0);}
      if (c == 'gz'){for (int i = 0; i <5; i++){displayLine(gz[i]);delay(delayTime);}displayLine(0);}
      if (c == 'g!'){for (int i = 0; i <5; i++){displayLine(gexcl[i]);delay(delayTime);}displayLine(0);}
      if (c == 'g?'){for (int i = 0; i <5; i++){displayLine(gques[i]);delay(delayTime);}displayLine(0);}
      if (c == 'g.'){for (int i = 0; i <5; i++){displayLine(geos[i]);delay(delayTime);}displayLine(0);}
      if (c == 'ba'){for (int i = 0; i <5; i++){displayLine(ba[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bb'){for (int i = 0; i <5; i++){displayLine(bb[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bc'){for (int i = 0; i <5; i++){displayLine(bc2[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bd'){for (int i = 0; i <5; i++){displayLine(bd[i]);delay(delayTime);}displayLine(0);}
      if (c == 'be'){for (int i = 0; i <5; i++){displayLine(be[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bf'){for (int i = 0; i <5; i++){displayLine(bf[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bg'){for (int i = 0; i <5; i++){displayLine(bg[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bh'){for (int i = 0; i <5; i++){displayLine(bh[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bi'){for (int it = 0; it <5; it++){displayLine(bi[it]);delay(delayTime);}displayLine(0);}
      if (c == 'bj'){for (int i = 0; i <5; i++){displayLine(bj[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bk'){for (int i = 0; i <5; i++){displayLine(bk[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bl'){for (int i = 0; i <5; i++){displayLine(bl[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bm'){for (int i = 0; i <5; i++){displayLine(bm[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bn'){for (int i = 0; i <5; i++){displayLine(bn[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bo'){for (int i = 0; i <5; i++){displayLine(bo[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bp'){for (int i = 0; i <5; i++){displayLine(bp[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bq'){for (int i = 0; i <5; i++){displayLine(bq[i]);delay(delayTime);}displayLine(0);}
      if (c == 'br'){for (int i = 0; i <5; i++){displayLine(br[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bs'){for (int i = 0; i <5; i++){displayLine(bs[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bt'){for (int i = 0; i <5; i++){displayLine(bt[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bu'){for (int i = 0; i <5; i++){displayLine(bu[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bv'){for (int i = 0; i <5; i++){displayLine(bv[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bw'){for (int i = 0; i <5; i++){displayLine(bw[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bx'){for (int i = 0; i <5; i++){displayLine(bx[i]);delay(delayTime);}displayLine(0);}
      if (c == 'by'){for (int i = 0; i <5; i++){displayLine(by[i]);delay(delayTime);}displayLine(0);}
      if (c == 'bz'){for (int i = 0; i <5; i++){displayLine(bz[i]);delay(delayTime);}displayLine(0);}
      if (c == 'b!'){for (int i = 0; i <5; i++){displayLine(bexcl[i]);delay(delayTime);}displayLine(0);}
      if (c == 'b?'){for (int i = 0; i <5; i++){displayLine(bques[i]);delay(delayTime);}displayLine(0);}
      if (c == 'b.'){for (int i = 0; i <5; i++){displayLine(beos[i]);delay(delayTime);}displayLine(0);}
      delay(charBreak);
    }

    void displayString(char* s)
    {
      for (int i = 0; i<=strlen(s); i++)
      {
      displayChar(s[i]);
      }
    }

    void loop()
    {
      displayString("sunil");
      Serial.print("freeMemory()=");
        Serial.println(freeMemory());
    }
I am getting the following error.

    sketch_jul17b:63: error: redefinition of 'int gm []'
    sketch_jul17b:60: error: 'int gm [5]' previously defined here
    sketch_jul17b:64: error: redefinition of 'int bm []'
    sketch_jul17b:61: error: 'int bm [5]' previously defined here
    sketch_jul17b.ino: In function 'void displayChar(char)':
    sketch_jul17b:139: error: 'rc2' was not declared in this scope
    sketch_jul17b:164: error: 'rques' was not declared in this scope
    sketch_jul17b:168: error: 'gc2' was not declared in this scope
    sketch_jul17b:177: error: 'gl' was not declared in this scope
    sketch_jul17b:193: error: 'gques' was not declared in this scope
    sketch_jul17b:197: error: 'bc2' was not declared in this scope
    sketch_jul17b:206: error: 'bl' was not declared in this scope
    sketch_jul17b:222: error: 'bques' was not declared in this scope
I don't know why this error is occurring.

title: error: redefinition of ' '

Answers: 3

body:
You have a combination of trying to define the same name twice, for example "gm"

    int gm[] = {9362,2,2,2,0};
    int bm[] = {4681,1,1,1,0};
    int rm[] = {18724,2304,36,2304,18724};
    int gm[] = {9362,1152,18,1152,9362};

And using others such "rc2" which you have never defined.

Your code won't compile and work until you make it self-consistent.

body:
The first errors happen because you are trying to define a variable with the same name in the same scope twice, like here:

    int gm[] = {9362,2,2,2,0};
    int bm[] = {4681,1,1,1,0};
    int rm[] = {18724,2304,36,2304,18724};
    int gm[] = {9362,1152,18,1152,9362};

gm is defined two times which is not allowed.

The other error happens because you are referencing variables you never declared like here:

    if (c == 'rc'){for (int i = 0; i <5; i++){displayLine(rc2[i]);delay(delayTime);}displayLine(0);}

rc2 isn't defined anywhere.

----------

Besides there are some other issues with your code:

    int charBreak = 2.1;

`int` types can only contain whole numbers, so `charBreak` will be set to two and not two point one. You probably wan't to use a `float`.

In `void displayChar(char c)` you try to compare a char with two chars:

    if (c == 'ra')

That won't work. The char type can only contain a single character, so the comparison will always be false. Two chars like this `'ab'` in single quotes are interpreted as 16 bit number. Two chars in double quotes are interpreted as a null-terminated string:

    char cstring1[] = "ab";
    char cstring2[] = {'a', 'b', '\0'};

    if (strcmp(cstring1, cstring2) == 0)
      // The two strings are identical

`strcmp` returns 0 on match-.

body: This can also happen if you have saved a version of the code (for example duplicate file for backup) within the current sketch folder.


body:
I've recently ordered an Arduino Yun and several other components to begin on a small robotics project (based on an old 4x4 RC Truck).  Although not mandatory for what I'd like to do, I was wondering how feasible it would be to mount a small camera or two and write some software for the Linux portion of the Yun to do basic image/video analysis such as face detection and computer vision based path finding?

Mostly this is a question about the processing power capabilities of the Yun.  Has anyone had any luck doing simple image analysis/recognition on this processor?

(Also, if anyone with 150+ rep could edit this to create and add the "computer-vision" tag that would be great)

title: How useful could the Arduino Yun be in computer vision in a robotics project?

Answers: 4

body:
It probably has enough memory and speed to run [basic object recognition software][1], but I there's a better solution, and that's to do your image capture and your object recognition with another device, and use the Arduino to act on the incoming data in some way. That would give you enough juice to do object tracking or searching. I plan to do this for my copter gimbal hopefully to be able to track objects on the ground, like criminals running from the cops for example.

This product will work great for that. Since you need a camera anyway, I think this is a pretty good deal... http://petapixel.com/2013/09/01/pixy-low-cost-camera-recognizes-follows-objects-color/

Can be purchased here: http://www.adafruit.com/products/1906

AdaFruit has tutorials to help you get started.  (Computer-vision doesn't exist as a tag right now and I can't create it, but I tried, sorry)

  [1]: http://opencv.org/

body:
I am guessing not very useful. Image recognition is quite CPU-intensive, and Arduinos are slow, memory-starved, 8-bit processors.

The Unix side of the Yun runs at 400 MHz, which is quite a bit faster than the Arduino part, but still quite slow compared to a mobile phone or desktop computer. And 64MB of RAM isn't enough to hold even a single HD image, never mind the data you would need to have in RAM to do image analysis. You'd probably have to limit yourself to 640x480, and the slow processor and lack of enough flash for large code libraries would be a problem. (You've only got 16 MB of flash memory on the LINUX processor.) I don't know if you can run programs from an SD card or not. That might solve your code storage problems, but you're still going to struggle with 64 MB of RAM.

body:
Maybe you can consider adding Raspberry Pi board to run OpenCV which is well supported by hundreds of books and tutorials.  See 20 tutorial from initial setting up to running typical functions in http://www.stemapks.com/opencv.html

Also, http://opencv-srf.blogspot.hk/

Then, there are many examples / tutorial / book on linking Arduino to RPi.

On the other hand, from web demo, Pixy CMUcam5 seems very good as a semi-ready-made solution. Watch the demo and see if it does what you want. If yes, then, it is easy solution. OpenCV is a library, it can do many tricks but need learning.

Hope this helps

body:
For this application the Arduino YUN is the worst possible solution because

 - **Low** RAM
 - **Terrible** Processor
 - No storage (you can add a microSD card though)
 - **High** Cost

The raspberry Pi 2, UDOO, RADXA, Ordio, pretty much anything with a **quad core processor** and **1GB of RAM** will do a **decent job**.

Face detection is RAM intensive, so you will need to worry about it lagging.

Alternatively you could also have the image processing part be done elsewhere like on a server (on a local network this could be your laptop) or something.

**Personally**,I would never recommend the Arduino YUN because it just simply isnt worth paying the 75$ for when for about the same price you could have a arduino pro micro and a raspberry pi (with a WiFi adapter, mircoSD card etc.) which is capable of doing probably way more than you actually need to.


body:
Today I got Arduino Leonardo to replace my Uno. I've tried running one of sketches I use on the Uno, but with no luck. When I start the upload, RX LED on the Leonardo flashes few times, and after several seconds, L LED pulsates and I get this message:

    avrdude: ser_open(): can't open device "\\.\COM9": The system cannot find the file specified.

    avrdude: ser_send(): write error: sorry no info avail
I've checked in *Device Manager*, where it says that Arduino Leonardo is on COM3, and COM3 is also set in Arduino IDE.

However, when I change COM port to 9 in *Device Manager* and also in Arduino IDE and then try to upload the sketch, things start to roll out like above, but this time IDE freezes for 5-10 mins on "Uploading..." part, and finally unfreezes with this message:

    Found programmer: Id = "B¨J"; type =
        Software Version =
    avrdude: error: buffered memory access not supported. Maybe it isn't
    a butterfly/AVR109 but a AVR910 device?
Several more infos:

    - OS: Win7 64-bit
    - Arduino IDE: 1.0.5-r2
    - Other serial devices: Only Bluetooth that I've manually assigned to COM200, to avoid possible conflicts.

title: Problem loading sketch to Leonardo

Answers: 2

body:
Per [imjosh](https://arduino.stackexchange.com/users/497/imjosh)'s suggestion, I've installed IDE version 1.5.7 BETA and that solved my problem.
Thanks!

body: I had my Olimexino 32u4 connected to Axagon USB 3.0 hub and had problems not only to flash but also to find a board. Then plugged it directly to USB 2.0 port on my laptop and it worked. If you have problems with board communicating with PC try to change USB port it is connected to and also try different USB cables.


body:
The arduino has a USB port which can connect to a computer.  The cable used to make this connection has a standard USB connector at one end (that connects to the computer) and a "larger" connector on the opposite end (that connects to the arduino).  See picture below:

![enter image description here][1]

What is the name of this "larger" connector?

  [1]: https://i.stack.imgur.com/cDAFp.jpg

title: USB cable connector

Answers: 1

body:
They are both standard USB. The end which goes into the computer is type A (or USB-A), and the end which goes into the Arduino is type B (or USB-B). The USB-B connector is also commonly used on devices such as printers and scanners. The distinction mainly exists so it's obvious which device is the host (i.e. the computer) and which device is the client (i.e. the Arduino).

As a side note, other types of USB connector exist as well. You will probably be familiar with mini and micro USB connectors, which can be found on various devices such as digital cameras and mobile phones.


body:
I upgraded to Arduino 1.5.7 in hopes of using the command line interface for a larger project. However, the old package I was using to program the ATTiny85 chip with the Sparkfun Tiny AVR Programmer no longer works. I'm getting the following error:

    Third-party platform.txt does not define compiler.path. Please report this to the third-party hardware maintainer.
    processing.app.debug.RunnerException
     at processing.app.debug.Compiler.getCommandCompilerCPP(Compiler.java:597)
     at processing.app.debug.Compiler.compileFiles(Compiler.java:275)
     at processing.app.debug.Compiler.compileSketch(Compiler.java:642)
     at processing.app.debug.Compiler.compile(Compiler.java:125)
     at processing.app.Sketch.build(Sketch.java:1589)
     at processing.app.Sketch.exportApplet(Sketch.java:1611)
     at processing.app.Sketch.exportApplet(Sketch.java:1597)
     at processing.app.Editor$DefaultExportHandler.run(Editor.java:2397)
     at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.NullPointerException
     at processing.app.helpers.StringReplacer.replaceFromMapping(StringReplacer.java:97)
     at processing.app.helpers.StringReplacer.replaceFromMapping(StringReplacer.java:89)
     at processing.app.helpers.StringReplacer.formatAndSplit(StringReplacer.java:37)
     at processing.app.debug.Compiler.getCommandCompilerCPP(Compiler.java:595)
     ... 8 more

Does a package exist that will allow me to program the chip in 1.5.7?

title: Is programming the ATTiny85 possible in 1.5?

Answers: 1

body: You can download a version of arduino-tiny for IDE 1.5.x from [here](https://code.google.com/p/arduino-tiny/).