body:
    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x30
    avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x0f
    avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x10
    avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x20
    avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x0f
    avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x10
    avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x30
    avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x0f
    avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x10
    avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x20

title: sketch uploading give error?

Answers: 2

body:
This [Instructables post][1] has a list of potential causes for this error. Is this a new board? What board are you using? Is it a genuine Arduino board or a clone? Have you been able to upload to the board previously?

  [1]: http://www.instructables.com/id/A-solution-to-avrdude-stk500getsync-not-in-syn/

body:
Have you changed the atmega328 chip? If you have the new one may not have a bootloader or it may have one for a different board. Select every board option. Duemillemova maybe?
If you still have no luck, you might have over written your bootloader. Try burning the bootloader again. Instructables shows you how.


body:
Atmel stated in their website:

> Atmel Studio 7 features seamless one-click import of projects created in the Arduino development environment. Your sketch, including any libraries it references, will be imported into Studio 7 as a C++ project. Once imported, you can leverage the full capabilities of Studio 7 to fine-tune and debug your design. Atmel Studio 7 fully supports the powerful embedded debugger on the Arduino Zero board. For other Arduino boards, shield-adapters that expose debug connectors are available, or switch to one of the many available Xplained-Mini/PRO boards to fully leverage the Atmel HW eco-system. Regardless of what you choose, you will surely make something amazing.

I wonder how they do it? Is it just a plug-in meaning that we still have to install Arduino software? Or do they have their own compiler and debugger?

title: How Atmel Studio 7 compile Arduino code?

Answers: 2

body:
It is almost always the case that a high-level environment like an IDE provides an interface to an existing tool-chain rather than being truly an all-in-one mega-application, which would a maintenance nightmare. Atmel Studio 7 is no exception, and [according to Atmel][1], uses and includes (quite likely by downloading it during the install process) the GCC tool-chain.

> Why Atmel Studio asked about Arduino IDE path when I try to import Arduino sketch?

Probably for the Arduino libraries, which are contained within the Arduino IDE executable.

  [1]: http://www.atmel.com/Microsite/atmel-studio/compiler-editor.aspx

body:
Atmel Studio allows for the arduino .ino file to actually be compiled as a c++ project. Doing so allows true debugging, and stepping through all arduino code. It was actually insightful as it walked me through **ARDUINO's main() function**, which is normally tucked away nicely in a library never to be seen.

The IDE allows for highly useful features such as refactoring, find and replace, syntax highlighting and much more. I found it very useful, and a pleasant upgrade from the arduino IDE.

I often switch back and forth between the Arduino IDE and Atmel Studio, very easy to do.

Installing the Arduino software allows Atmel Studio to locate the libraries when it is installed.

By installing the Vmicro(visual Micro) toolbar, things really come together, and seem very seamless.

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

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


body: I want to have an Arduino based game you can play on a nokia 5110 screen. The problem is you cant make a medium sized game on an Arduino because the flash size is only 32k. I sit possible to have multiple Arduino's connected to each other, communicating to make it possible to have a bigger game. If it is possible how does it work?

title: How to have arduinos work together?

Answers: 3

body:
Yes and no.

Yes you can make Arduinos communicate with each other and send messages to each other.

Can you use that to make a game?  Possibly.

Is it worth the effort?  No.

It would be a huge amount of work and be overly complex when you could just use a bigger Arduino, like a Mega2560 or a Due.

body:
You can have two Arduinos communicate with each other but it is fairly complex.  See this [instructable][1].  One process is using the I2C protocol.

A far easier option is to use a larger Arduino [model][2].  Consider the Mega 2560 since it has 8 times the Flash memory.

  [1]: http://www.instructables.com/id/I2C-between-Arduinos/?ALLSTEPS
  [2]: https://www.arduino.cc/en/Products/Compare

body:
You **can** make quite an impressive game.

[![Toorum's Quest][1]][1]

**Features**

* Based on ATmega328P running at 16 Mhz (same as Arduino Uno).
* The game has a display resolution of 104x80 with 256 colors.
* Video mode is tile based and supports up to 3 sprites per scan line.
* Sprites are multiplexed so there can be unlimited number of sprites vertically on the screen.
* 4 audio channels with triangle, pulse, sawtooth and noise waveforms.
* Chiptune music playroutine and sound effects.
* NES controller support.

Video of it in action:

<https://www.youtube.com/watch?v=sLvgW_zb6bQ>

Original [post on the Arduino forum](http://forum.arduino.cc/index.php?topic=197983.0).

---

So, before you start wanting to connect lots of Arduinos together, investigate what can be achieved with just one. :)

The first thing to do, as others have mentioned, is to store static information into PROGMEM (see [Putting constant data into program memory (PROGMEM)](http://www.gammon.com.au/progmem) for more details).

If Petri Häkkinen can get his title screen, levels, sprites, music, and game logic into an Atmega328P you can too! Have fun!

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


body:
I have a simple question to ask you about SDA and SCL pins.
I have a gyro and I use these 2 pins to make it work; how can I use an accelerometer combined to a Gyro if these 2 pins are used? I should need another 2 SDA and SCL pins for the accelerometer... Tell me that I don't need to buy an IMU :D

EDIT: I'm using Gyro LG3D20H from Adafruit, reading gyro values each 10 ms.

title: SDA and SCL problem with MEMS

Answers: 1

body:
I2C is designed to have multiple devices connected. Assuming the gyro and accelerometer have different I2C addresses they can both be connected to the same SDA and SCL pins.

For more information see <http://www.gammon.com.au/i2c>

Naturally you can only "talk to" one at a time. You may need pull-up resistors on both SDA and SCL, unless the hardware already has them.


body:
I have a spare Arduino Uno lying around, which I figured I could attempt to turn into a game controller. First clear issue, that immediately popped up, was that there are not enough digital input pins on the board, but I think I can get around that by using analog pins with appropriate external resistors (is that actually a possibility?).

Another one, more severe, is that I'm not sure how I would need to go around wiring microswitch buttons with the board. Assuming they short the circuit when pushed (SPST), I could simply wire one contact to an input pin, set to `INPUT_PULLUP` mode, and connect the other to ground. However, since I know little about how such circuits work, I'm immediately in doubt about two things. Considering the board would be used as a controller, an external power source is out of question and I'd only want to rely on the USB power. Since I want to use plenty of buttons (up to fifteen), out of caution I'm worried that shorting this many input pins to the ground at once could overload the... regulator I think?

So my question is this: is it safe to use multiple, potentially simultaneously pressed, buttons connected to input pins on an Arduino Uno board, powered solely from a USB port? Additionally, just to be clear, is it normal to connect them all to a common ground on the board?

title: Arduino with multiple buttons - will power be an issue?

Answers: 2

body:
Yes, it is safe to connect multiple buttons to ground. The pull-up resistors have a fairly high value - about 10 kΩ and we know from Ohm's Law that

    I = V / R = 5 V / 10k = 0.5 mA

per button. Your USB power is good for about 500 mA.

Welcome to StackExchange.

body:
Most of your idea is sensible. Let's go over the sensible part first, and then we'll cover the bits that need work.

Using an internal pullup and shorting the input to ground is the correct way to approach this. Note that the pins will read `HIGH` when off and `LOW` when triggered this way.

Each pullup on an AVR is between 20kohm and 50kohm. This means that the current consumption if all 15 buttons are pressed is at most about \$15 \cdot {5 \text{V} \over 20\text{k}\Omega} = 3.75\text{mA}\$. This isn't enough for the USB connection to care about.

As for using the analog connections, A0 through A5 also have digital GPIO capability, which means that you would treat them exactly the same as you would the digital pins (A6 and A7 don't have digital GPIO unless you're running a ATmegaXX8PB with a special core).

And now the bad news.

The Arduino Uno is based on the ATmega328P, which *does not* have native USB capability. It communicates with the host through a serial connection via a USB-UART bridge. If you're using a real (or real-enough) Uno then that bridge is a ATmega16U2 which is a MCU that *does* have native USB capability, so it can be reprogrammed to interpret the serial stream from the '328P and talk USB to the host.

But if you aren't then you will either need to run a piece of software on the host that translates the serial stream to HID actions, or you will have to run a software USB stack on the '328P such as V-USB which will allow you to use Low-Speed USB 1.1 directly.

My recommendation is to see if you can get an Arduino or other AVR-based board that has an ATmegaXXU4 so that you can use `Mouse` and `Keyboard` directly instead of having to faff around with HID profiles and software USB. Unless that's your thing, of course.


body:
There is [this library][1], but it emulates only one throttle and one rudder. The X Y Z axis don't work because they are addressed from -127 to 127 and I need 0 to 255. I just need one more throttle axis. If it helps, I'm using an ATmega328 and read analog values in the 0 to 1024 range to read Logitech g27 pedals, then dividing by about 4 to fit the read value into the 0 to 255 range.

  [1]: https://github.com/MHeironimus/ArduinoJoystickLibrary

title: Does anyone know a library that can emulate 3 throttles?

Answers: 0


body:
I noticed timing inconsistencies in my project, and further debugging pinpointed it to the problem below. The text should be updating every second, but the returned values are >> 1000ms.

To clarify, the text is not showing up every second.  The delays between texts vary according to fluctuating start and finish values.

I'm using a Teensy 3.2. Changing the baud rate doesn't help.

Is my timing crystal busted? Is there a serial buffering issue? I don't know how to fix either of these.

[![example code][1]][1]

Any help would be appreciated!

Edit:

Here's the code if anyone wants to test.  I found that adding more delay functions screws the output up in completely unlinear ways.

<!-- language: c -->

    unsigned long start, finished, elapsed;

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

    void loop() {
      Serial.println("Start...");
      start = millis();
      Serial.println(start);
      delay(1000);
      finished = millis();
      Serial.println(finished);
      Serial.println("Finished");
      elapsed = finished - start;
      Serial.print(elapsed);
      Serial.println(" milliseconds elapsed");
      Serial.println();
    }

Edit #2:

I thought it was worth showing everyone this screenshot.  It looks like `delay(1000)` just isn't functioning at all.

[![screenshot][2]][2]

Edit #3:

I debugged it with an LED and it blinked at exactly 1s intervals.  It seems like `delay(1000)` works, so the problem must be related to the serial buffering.  I also updated my software but that didn't help.

Edit #4:

New developments from further debugging:

 - The problem is not reproducible on a different computer.  The Arduino serial monitor on other computers displays correctly.
 - Updating to the latest OSX, arduino IDE, and teensyduino did not help.
 - Terminal 'screen' command surprisingly prints correct serial communication.
 - Serial monitors from 3rd party apps, like CoolTerm and Arduino IDE do not work.

  [1]: https://i.stack.imgur.com/VuTQD.png
  [2]: https://i.stack.imgur.com/BprVs.png

title: Delay function broken?

Answers: 2

body:
After correcting the syntax error (missing semicolon) I tried your code on my Teensy 3.0. The results look OK to me:

    Start...
    1250
    2250
    Finished
    1000 milliseconds elapsed

    Start...
    2250
    3250
    Finished
    1000 milliseconds elapsed

    Start...
    3250
    4250
    Finished
    1000 milliseconds elapsed

    Start...
    4250
    5250
    Finished
    1000 milliseconds elapsed

    Start...
    5250
    6250
    Finished
    1000 milliseconds elapsed

    Start...
    6250
    7250
    Finished
    1000 milliseconds elapsed

    Start...
    7250
    8250
    Finished
    1000 milliseconds elapsed

    Start...
    8250
    9250
    Finished
    1000 milliseconds elapsed

---

Since the code you posted doesn't compile, can you re-test please with your posted code, assuming you add in the semicolon, and put a space before "milliseconds elapsed".

---

Further down my test I see this:

    Start...
    153258
    154258
    Finished
    1000 milliseconds elapsed

    Start...
    154259
    155259
    Finished
    1000 milliseconds elapsed

    Start...
    155259
    156259
    Finished
    1000 milliseconds elapsed

Now are you talking about the "creep" in the start time? That doesn't totally surprise me, because the rest of the code must take *some* time to execute.

---

*I know this isn't an "answer" per se, but I can't post this much information into a comment.*

body: Since the subtraction's result (`finished - start`) displays alright, it means the right number is being stored in the variable, so it's Serial that is screwing up the task of printing it. Try reducing the baud rate to 9600 and try again.


body:
I would like to get one information about this TFT LCD module . This particular module works with parallel interface with arduino mega and uno.

I am trying to get rid of arduino in my project and use esp8266 itself. I have this module http://www.aliexpress.com/item/3-5-inch-TFT-Touch-LCD-Screen-Display-Module-For-Arduino-UNO-R3-HIGH-QUALITY-Free/1854595985.html

This has only the parallel interface pins mentioned which requires around more than 10 pins to make it work. Is there any possibility that there is an SPI interface supported for this one by  making use of any of the existing pins for the parallel interface.

I don't think so but still can someone confirm that. If so I need to get SPI interface ready TFT LCDs.

Thanks,

title: 3.95 TFT LCD SPI or parallel interface

Answers: 1

body:
In general, no. The interface used by the chip is normally hard wired either in the connections to the Chip On Glass or in the connections of the shield (most commonly the former) and as such cannot really be changed.

You will need to either use a TFT screen that has the interface already set to SPI (and there are many) or use some form of SPI I/O expander to provide enough I/O pins to drive a parallel display.

Note that using SPI to communicate with a screen makes the screen updates considerably slower than using a parallel interface. The bigger the screen the slower it gets.


body:
i am looking to communicate text ( 40 char for each message ) between N arduino and a central one ( Communication is one way slaves to Master).I am looking for wire communication with 1 to 5 m distance.Does anyone know the best approach to do that ?

Vincent

title: Simple network protocol to communicate between N slave arduino and 1 central arduino?

Answers: 2

body:
You have quite a few options available to you as your requirements are filled by quite a few protocols, I am not going to list all. You can use things such as I2C, CAN, RS-485, RS-232.

You can find a few good examples from this [EE.SE][1] post from a search.

The CAN option is quite a good one for your application and is easy to set up and there are quite a few libraries available for the [common chip][2] MCP2525 and MCP2551. Yo can also get a 'shield' with this functionality from sparkfun.

The other options are discussed in the linked EE.SE post with regards to RS-485.

[I2C][3] can be implemented with the Wire library of arduinos and other libraries.

You can use RS-232, but I don't think it will be immune to noise at the distance you want, but you can still try. What you can do is use a multiplexer, such as this one [CD74HC4067][4], and use it to multiplex the TX line from each node to the RX of the master.

From SFE's site:

>  For example, you could use it to connect the TX pins of 16 devices to one RX pin on your microcontroller. You can then select any one of those 16 devices to listen to. If you want two-way communications, you can add a second board to route your microcontroller’s TX line to 16 device’s RX lines. By using multiple boards, you can create similar arrangements for I2C, SPI, etc.

You will probably want to add some sort of checksum/CRC to the data you send over the network too.

  [1]: https://electronics.stackexchange.com/questions/35773/communication-between-multiple-microcontrollers
  [2]: https://www.google.com/search?q=can controller IC&ie=utf-8&oe=utf-8
  [3]: https://en.wikipedia.org/wiki/I²C
  [4]: https://www.sparkfun.com/products/9056

body:
IMHO you should first decide your network topology.

If you want a "star" network, i.e. a network when every node is directly connected to the central one, you can use any protocol. Maybe even a multiplexed serial interface.

If you want a daisy chain interface or a bus one use can or RS485.

Personally I'd avoid I2C (it's good for on-board communication, but if the device is a few meters away the noise can break it).

My suggestion: use serial over half duplex RS485: you can get very low price physical interfaces. Since it is half duplex, only one can "speak", so the master first sends an address, then puts itself in listen mode and waits. The slave whose address was told puts itself in sending mode and sends the data.

This way you will have a bus (so you can simply attach a node to another node without having to place a wire till the masater) and you'll have a simple bus logic which will prevent the information to collide. And, most important, RS485 is very strong (up to 1km if I remember well).

CAN can (sorry) be simpler to use, since the anti-collision is "embedded" in the protocol, but it's a bit more complicated to use (you'll need a transceiver and to implement the whole logic in the microcontroller instead of using a dedicated peripheral like the serial interface).


body:
My project intend to command an Arduino UNO by my notebook without cable. I thought to use a RF Nordic nRF24L01 cabled on an Arduino UNO, and to use the wireless card of my notebook to send command to it. Is it possible? Any solution?
Is this hardware solution possible?

I need to send to Arduino four analog signals to setup the light of four led.

title: connection between Arduino Uno with nRF24L01 and notebook with wireless card

Answers: 1

body:
Absolutely no. Can you connect your bluetooth headset to the wireless router? No because even if they share the same band they "speak" different protocols. So why could you do that with the nRF24L01?

If you want to communicate with your PC you have three options:

 1. Choose nRF24L01. In this case, since the PC does not have that device, you will need to make an adapter (the easiest one could be an USB adapter). You can connect a microcontroller to a USB to serial converter and to the nRF24L01 and use it as a bridge.
 2. Choose Wifi. Then you'll need a new transceiver for the arduino UNO you are using (maybe the ESP8266, which is around 2$) but can be a bit more complicated for just sharing data (I never used it, though, so I can be wrong).
 3. Choose bluetooth. Usually this is my preferred way to communicate with a board. Cheap (the HC-06 module is about 2-3 $) and easy to use (the interface is a plain serial).

Good luck ;)


body:
I am trying to pass a class internal function as a callback function within the class. The error behavior is similar to [this problem][1]. Whatsoever, I was unable to construct working code based on that question's answer.

I try to pass over a callback function from within the class,in order to create a finite state machine, inspired by the examples I found on adafruit regarding multithreading. The idea is, that each state can call his successor. The class itself then represents the state machine and I just will call its update function.

While the following code does not resemble this utility, it resembles the problem in a minimal example (based on [this larger codepiece][2]):

    class MyClass
    {
      const byte theAnswer = 42;
      void (*myCallback)();

      void setCallback(void (*callback)())
      {
        myCallback = callback;
      }

      public:

      void print_info()
      {
        Serial.println(theAnswer);
      }

      void call()
      {
        myCallback();
      }

       MyClass()
      {
        setCallback(&MyClass::print_info);
      }
    };

    MyClass AClassOfItsOwn();

    void setup()
    {
      Serial.begin(9600);
      while (! Serial); // Wait until Serial is ready
    }

    void loop()
    {
      AClassOfItsOwn.call();
      return;
    }

I get the following error code returned:

> ...testscript.ino: In constructor 'MyClass::MyClass()':
>
> testscript:25: error: no matching function for call to
> 'MyClass::setCallback(void (MyClass::*)())'
>
>          setCallback(&MyClass::print_info);
>
>                                          ^
>
> ...\testscript.ino:25:41:
> note: candidate is:
>
> ...\testscript.ino:6:12:
> note: void MyClass::setCallback(void (*)())
>
>        void setCallback(void (*callback)())
>
>             ^
>
> ...\testscript.ino:6:12:
> note:   no known conversion for argument 1 from 'void (MyClass::*)()'
> to 'void (*)()'
>
> ...\testscript.ino:
> In function 'void loop()':
>
> testscript:40: error: request for member 'call' in 'AClassOfItsOwn',
> which is of non-class type 'MyClass()'
>
>        AClassOfItsOwn.call();
>
>                       ^
>
> exit status 1 no matching function for call to
> 'MyClass::setCallback(void (MyClass::*)())'

----------
**fun times with polymorphism**

This is code we discussed during looking for a solution. I leave it here for future reference.

I tried creating an instance of this wrapper within the actual class to hold the callback, but that did not work either.

    class CallbackWrapper
    {
      void (*myCallback)();
      public:

      void call()
      {
        myCallback();
      }

      void setCallback(void (*callback)())
      {
        myCallback = callback;
      }
    };

    class MyClass : public CallbackWrapper
    {
      const byte theAnswer = 42;
      public:

      void print_info()
      {
        Serial.println(theAnswer);
      }

       MyClass()
      {
        CallbackWrapper::setCallback(&MyClass::print_info);
      }
    };

trying to store the callback function in a wrapping class (also not working, `'((MyClass*)this)->MyClass::CBW' does not have class type`)

    class CallbackWrapper
    {
      void (*myCallback)();
      public:

      void call()
      { myCallback(); }

      void setCallback(void (*callback)())
      { myCallback = callback; }
    };

    class MyClass
    {
      const byte theAnswer = 42;
      CallbackWrapper CBW();
      public:
      void print_info() { Serial.println(theAnswer); }
      void call() { CBW.call(); }
      MyClass()
      { CBW.setCallback(&MyClass::print_info); }
    };

An update on why I want to change the callback function during runtime. Here I try to randomly change the callback function:

    class MyClass
    {
      CallbackWrapper CBW();
      public:
      void do_this() { Serial.println("doing this"); }
      void do_that() { Serial.println("doing that"); }
      void call()
      {
        CBW.call();
        if (rand() > 0.5)
        {
          CBW.setCallback(&MyClass::do_this)
        }
        else
        {
          CBW.setCallback(&MyClass::do_that)
        }
      }
       MyClass()
      {  }
    };

For discussion with Michail

    class CallbackWrapper
    {
      public:
      void (*myCallback)();
      void call()
      { myCallback(); }

      virtual void setCallback(void (*callback)())
      {  }
    };

    class MyClass : public CallbackWrapper
    {
      public:
      void setCallback(void (*callback)())
        { myCallback = callback; }
      void do_this() { Serial.println("doing this"); }
      void do_that() { Serial.println("doing that"); }
      void call()
      {
        CallbackWrapper::call();
        if (rand() > 0.5)
        { setCallback(&MyClass::do_this); }
        else
        { setCallback(&MyClass::do_that); }
      }
       MyClass()
      {  }
    };

  [1]: https://arduino.stackexchange.com/questions/14480/pass-a-member-function-pointer-to-a-method-of-a-foreign-class-edb-lib
  [2]: https://learn.adafruit.com/multi-tasking-the-arduino-part-3/put-it-all-together-dot-dot-dot

title: pass class internal function as callback

Answers: 1

body:
Unless you specifically limit yourself to one single class for a callback (i.e., include the class name in the function pointer specification) then you can ONLY use `static` member functions as callbacks.

`static` member functions appear as a normal function, not a member function, so don't have the implied `MyClass *this` as a first parameter.

If you want to allow member functions that aren't `static` you will have to make use of *polymorphism* and have a single *base* class that all classes which provide a callback function will inherit from.  Then you limit the callback function pointer to be members of that base class.

It is possible to do it if you are happy to limit to just one class, though the syntax is rather cryptic:

    class MyClass
    {
      const byte theAnswer = 42;
      void (MyClass::*myCallback)();

    public:

      void call() {
        (this->*myCallback)();
      }

      void setCallback(void (MyClass::*callback)()) {
        myCallback = callback;
      }

      void print_info() {
        Serial.println(theAnswer);
      }

      MyClass() {
        setCallback(&MyClass::print_info);
      }
    };

Using polymorphism you can only pass a callback function that is a member of the parent class, so it looks like that method may be out.


body:
I have a PING Ultrasonic Sensor, Adafruit Absolute Orientation Sensor, and a Continuous rotation servo. All pins are connected to an Arduino Micro. However because the micro only has one 5V output, I used a rail from a breadboard. I connected the + & - leads from all the devices to the rail and then plugged in two leads connecting 5V and GND from the Micro to the rail. My goal was two send power from the Arduino Micro down the rail to all three devices.

I plugged in the Micro, and instead of seeing green lights on the sensor (powered on), the blue light on the Micro turned off and the servo twitched. I have no idea why. Do I need external power for the 5V?

title: Arduino Micro blue light dimms and turns off when I plug in my circuit

Answers: 1

body: This sounds like a lot to have connected to the Micro's 5v pin. Without knowing your exact model of servo, I would still believe you are hitting the current limit. Can you try unplugging the servo and see if the circuit functions without the servo? I would power the servo externally with a 5v supply.


body:
I got:

- https://www.arduino.cc/en/Main/ArduinoBoardDuemilanove

- http://wiki.iteadstudio.com/Stackable_SD_Card_shield_V3.0 (set to 5V logic)

with this [sketch][1] using SPI/SdFat+OneWire/DallasTemperature+EmonLib and no matter what I try I got corrupted files like [this][2].

I even haven't attached my sensors yet :(
I have tried with 3 SD cards so far, each formatted with [SD Memory Card Formatter](https://www.sdcard.org/downloads/formatter_4/) and each one has this problem.

There is a separate question like that ([Corrupted files generated by Arduino with SD library. How to avoid that?](https://electronics.stackexchange.com/questions/57714/corrupted-files-generated-by-arduino-with-sd-library-how-to-avoid-that)) but it concerns SPI confict but here SD is my only SPI device on the bus.

Any ideas?

  [1]: http://pastie.org/10691360
  [2]: http://pastie.org/10691362

title: Corrupted files generated by Arduino with SdFat library. How to avoid that?

Answers: 1

body: This SD shield has CS on D4, not D10


body:
I am just getting hands on to my Arduino Uno.

I am have finished the blinking light tutorial, managed to read a potentiometer, build a running light with delays and as well a binary counter.

Now I build a small project with 5 LEDs and a potentiometer to configure a running light and change the speed of the running light with the potentiometer.

The LEDs are connected to the pins 13 to 9 and the potentiometer is connected A0 and 5V.

I also managed to program it without a delay function, but I think it is rather ugly.

Is there a better way of doing this like I did it?

    int led1 = 13;
    int led2 = 12;
    int led3 = 11;
    int led4 = 10;
    int led5 = 9;
    //the delay
    int pause = 1500;
    //count to decide which LEDs are HIGH and which are LOW
    int count = 0;
    // will store last time LED was updated
    unsigned long previousMillis = 0;

    // the setup routine runs once when you press reset:
    void setup() {
      // initialize the digital pin as an output.
      pinMode(led1, OUTPUT);
      pinMode(led2, OUTPUT);
      pinMode(led3, OUTPUT);
      pinMode(led4, OUTPUT);
      pinMode(led5, OUTPUT);

      // initialize serial communication at 9600 bits per second:
      Serial.begin(9600);
    }

    // the loop routine runs over and over again forever:
    void loop() {

      unsigned long currentMillis = millis();

      // read the input on analog pin 0:
      pause = analogRead(A0);
      float voltage = pause * (5.0 / 1023.0);

      // print out the value and teh corresponding voltage you read:
      //Serial.println("Value: %d and Voltage: %f", pause, voltage);
      Serial.print("Value: ");
      Serial.println(pause);
      Serial.print("Volts: ");
      Serial.println(voltage);

      if (currentMillis - previousMillis >= pause) {
        // save the last time you blinked the LED
        previousMillis = currentMillis;

        if (count == 0) {
          digitalWrite(led1, HIGH);
          digitalWrite(led2, LOW);
          digitalWrite(led3, LOW);
          digitalWrite(led4, LOW);
          digitalWrite(led5, LOW);
        }
        else if (count == 1){
          digitalWrite(led2, HIGH);
        }
        else if (count == 2) {
          digitalWrite(led1, LOW);
          digitalWrite(led3, HIGH);
        }
        else if (count == 3) {
          digitalWrite(led2, LOW);
          digitalWrite(led4, HIGH);
        }
        else if (count == 4) {
          digitalWrite(led3, LOW);
          digitalWrite(led5, HIGH);
        }
        else if (count == 5) {
          digitalWrite(led4, LOW);
        }
        else if (count == 6) {
          digitalWrite(led4, HIGH);
        }
        else if (count == 7) {
          digitalWrite(led5, LOW);
          digitalWrite(led3, HIGH);
        }
        else if (count == 8) {
          digitalWrite(led4, LOW);
          digitalWrite(led2, HIGH);
        }
        else if (count == 9) {
          digitalWrite(led3, LOW);
          digitalWrite(led1, HIGH);
        }
        else if (count == 10) {
          digitalWrite(led2, LOW);
          digitalWrite(led1, HIGH);
          count = -1;
        }
        count++;
      }
    }

title: Running light, without delay, and a potentiometer

Answers: 3

body:
Your Serial.print()s will print on every iteration of loop() even if that iteration doesn't operate on the LEDs. You'll be swamped with output on the terminal.

One improvement I'd make would be to get rid of the counter and the if/else if/.../else if segment. Rotate a bit through a byte variable for as many bit-positions as you have LEDs. Then call a function with that byte, that will set each LED on or off according to the state of its respective bit.

One more improvement can be had if you rotate the bits through bit positions 1 to 5 (in this case) of your byte variable, because you made the fortunate or perhaps intentional assignment of LED's to digital I/Os that are adjacent bits in PORT-B! One single `PORTB = [your byte];` statement could set all 5 LEDS simultaneously.

Update:
PORTB is a register in the UNO's Atmega328p MCU, one of three (PORTB, PORTC, and PORTD) that connect to all of the I/Os on the UNO (or any other '328 based MCU board). By setting the (up to) 8 bits in one port, a single assembly-language instruction can set that many I/Os simultaneously. It is incredibly efficient. The downside of doing that instead of calling digitalWrite() is that the sketch is then tailored to that particular processor. digitalWrite() uses more program memory and execution time (by a lot, especially when setting multiple I/Os), but keeps your sketch processor independent; digitalWrite() knows which processor it was compiled for and how to translate a Digital I/O number to a physical external pin on that processor, so you don't have to.

For those interested in the low level details of the hardware, they are in the processor's [datasheet][1].

  [1]: http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf

body:
You can put the LED pin numbers into an array.  After each delay period, turn off the current LED, increment the count, and turn on that LED.  For example:

<!-- language: lang-C -->

    // Sketch re: http://arduino.stackexchange.com/questions/19605/running-light-without-delay-and-a-potentiometer

    // Set constants for pins with LEDs
    enum { led1 = 13, led2 = 12, led3 = 11, led4 = 10, led5 = 9};

    // Make an array with the LED pin numbers
    byte ledPins[] = { led1, led2, led3, led4, led5 };

    // # of entries in ledPins:
    enum { numLeds = sizeof(ledPins) / sizeof ledPins[0]};

    //count to track which LEDs are HIGH and which are LOW
    int count = numLeds-1;  // Will roll over to 0

    // To store last time LED was updated
    unsigned long previousMillis = 0;

    void setup() {
      // initialize digital pin outputs
      for (byte i=0; i<numLeds; ++i)
        pinMode(ledPins[i], OUTPUT);

      // initialize serial communication at 9600 bits per second:
      Serial.begin(9600);
    }

    // loop() runs over and over again forever:
    void loop() {
      unsigned long currentMillis = millis();
      // read input on analog pin 0:
      int deli = analogRead(A0);
      float voltage = deli * (5.0 / 1023.0);

      // Print out the value and corresponding voltage you read:
      // Serial.println("Value: %d and Voltage: %f", pause, voltage);
      Serial.print("Value: ");
      Serial.println(deli);
      Serial.print("Volts: ");
      Serial.println(voltage);

      if (currentMillis - previousMillis >= deli) {
        // Save the last time we blinked the LED
        previousMillis = currentMillis;

        // Turn off current LED, turn on next one
        digitalWrite(ledPins[count], LOW);
        count = (count+1) % numLeds;
        digitalWrite(ledPins[count], HIGH);
      }
    }

body:
Completed now.

@all: Thank you very much.

@JRobert: Thanks a lot for the very good explanation
@jwpat7: Thanks for the code, it helped me a lot.

    // Sketch re: http://arduino.stackexchange.com/questions/19605/running-light-without-delay-and-a-potentiometer

    // Set constants for pins with LEDs
    enum {
      led1 = 13, led2 = 12, led3 = 11, led4 = 10, led5 = 9};

    // Make an array with the LED pin numbers
    byte ledPins[] = {
      led1, led2, led3, led4, led5 };

    // # of entries in ledPins:
    enum {
      numLeds = sizeof(ledPins) / sizeof ledPins[0]};

    //count to track which LEDs are HIGH and which are LOW
    int count = numLeds-1;      // Will roll over to 0

    // To store last time LED was updated
    unsigned long previousMillis = 0;

    //direction forward
    boolean forward = true;

    void setup() {
      // initialize digital pin outputs
      for (byte i=0; i<numLeds; ++i)
        pinMode(ledPins[i], OUTPUT);

      // initialize serial communication at 9600 bits per second:
      Serial.begin(9600);
    }

    // loop() runs over and over again forever:
    void loop() {
      unsigned long currentMillis = millis();
      // read input on analog pin 0:
      int deli = analogRead(A0);
      float voltage = deli * (5.0 / 1023.0);

      // Print out the value and corresponding voltage you read:
      // Serial.println("Value: %d and Voltage: %f", pause, voltage);
      // Serial.print("Value: ");
      // Serial.println(deli);
      // Serial.print("Volts: ");
      // Serial.println(voltage);

      if (currentMillis - previousMillis >= deli) {
        // Save the last time we blinked the LED
        previousMillis = currentMillis;

        if(forward){
          // Turn off current LED, turn on next one
          digitalWrite(ledPins[count], LOW);
          count = (count+1) % numLeds;
          digitalWrite(ledPins[count], HIGH);

          if(count == numLeds-1 ){
            forward = false;
            count = 0;
          }
        }
        else {
          digitalWrite(ledPins[count + numLeds-1], LOW);
          count = (count - 1) % numLeds;
          digitalWrite(ledPins[count + numLeds-1], HIGH);

          if(count + numLeds-1 == 0){
            forward = true;
            count = 0;
          }
        }
      }
    }

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

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


body:
My apologies. This is my first time on this site and I wasn't even aware that it wasn't some sort of discussion forum until receiving the automated response message to my already submitted vague and open-ended question.

**Thank you Nick Gammon** for pointing out Wanago's very interesting project, and I am sorry I did not provide enough information to show the difference in requirements. His solution is quite strictly structured and rigid (not just physically). But I wish to provide a solution that might allow anyone to fairly easily create an ad-hoc collection of any available arduino compatible hardware - which could also allow use of ESP devices for additional functionality if wished, but would not require ESPs as a means of connecting nodes. There may be a better solution than your RS485 Rolling Master for connecting nodes, but yours is the best solution I have yet seen so far, and not least because of the minimal resources required.

**Thank you JBulmer** for your clear overview and assessment, which does now give me a point of focus. In order to pursue this, I must try to aquire sufficient skills to add some form of multiple-chunk protocol layer on top of Nick Gammons Rolling Master protocol. I don't know if I'll manage it because I'm a hacker not a programmer, therefore I would appreciate  if I could give my reasons for trying, because I would very much value your opinion as to whether you think it would be worth my efforts or not.

Nicks protocol already provides auto-negotiating of nodes and takes care of most fault-tolerance type issues. I believe it auto-detects nodes and assigns them IDs which are stored in each individuals EEPROM, so he has already taken care of most of the connectivity side of things.

And I think the main reason for him using a defined message length was in order for all nodes to be able to poll in timeslot sequence for opportunity to transmit as master, which means it ought to be possible to somehow sync up re-constitution of split message blocks.

So apart from the protocol extension for handling of long strings, I don't see any other major obstacles which I can't imagine a solution for in principle even if not yet aware of how. I hasten to add that I am pushing myself way out of my comfort zone to try to achieve this because I think (though perhaps wrongly) that it might offer much benefit to ordinary arduino amateurs (such as myself) who I feel arduino is mainly aimed at. So the following example is not any specific requirement of mine, just something to illustrate some of the potential that could be offered to non-professionals - hopefully after the initial scene-setting, things can become more apparent...

The majority of arduino project examples use the serial monitor as a quick and easy way for user interaction, which can then be expected to need customising for more practical methods of input and output - but clustered nodes communicating serially might allow many project examples to be used almost as is.

An Infra-Red sender makes a good starting point. The IRremote library IRsendDemo.ino monitors the serial port for a keypress then calls a send routine, eg: irsend.sendSony. The incoming serial trigger could be made to be anything the user wished to use as a command, such as MyIRblaster, and could also include an equivalent text string of any required parameters for appropriate data conversion before use, ie:  MyIRblaster Sony(0xa90, 12)
All this can be developed and tested in independent isolation using the serial monitor, then when happy, add a 'common' block of RS485-based cluster-talk code, allowing any other node the ability to then send it a MyIRblaster command and parameter to action when needed.

As the IR arduino is using the IRremote library anyway, we may as well also give it an IRread capability, which wouldn't even require any associated trigger command.

It would be an advantage to be able to save IR signals somewhere though, but trying to squeeze on additional SD and FAT libraries as well as IRremote might be a step too far, so perhaps better just to add a separate SD node for storage. The SD node could have a file of saved IR codes, perhaps each with an asscociated corresponding simple text description such as TVmute, and have a suitable command+parameter capability added such as "SendBlaster (name)". This would allow any node to issue eg: "SendBlaster TVmute" to the SD node which in turn could issue a corresponding MyIRblaster Sony(0xa90, 12) command to the IR node.

And similarly to action any other types of node functionality for that matter - it would be relatively trivial to add some relays to the IR node if wished, and make the node recognise a "Relay (name)" command+parameter for instructing it to control any relay as required.

But it would also be just as easy (if not easier from a software point of view) to add a separate Relay node if wished. And similarly, even a Trigger node perhaps offering 64 channels of interupt-driven inputs - which also wouldn't need to recognise any incoming command, just simply be able to issue perhaps a 'Triggered' command plus appropriate triggered channel number as a lookup instruction to the SD node. Every trigger input could be assigned its own corresponding list of responses in its config file entry, which could include any of the functionality that any of the nodes could respond to.

Adding new functionality to the cluster would be as simple as adding another command keyword to a relevent nodes list of commands to be parsed for, which when matched would branch to an appropriate internal function.

So adding a "WriteLOG" command to the SD node (and having it parse for an accompanying "Details" parameter) could provide a facility for every node to be able to record events to an event log just by sending the serial command "WriteLOG (details)"to the SD node.

Commands don't have to be external, they could include any locally recognised macro-type commands for accessing any of the internal capability. So for instance the SD node could recognise a "Pause (duration)" instruction to invoke a non-blocking delay if wished. This could allow the SD node to send multiple IR code commands with pauses between each transmission. It might also recognise a 'No_Retrigger (duration)' timer to prevent unwanted repeat triggering of PIRs etc.

To better appreciate the potential now, we could create a config file on SD that contains an appropriate channel entry # for every trigger input we might wish, be it IR receives, PIRs, switch contacts or whatever.
The channel #3 doorbell entry could be something like this...

# 3  Doorbell,  No_Retrigger (3mins),  MyIRblaster (TVmute),  Relay (Porchlight) (ON),  Relay (Doorbell) (ON),  Pause (3secs),  Relay (Doorbell) (OFF),   MyIRblaster (TVun_mute),  Pause (5mins), Relay (Porchlight) (OFF).

If the SD node receives a 'Triggered Doorbell' instruction it simply parses the corresponding #3 entry and sends any extracted commands out for the other nodes to action as appropriate. In this case it would ignore subsequent PIR retriggering for 3 minutes, send commands to mute the TV, turn on the porch light, ring the doorbell for 3 seconds, unmute the TV, then turn the porch light off after 5 minutes.
It could also easily include simple local conditional logic to only turn the Porchlight when dark etc, which could allow option for appropriate qualifiers to a commands parameters, ie: Porchlight (ON) (IF_dark).

PIR sensors could select CCTV cameras, or even send IR commands to point a PTZ cam to preset positions, and all using just the same cluster functionality being used above.

A voice node might be added to givie an "Announce (message)" command, then add appropriate config entries to provide appropriate voice announcements for any triggered events.

Even amateurs could evolve quite sophisticated flexible ad-hoc systems without needing any rocket science, and without hardware constraints other than needing cheap RS485 adapters and sufficient memory for running the protocol and parsing out any commands plus conversion of any parameters.

Although the SD node in the example above is tending towards becoming a systems co-ordinator, it is still just essentially another cluster peer node. But perhaps there could be good grounds for trying to modify Nicks Rolling Master to take advantage of what benefits an SD intelligent controller might offer, such as newly connecting nodes automatically obtaining assigned IDs plus other 'characteristics' and 'behaviour' from the centrally managed SD config file.

I'm willing to roll up my sleeves and prepare for the long slog if the concept is considered realistic and worthwhile, but I would certainly welcome informed opinion as to whether it might be or not.

-------Original---------

I am looking into the feasibility of linking multiple Arduinos together to form a cluster of Arduino and ESP8266 nodes capable of sending sequences of plain text commands plus optional parameters to each other.

This could offer a mechanism for any node to be able to access the functionality of any other node without having local burden of that functionality.

For instance, only the SDcard node would require the libraries and overheads for accessing a centralised config file on SD card, but any of the other nodes could request appropriate entries from the config file whenever needed, or have ability to write event entries to a log file.

Similarly for an InfraRed node and its IR libraries, allowing any other node to send it plain text commands and parameters to transmit any required IR code even though the other nodes don't have local IR functionality themselves.

Basically, each individual arduino might just be considered a black box that does something useful and can be programmed to respond to certain external text commands (so in fact any other platforms with similar blackbox functionality could also easily be integrated to the cluster if wished).
Each node would parse an incoming string for a command that matched any of it's own local list of recognisable commands (ie: IRsend [code]) then branch as appropriate with any extracted accompanying parameters.

A cluster could be built up to include any and all required arduino functionality even though all of that functionality could never be squeezed onto any single arduino.

So an automation cluster could include things like voice announcements, web access, X-10 firecracker control etc just by including the appropriate nodes. Then tomorrow a voice recognition node might be easily added - needing to do nothing more than just issue appropriate text commands to also invoke any already existing functionality.

In principle, anyone could have the capability for doing almost anything they might wish, so although I don't know if this cluster functionality idea can be practically achieved or not, but the possible potential offers much incentive for trying.

And Nick Gammons excellent [RS485 Rolling Master article](http://www.gammon.com.au/forum/?id=11428) brings the possibility so tantalisingly close... but it uses fixed-length messages to achieve it's clever self-negotiating fault-tolerance, and I'm afraid I don't know enough to be able to merge variable-length long string capability with his enticing communications system.

So I would appreciate any suggestions, even just informed advice telling me to forget it because it cannot be done (cos at least then I'd be able to get some sleep!).

Thanks,
Robin Baker.

title: Arduino cluster functionality - feasibility advice for arduinos to communicate using variable-length long strings?

Answers: 2

body:
Someone (Wanago) has done a similar project [here](http://forum.arduino.cc/index.php?topic=61643.0). However instead of ESP8266 he used I2C which sounds more practical to me.

See images:

[![Stack of processors][1]][1]

[![Another stack of processors][2]][2]

He had the same basic idea - each board has a specific task, and the work is shared between them.

  [1]: https://i.stack.imgur.com/nDEyq.jpg
  [2]: https://i.stack.imgur.com/WUcnC.jpg

body:
Many communication systems use fixed-length, or limited-length, data exchange at the lower levels. For example, the ethernet network, under TCP/IP, has a maximum package size of 1526 bytes.

However, that doesn't prevent us moving large chunks of data, e.g. a DVD across the Internet.

A common approach is to use a [layered protocol suite][1]. Each layer is responsible for providing a service to the higher layer by using the service of the lower layers.

We talk about layered protocols because it provides a powerful, yet simplified way of thinking about communication problems. Rather than get bogged down in lots of detailed issues which need to be solved to work, we try to organise the problem into simpler and simpler solutions. Eventually things which we can implement without too much difficulty can be built, then higher layers are built from the simpler capabilities of lower layers.

The highest level of your protocol would provide the sort of service you need. In this case, you want to be able to send long-ish string messages, so the highest level would do that by using a mid-level fixed-length service.

In its turn the mid-level fixed-length service might provide error-free fixed-length messages using a still-lower-level service which can move fixed-length messages, but can't correct some types of errors.

(This is just an illustration of the idea, please don't take this as a concrete suggestion on how to implement anything.)

So, don't think "I don't know enough to be able to merge variable-length long string capability with his enticing communications system"

Instead, ask the simpler question, "how could I use that existing fixed-length communication system to send variable length strings?"

The answer might be pretty simple if the underlying system guarantees the order that messages are received. For example, send a count of the message length (in one or more messages) then send that number of bytes. The receiver knows how much to expect, and needn't act to interpret the data until it is received.

Then how to tell the difference between the command and its parameters? The command might be the first 'parameter' in the string, and parameters come after it.

The way I interpret your question, there may be several problems beyond sending variable length strings. There are potential problems like: adding or removing nodes, nodes failing, allocating 'names' to services on nodes (so commands can be sent to the appropriate node), etc.

However, the fundamental problem of sending long strings over a fixed-length communication channel is straightforward, and can be solved in a few different ways (I mentioned one, above).

  [1]: https://en.wikipedia.org/wiki/Protocol_stack


body: I am using the visual micro extension for Visual Studio 2015.  I would like to not use any .ino files since I'm trying to setup cppcheck which doesn't recogonize .cpp files, and its just what I'm used to.  However when I change my project.ino file to project.cpp the compile option is no longer available (I assume its looking for a .ino file).  Is there a project setting I can change to fix this?

title: Visual Micro without .ino files

Answers: 2

body:
Make a new tab in the IDE (top RH corner) with a xxx.cpp file name. Put your code in that. Leave the .ino file blank. Then it will compile. You need to add:

<!-- language-all: lang-C++ -->

    #include <Arduino.h>

... to the start of the .cpp file.

More information: [How to avoid the quirks of the IDE sketch file pre-preprocessing](http://www.gammon.com.au/forum/?id=12625)

---

To clarify the question about libraries ...

You do need to put into the .ino file an include for any libraries used in the project. For example:

    #include <Wire.h>
    #include <SPI.h>
    #include <EEPROM.h>

This effectively triggers the Arduino build process to link those libraries into the final executable file.

Related, my reply in this thread: <https://arduino.stackexchange.com/questions/13178/classes-and-objects-how-many-and-which-file-types-do-i-actually-need-to-use-the>

body:
As you have found, Visual Micro will not consider the project to be an Arduino project if you do not have a "project_name.ino" included in the project

A cheat is to create a "project_name.cpp" and include it in the project. This will cause the .ino to be ignored during compilation.

EDIT: The project_name.cpp takes priority during compile, therefore the .ino just becomes a dummy. However the .ino will still be used for intellisense. The cpp should be #included in the .ino along with any libraries you want discovered by intellisense.

The Visual Micro release yesterday includes automatic "library in library" discovery which means you would no longer need to put all lib #include's in the project_name.ino. (tip: you can [switch the "deep search" feature off][1] for each project via the Visual Micro menu. It slows the compile down with large libraries)

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

  [1]: http://www.visualmicro.com/post/2016/01/14/How-to-improve-compile-times-dramatically.aspx
  [2]: https://i.stack.imgur.com/kcK3T.png


body:
I need to install my Arduino drivers, but Windows 8.1 doesn't seem to like Arduino, and it greys out the update driver button. Therefore I can't select the drivers from the drivers folder in my Arduino IDE folder.

There are drivers that need to be installed. But Windows 8.1 greys out the `update driver software` button. Also, it refers to Arduino Uno as an `unknown device`. How do I install the Arduino drivers and make Windows let me install the drivers?

title: How do I install Arduino drivers?

Answers: 3

body: Often reinstall the latest arduino IDE with Windows Administrator rights helps (use right click execute as administrator).

body:
The IDE package usually ships with the driver(at-least the latest one). <br>
Go to **Program Files** in **C:** and find the **Arduino** folder and you should find a folder named **Drivers**. Inside you will find an application named **dpinst-x86**. Run it and you should be good to go!

body: If the arduino is undetected in PC go to control panel-device manager - connect the arduino and some COM port will appear click it and troubleshoot make sure your PC is connected to internet and then you will be able to see your com port in arduino ide.


body:
On Arduino Due, I set-up DMA transfers using direct control of memory mapped hardware registers.

There is a 16-bit BTSIZE field in CTRLA which indicates the number of (width sized) transfers.  If I specify larger than 8191, the value of btcount is trimmed to 13 bits after the DMA channel is enabled.  I set chunk size src/dest to 1.

The [ATMEL data sheet for the sam3x][1] (linked from the [due page][2]) does not mention this 'limitation' (section 22.7.16), or possibly I'm using it wrong.

What reference is canonical and correct for the DMAC (dma controller)?

----

As noted in the links in the comments, multi-buffer transfer can work around this, but since I don't know why it works or fails, it's hard to decide if that solution will work in all cases.

  [1]: http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf
  [2]: https://www.arduino.cc/en/Main/ArduinoBoardDue

title: Due : DMAC BTSIZE trimmed modulo 8192?

Answers: 1

body:
I'll quote the answer given in [this link](http://community.atmel.com/forum/synchronous-serial-controller-ssc-or-i2s-using-dma-controller-sam3x8e-incomplete-data-transfer) to help make this question more useful for future people who search this problem.

> The dmac.h file in asf library has a macro named DMA_MAX_LENGTH set to 0xFFF = 4095. We tried changing it to higher values but still Buffer Transfer size (BTSIZE) register was showing only values till 4095. This seemed to us to a hardware limitation of the DMAC in Atmel SAM3x8E (which we did'nt see mentioned in the datasheet). So this closed the option of single buffer transfer for us and we moved to multi-buffer transfer
>
> It was a simple way out (even though I took some time to figure it out :P ) - *Use multi-buffer transfer with contiguous source address!* (see table 22.4 Row 3)


body:
I have an ATtiny85 and an Arduino Uno both using NRF24L01 chips to communicate with one another. The ATtiny85 is powered by a CR2032 coin cell. I am using tmrh20's fork of the RF24 library which can be found [here][1]. Here's the problem I'm encountering:

Under the current code posted, the Uno will receive about 80 packets of data (80 packets times 2 seconds per packet is about 160 seconds of time) before the ATtiny will simply stop sending, and the Uno receives no more data. I can tell that it's the ATtiny, because I've got a DMM hooked up to it. Normally, my DMM tells me that the ATtiny is drawing less than 0.005mA of current, but at the instance of the stall the DMM reads approximately 1.4 mA of current draw, which makes sense because under normal conditions with no sleep the ATtiny draws about 1mA, and the radio not in power down mode and not transmitting draws 0.4mA.

I've spent quite some time trying everything from setting the clock speed to a different value (it's at 1MHz) to changing the power amplifier value. The only thing I've tried that makes an impact is getting rid of the powerUp and powerDown function calls. Once these are removed everything works perfectly transmission-wise, except the only issue is that the whole system is drawing 0.4mA constantly, which is too much.

I don't think the coin cell is a problem considering the system works when the powerUp and powerDown calls are removed. Here's my code:

Reciever:

    #define CE_PIN 7
    #define CSN_PIN 8

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

    RF24 radio(CE_PIN, CSN_PIN);

    byte address[11] = "SimpleNode";
    unsigned long payload = 0;

    void setup() {
      while (!Serial);
      Serial.begin(115200);
      radio.begin(); // Start up the radio
      radio.setAutoAck(1); // Ensure autoACK is enabled
      radio.setRetries(15,15); // Max delay between retries & number of retries
      radio.openReadingPipe(1, address); // Write to device address 'SimpleNode'
      radio.startListening();
      Serial.println("Did Setup");

    }

    long counter = 0;

    void loop(void){
      if (radio.available()) {

        radio.read( &payload, sizeof(unsigned long) );
        if(payload != 0){
            Serial.print("Got Payload ");
            Serial.print(payload);
            Serial.print(" - ");
            Serial.println(counter);
            counter++;
        }
      }

    }

Transmitter:

    //Sleep
    #include <avr/sleep.h>

    const int sleepSecs = 2;

    //Radio
    #define CE_PIN 3
    #define CSN_PIN 3 //Since we are using 3 pin configuration we will use same pin for both CE and CSN
    #include "RF24.h"
    RF24 radio(CE_PIN, CSN_PIN);
    byte address[11] = "SimpleNode";
    unsigned long payload = 0;

    void setup() {
      //Setup radio
      radio.begin(); // Start up the radio
      radio.setAutoAck(1); // Ensure autoACK is enabled
      radio.setRetries(15,15); // Max delay between retries & number of retries
      //RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX
      radio.setPALevel(RF24_PA_HIGH);
      radio.openWritingPipe(address); // Write to device address 'SimpleNode'

      //Setup sleep
      setup_watchdog(6);
      set_sleep_mode(SLEEP_MODE_PWR_DOWN); //Power down everything, wake up from WDT
      sleep_enable();
    }

    volatile int watchdog_counter = 0;

    ISR(WDT_vect) {
      watchdog_counter++;
    }

    void loop() {
      sleep_mode(); //Go to sleep!

      if(watchdog_counter >= sleepSecs)
      {
        ADCSRA |= (1<<ADEN);
        radio.powerUp();
        watchdog_counter = 0;

        payload = 123456;
        radio.write(&payload, sizeof(unsigned long) ); //Send data to 'Receiver' every second

        radio.powerDown();
        ADCSRA &= ~(1<<ADEN); //Disable ADC, saves ~230uA
      }
    }

    //Sets the watchdog timer to wake us up, but not reset
    //0=16ms, 1=32ms, 2=64ms, 3=128ms, 4=250ms, 5=500ms
    //6=1sec, 7=2sec, 8=4sec, 9=8sec
    //From: http://interface.khm.de/index.php/lab/experiments/sleep_watchdog_battery/
    void setup_watchdog(int timerPrescaler) {

      if (timerPrescaler > 9 ) timerPrescaler = 9; //Limit incoming amount to legal settings

      byte bb = timerPrescaler & 7;
      if (timerPrescaler > 7) bb |= (1<<5); //Set the special 5th bit if necessary

      //This order of commands is important and cannot be combined
      MCUSR &= ~(1<<WDRF); //Clear the watch dog reset
      WDTCR |= (1<<WDCE) | (1<<WDE); //Set WD_change enable, set WD enable
      WDTCR = bb; //Set new watchdog timeout value
      WDTCR |= _BV(WDIE); //Set the interrupt enable, this will keep unit from resetting after each int
    }

  [1]: http://tmrh20.github.io/RF24/classRF24.html

title: RF24 Stalls Arduino Program with powerDown

Answers: 2

body: After looking at the RF24 header file, I suggest you call `radio.stopListening()` right before you call `write()`. Also add a delay of 5 ms after `write()`. It would be nice to know the exact point at which the program got stuck; add `digitalWrite(13, HIGH)` inside the IF block, after `powerDown()` and again outside the block, immediately after `sleep_mode()`, but with a LOW argument instead, so you can know if the problem is that the AVR stops waking up at some point or if its the radio methods that is blocking, for some reason.

body:
A delay after the `powerUp()` made the program work for longer, but it still stalled. More delays after `write()` only exacerbated the issue. The only thing that I've done to get this to work is to put the sending code in the watchdog ISR itself. However, this is limited to only around 4 seconds max per sent packet because this is the watchdog's max value, but that's OK for my application.

This leads me to believe that somehow the watchdog is interfering with sending, so possibly disabling it and reenabling after sending could have some effect if anyone else is having this problem.


body:
How do you install the Arduino IDE on the Raspberry Pi running an ARM version of Ubuntu or Raspbian? There doesn't seem to be any [official ARM release][1]. Both distros have an "arduino" package in their standard repos, but it only includes an ancient 1.0 version that's missing a lot of features.

  [1]: https://www.arduino.cc/en/Main/OldSoftwareReleases#00xx

title: How to install Arduino IDE on Raspberry Pi

Answers: 1

body:
Arduino at http://playground.arduino.cc/Linux/Raspbian recommends:

    sudo apt-get update && sudo apt-get install arduino

but indeed warns that the version is old:

> Note: This will install an old version of Arduino, and may not support
> some of the newer boards. You can not download a newer version from
> the website, because there is no ARM version. -- [Arduino wiki on Raspbian][1]

Looking at the raspbian respository at http://archive.raspbian.org/raspbian/pool/main/a/arduino/ currently lists 1.0.5

There are folks working newer versions of Arduino for ARM at https://github.com/arduino/Arduino/issues/3334 but it isn't finished yet.

  [1]: http://playground.arduino.cc/Linux/Raspbian


body:
    C:\Users\Field\Documents\Arduino\Adafruit_TCS34725-master\examples\tcs34725autorange\tcs34725autorange.ino:2:31: fatal error: Adafruit_TCS34725.h: No such file or directory

     #include "Adafruit_TCS34725.h"

                                   ^

    compilation terminated.

exit status 1
Error compiling.

title: Trying to understand compilation error message

Answers: 1

body:
You are trying to use a library, but it is either not installed, or is installed in the wrong location. A library, in this context, is code that supports a sensor or some other hardware or that accomplishes a task. We call them libraries because we can share and reuse them – like borrowing a book from a library.

It looks like you're trying to get the Adafruit TCS34725 color sensor going. The official source of the library is in the [Adafruit's GitHub repository for the TCS34725][1] and there is a link at the bottom of the README for how to install a library. I'll bet that will get you back on track.

[1]: https://github.com/adafruit/Adafruit_TCS34725


body:
I am trying to dow what is demonstrated in this [tutorial][1]. I have altered the original setup a little by adding a level converter to not fry the Bluetooth module and resistors for the LEDs, as well as using only 2 instead of four LEDs (which I adjusted for in code later). other than that I am using the exact same setup, code,and procedure. Yet when I try to run my code on the Arduino. I get the error below. I believe it is due to using Tx/Rx and serial at the same time but I really don't know anything about this. Should I add more libraries?
Should I change the wiring shown in the tutorial link? It seems like I need to use Tx/Rx

    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xce
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xce
    avrdude: stk500_recv(): programmer is not responding

Here is the code I used from tutorial:

<!-- language: c -->

    //Coded By: Angelo Casimiro (4/27/14)
    //Voice Activated Arduino (Bluetooth + Android)
    //Feel free to modify it but remember to give credit

    String voice;
    int
    led1 = 2, //Connect LED 1 To Pin #2
    led2 = 3, //Connect LED 2 To Pin #3
    led3 = 4, //Connect LED 3 To Pin #4
    led4 = 5, //Connect LED 4 To Pin #5
    led5 = 6; //Connect LED 5 To Pin #6
    //--------------------------Call A Function-------------------------------//
    void allon(){
         digitalWrite(led1, HIGH);
         digitalWrite(led2, HIGH);
         digitalWrite(led3, HIGH);
         digitalWrite(led4, HIGH);
         digitalWrite(led5, HIGH);
    }
    void alloff(){
         digitalWrite(led1, LOW);
         digitalWrite(led2, LOW);
         digitalWrite(led3, LOW);
         digitalWrite(led4, LOW);
         digitalWrite(led5, LOW);
    }
    //-----------------------------------------------------------------------//
    void setup() {
      Serial.begin(9600);
      pinMode(led1, OUTPUT);
      pinMode(led2, OUTPUT);
      pinMode(led3, OUTPUT);
      pinMode(led4, OUTPUT);
      pinMode(led5, OUTPUT);
    }
    //-----------------------------------------------------------------------//
    void loop() {
      while (Serial.available()){  //Check if there is an available byte to read
      delay(10); //Delay added to make thing stable
      char c = Serial.read(); //Conduct a serial read
      if (c == '#') {break;} //Exit the loop when the # is detected after the word
      voice += c; //Shorthand for voice = voice + c
      }
      if (voice.length() > 0) {
        Serial.println(voice);
    //-----------------------------------------------------------------------//
      //----------Control Multiple Pins/ LEDs----------//
           if(voice == "*all on") {allon();}  //Turn Off All Pins (Call Function)
      else if(voice == "*all off"){alloff();} //Turn On  All Pins (Call Function)

      //----------Turn On One-By-One----------//
      else if(voice == "*TV on") {digitalWrite(led1, HIGH);}
      else if(voice == "*fan on") {digitalWrite(led2, HIGH);}
      else if(voice == "*computer on") {digitalWrite(led3, HIGH);}
      else if(voice == "*bedroom lights on") {digitalWrite(led4, HIGH);}
      else if(voice == "*bathroom lights on") {digitalWrite(led5, HIGH);}
      //----------Turn Off One-By-One----------//
      else if(voice == "*TV off") {digitalWrite(led1, LOW);}
      else if(voice == "*fan off") {digitalWrite(led2, LOW);}
      else if(voice == "*computer off") {digitalWrite(led3, LOW);}
      else if(voice == "*bedroom lights off") {digitalWrite(led4, LOW);}
      else if(voice == "*bathroom lights off") {digitalWrite(led5, LOW);}
    //-----------------------------------------------------------------------//
    voice="";}} //Reset the variable after initiating

  [1]: http://www.instructables.com/id/Voice-Activated-Arduino-Bluetooth-Android/?ALLSTEPS

title: bluetooth module with stk500_recv() error

Answers: 1

body: How did you upload the sketch? With the Bluetooth module still connected? In that case please disconnect it and the upload. Connect again after the upload.


body:
How would I refine this to only recognize red and green? I don't need the full functionality of this code, just the ability to distinguish between red and green, and output that respectively.

I also would like to eliminate the bleed over; meaning, the green led stays on slightly when I flood the Adafruit with red light and vice versa. I am not really familiar with the output of the Adafruit, but it seems this could be an analog "question and answer" situation; it's either green or red or nothing.

    #include <Wire.h>
    #include "Adafruit_TCS34725.h"

    #ifndef _TCS34725_H_
    #define _TCS34725_H_

    #if ARDUINO >= 100
     #include <Arduino.h>
    #else
     #include <WProgram.h>
    #endif

    #include <Wire.h>

    #define TCS34725_ADDRESS          (0x29)

    #define TCS34725_COMMAND_BIT      (0x80)

    #define TCS34725_ENABLE           (0x00)
    #define TCS34725_ENABLE_AIEN      (0x10)    /* RGBC Interrupt Enable */
    #define TCS34725_ENABLE_WEN       (0x08)    /* Wait enable - Writing 1 activates the wait timer */
    #define TCS34725_ENABLE_AEN       (0x02)    /* RGBC Enable - Writing 1 actives the ADC, 0 disables it */
    #define TCS34725_ENABLE_PON       (0x01)    /* Power on - Writing 1 activates the internal oscillator, 0 disables it */
    #define TCS34725_ATIME            (0x01)    /* Integration time */
    #define TCS34725_WTIME            (0x03)    /* Wait time (if TCS34725_ENABLE_WEN is asserted) */
    #define TCS34725_WTIME_2_4MS      (0xFF)    /* WLONG0 = 2.4ms   WLONG1 = 0.029s */
    #define TCS34725_WTIME_204MS      (0xAB)    /* WLONG0 = 204ms   WLONG1 = 2.45s  */
    #define TCS34725_WTIME_614MS      (0x00)    /* WLONG0 = 614ms   WLONG1 = 7.4s   */
    #define TCS34725_AILTL            (0x04)    /* Clear channel lower interrupt threshold */
    #define TCS34725_AILTH            (0x05)
    #define TCS34725_AIHTL            (0x06)    /* Clear channel upper interrupt threshold */
    #define TCS34725_AIHTH            (0x07)
    #define TCS34725_PERS             (0x0C)    /* Persistence register - basic SW filtering mechanism for interrupts */
    #define TCS34725_PERS_NONE        (0b0000)  /* Every RGBC cycle generates an interrupt                                */
    #define TCS34725_PERS_1_CYCLE     (0b0001)  /* 1 clean channel value outside threshold range generates an interrupt   */
    #define TCS34725_PERS_2_CYCLE     (0b0010)  /* 2 clean channel values outside threshold range generates an interrupt  */
    #define TCS34725_PERS_3_CYCLE     (0b0011)  /* 3 clean channel values outside threshold range generates an interrupt  */
    #define TCS34725_PERS_5_CYCLE     (0b0100)  /* 5 clean channel values outside threshold range generates an interrupt  */
    #define TCS34725_PERS_10_CYCLE    (0b0101)  /* 10 clean channel values outside threshold range generates an interrupt */
    #define TCS34725_PERS_15_CYCLE    (0b0110)  /* 15 clean channel values outside threshold range generates an interrupt */
    #define TCS34725_PERS_20_CYCLE    (0b0111)  /* 20 clean channel values outside threshold range generates an interrupt */
    #define TCS34725_PERS_25_CYCLE    (0b1000)  /* 25 clean channel values outside threshold range generates an interrupt */
    #define TCS34725_PERS_30_CYCLE    (0b1001)  /* 30 clean channel values outside threshold range generates an interrupt */
    #define TCS34725_PERS_35_CYCLE    (0b1010)  /* 35 clean channel values outside threshold range generates an interrupt */
    #define TCS34725_PERS_40_CYCLE    (0b1011)  /* 40 clean channel values outside threshold range generates an interrupt */
    #define TCS34725_PERS_45_CYCLE    (0b1100)  /* 45 clean channel values outside threshold range generates an interrupt */
    #define TCS34725_PERS_50_CYCLE    (0b1101)  /* 50 clean channel values outside threshold range generates an interrupt */
    #define TCS34725_PERS_55_CYCLE    (0b1110)  /* 55 clean channel values outside threshold range generates an interrupt */
    #define TCS34725_PERS_60_CYCLE    (0b1111)  /* 60 clean channel values outside threshold range generates an interrupt */
    #define TCS34725_CONFIG           (0x0D)
    #define TCS34725_CONFIG_WLONG     (0x02)    /* Choose between short and long (12x) wait times via TCS34725_WTIME */
    #define TCS34725_CONTROL          (0x0F)    /* Set the gain level for the sensor */
    #define TCS34725_ID               (0x12)    /* 0x44 = TCS34721/TCS34725, 0x4D = TCS34723/TCS34727 */
    #define TCS34725_STATUS           (0x13)
    #define TCS34725_STATUS_AINT      (0x10)    /* RGBC Clean channel interrupt */
    #define TCS34725_STATUS_AVALID    (0x01)    /* Indicates that the RGBC channels have completed an integration cycle */
    #define TCS34725_CDATAL           (0x14)    /* Clear channel data */
    #define TCS34725_CDATAH           (0x15)
    #define TCS34725_RDATAL           (0x16)    /* Red channel data */
    #define TCS34725_RDATAH           (0x17)
    #define TCS34725_GDATAL           (0x18)    /* Green channel data */
    #define TCS34725_GDATAH           (0x19)
    #define TCS34725_BDATAL           (0x1A)    /* Blue channel data */
    #define TCS34725_BDATAH           (0x1B)

    typedef enum
    {
      TCS34725_INTEGRATIONTIME_2_4MS  = 0xFF,   /**<  2.4ms - 1 cycle    - Max Count: 1024  */
      TCS34725_INTEGRATIONTIME_24MS   = 0xF6,   /**<  24ms  - 10 cycles  - Max Count: 10240 */
      TCS34725_INTEGRATIONTIME_50MS   = 0xEB,   /**<  50ms  - 20 cycles  - Max Count: 20480 */
      TCS34725_INTEGRATIONTIME_101MS  = 0xD5,   /**<  101ms - 42 cycles  - Max Count: 43008 */
      TCS34725_INTEGRATIONTIME_154MS  = 0xC0,   /**<  154ms - 64 cycles  - Max Count: 65535 */
      TCS34725_INTEGRATIONTIME_700MS  = 0x00    /**<  700ms - 256 cycles - Max Count: 65535 */
    }
    tcs34725IntegrationTime_t;

    typedef enum
    {
      TCS34725_GAIN_1X                = 0x00,   /**<  No gain  */
      TCS34725_GAIN_4X                = 0x01,   /**<  4x gain  */
      TCS34725_GAIN_16X               = 0x02,   /**<  16x gain */
      TCS34725_GAIN_60X               = 0x03    /**<  60x gain */
    }
    tcs34725Gain_t;

    class Adafruit_TCS34725 {
     public:
      Adafruit_TCS34725(tcs34725IntegrationTime_t = TCS34725_INTEGRATIONTIME_2_4MS, tcs34725Gain_t = TCS34725_GAIN_1X);

      boolean  begin(void);
      void     setIntegrationTime(tcs34725IntegrationTime_t it);
      void     setGain(tcs34725Gain_t gain);
      void     getRawData(uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *c);
      uint16_t calculateColorTemperature(uint16_t r, uint16_t g, uint16_t b);
      uint16_t calculateLux(uint16_t r, uint16_t g, uint16_t b);
      void     write8 (uint8_t reg, uint32_t value);
      uint8_t  read8 (uint8_t reg);
      uint16_t read16 (uint8_t reg);
      void setInterrupt(boolean flag);
      void clearInterrupt(void);
      void setIntLimits(uint16_t l, uint16_t h);
      void     enable(void);

     private:
      boolean _tcs34725Initialised;
      tcs34725Gain_t _tcs34725Gain;
      tcs34725IntegrationTime_t _tcs34725IntegrationTime;

      void     disable(void);
    };

    #endif

    // Pick analog outputs, for the UNO these three work well
    // use ~560  ohm resistor between Red & Blue, ~1K for green (its brighter)
    #define redpin 3
    #define greenpin 5
    #define bluepin 6
    // for a common anode LED, connect the common pin to +5V
    // for common cathode, connect the common to ground

    // set to false if using a common cathode LED
    #define commonAnode true

    // our RGB -> eye-recognized gamma color
    byte gammatable[256];

    Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);

    void setup() {
      Serial.begin(9600);
      Serial.println("Color View Test!");

      if (tcs.begin()) {
        Serial.println("Found sensor");
      } else {
        Serial.println("No TCS34725 found ... check your connections");
        while (1); // halt!
      }

      // use these three pins to drive an LED
      pinMode(redpin, OUTPUT);
      pinMode(greenpin, OUTPUT);
      pinMode(bluepin, OUTPUT);

      // thanks PhilB for this gamma table!
      // it helps convert RGB colors to what humans see
      for (int i=0; i<256; i++) {
        float x = i;
        x /= 255;
        x = pow(x, 2.5);
        x *= 255;

        if (commonAnode) {
          gammatable[i] = 255 - x;
        } else {
          gammatable[i] = x;
        }
        //Serial.println(gammatable[i]);
      }
    }

    void loop() {
      uint16_t clear, red, green, blue;

      tcs.setInterrupt(false);      // turn on LED

      delay(60);  // takes 50ms to read

      tcs.getRawData(&red, &green, &blue, &clear);

      tcs.setInterrupt(true);  // turn off LED

      Serial.print("C:\t"); Serial.print(clear);
      Serial.print("\tR:\t"); Serial.print(red);
      Serial.print("\tG:\t"); Serial.print(green);
      Serial.print("\tB:\t"); Serial.print(blue);

      // Figure out some basic hex code for visualization
      uint32_t sum = clear;
      float r, g, b;
      r = red; r /= sum;
      g = green; g /= sum;
      b = blue; b /= sum;
      r *= 256; g *= 256; b *= 256;
      Serial.print("\t");
      Serial.print((int)r, HEX); Serial.print((int)g, HEX); Serial.print((int)b, HEX);
      Serial.println();

      //Serial.print((int)r ); Serial.print(" "); Serial.print((int)g);Serial.print(" ");  Serial.println((int)b );

      analogWrite(redpin, gammatable[(int)r]);
      analogWrite(greenpin, gammatable[(int)g]);
      analogWrite(bluepin, gammatable[(int)b]);

title: Refine Colorview Code

Answers: 0


body:
 I want to upload an .hex file to an Atmega8 chip (SMD). I want to use the Arduino IDE and an Uno as the ISP program. But I'm unable to find any details on how to load a sketch which is in .hex format.

Following is the batch file I created to use with avrdude. I would like to know if the Command is correct?

    C:\Users\Pranay\Desktop\DIY\arduino-1.0.1!\hardware\tools\avr\bin/avrdude -CC:\Users\Pranay\Desktop\DIY\arduino-1.0.1!\hardware\tools\avr\etc/avrdude.conf -v -v -v -v -patmega8 -cstk500
     -P\\.\COM4 -b19200 -Uflash:w:C:\Users\Pranay\Desktop\DIY\arduino-1.0.1!\hexFiles\Heart.hex:i

    pause

title: How to upload .hex file to Atmega8 Using Arduino IDE and Uno as an Isp?

Answers: 0


body:
I'm currently experimenting with my arduino Uno. I control it via an mobile (android) but wanted to just use a microphone on the board so I don't need to carry my mobile around. It is possible to record flac files from a mic and send it to Google speech api and get a return? And then maybe output it via the synthesis.

So it is possible to do this on an arduino uno and with C. If doesnt is there any other way I can go? I could buy a raspberry pi but I don't an whole operating system like linux installed. So any thoughts?

title: Arduino Google speech api

Answers: 1

body:
You can use a special voice recognition shield (for example: [EasyVR Shield 3.0 - Voice Recognition Shield]) to integrate a simple and basic voice recognition. I think it's a very fast and easy prototyping way...

For the use of the more complex Google Speech Recognition I would use a more powerful microcontroller (such as Raspberry PI or something like that)...

[EasyVR Shield 3.0 - Voice Recognition Shield]:https://www.sparkfun.com/products/13316


body:
For an ethernet project I do, I need to store the Ethernet Shield's MAC address.
I store it like that:

    byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0xE1, 0x85 };
That works OK, but in my project I need all the SRAM available, so every byte of memory is important. I've used the F() macro and PROGMEM everywhere, but I couldn't manage to store the MAC byte array in the PROGMEM.

How can I store it in PROGMEM? Is it even possible?

title: Saving byte array in PROGMEM instead of SRAM

Answers: 1

body:
<!-- language-all: lang-C++ -->

See [Putting constant data into program memory (PROGMEM)](http://www.gammon.com.au/progmem) for tips about putting stuff into PROGMEM. However personally I wouldn't get too excited about saving 6 bytes.

---

Example code:

*Declare data globally:*

    const byte mac [6] PROGMEM = { 0x90, 0xA2, 0xDA, 0x0F, 0xE1, 0x85 };

*Get a copy for use into a temporary variable:*

      char foo [6];
      memcpy_P (foo, mac, sizeof foo);


body:
I have a Arduino Uno and a CC3000 shield. When I run the example code for Webclient from Adafruits libary it works perfect.

When I switch out address for reading a corresponding text file from my own server the code completes sporadically. The output in the serial window stops at differens places every time.

Does anyone have any idea how I can fix this?

The Adafruit points to this URL: http://www.adafruit.com/testwifi/index.html
While mine points to this URL: http://a.sjsd.li/test/test.html

title: Adafruit libary and CC3000 shield

Answers: 2

body: Perhaps the CC3000 isn't waiting long enough for the whole response to come in. Try increasing the variable `IDLE_TIMEOUT` in the Web_Client sketch, near the top. Change its value to 10000 and see if you get the whole response this time.

body:
I have arrived at a solution that works for me. Instead of using Adafruit library I have adopted [Sparkfuns library][1].

Some adjustments in the setup for the pins:

    #define CC3000_INT      3   // Needs to be an interrupt pin (D2/D3)
    #define CC3000_EN       5   // Can be any digital pin
    #define CC3000_CS       10  // Preferred is pin 10 on Uno
    #define SD_CS           4   // Chip select for SD card

Then some adjustemnt in the block for the HTTP request:

    client.print("GET /index.html HTTP/1.1\r\n");
    client.print("Host: ");
    client.print(server);
    client.print("\r\n\r\n");
    client.println();
    Serial.println();
This is not a solution for the Adafruit libary. But it helped me to continue my project.

  [1]: https://github.com/sparkfun/SFE_CC3000_Library


body:
I want to make a system using NeoPixels, an Arduino and an ESP8266 module to ping IP addresses on my network to determine if certain people are on our Wi-Fi (I'll be pinging mobile phones).

I'm finding it hard to find any help as to how to ping IP addresses from an Arduino using the ESP8266 module. I did find the [ICMP Ping library][1], but it uses the Ethernet shield, and I'm quite new to Arduino so I don't even know if I could modify the library in any way.

If anyone could help me on my way, that'd be great!

  [1]: http://playground.arduino.cc/Code/ICMPPing

title: Ping IP address using ESP8266 connected to Arduino

Answers: 3

body: From what I could find, it seems theres a command for pinging a server. It returns the number of milliseconds taken for the server to respond. The command is: `AT+PING="web site"` or `AT+PING=<ip addr>`, from 2 separate sources. You'll have to test them to see which (if not both) is correct.

body:
Not all devices (including) phones respond to ICMP Ping. This may differ for each (mobile) OS and version and phone make and model. But assuming your phone does respond to ping...

If you use the ESP with just the default firmware (a waste of a perfectly capable microcontroller), then indeed use the AT+PING command from the other answers.

If you use the ESP directly, you may be out of luck. Both the nocemcu lua firmware and the arduino api for esp seem to lack icmp ping functionality.

body:
This answer does not answer your question, but it implements the device you are describing. Unfortunately I don't have enough reputation to comment, so I will post it as an answer.

As people said before, ping is not a reliable option to scan the network. On Linux you can use dedicated (software) tools to scan the network, but even they struggle to reliably detect (some) mobile devices. So I wanted my router to do the work for me (at least it should reliably know which devices are logged into the Wi-Fi, right?).

Fortunately I have a Fritz!Box that provides an API to communicate with. Based on that API and an ESP8266 I build such a device you described in your question: [[15min] Weasley Clock / Who is Home Indicator - based on TR-064 (beta)](http://www.instructables.com/id/Who-Is-Home-Indicator-aka-Weasley-Clock-Based-on-T).

To do that I wrote a library for Arduino to uses that API: [Aypac/Arduino-TR-064-SOAP-Library](https://github.com/Aypac/Arduino-TR-064-SOAP-Library).


body:
I am thinking of working on a project based on a camera module OV7670. I am making a security system using an arduino where detected motion (I am also using a PIR sensor) will trigger the camera module. I wanted to get all kinds of information needed to work with the camera module in this kind of project.

I am not expecting a very long answer rearding everything about the module. The most important points and maybe a few references would be enough. It would also be helpful if programming reference for the camera module is also provided.

title: Details on OV7670

Answers: 1

body:
[This post][1] is a link to a blog that describes the pinout and connections, along with some general information. They also have a link to [an "ArduCAM" library][2] with [an example][3] utilizing your camera model.

  [1]: http://www.arducam.com/camera-modules/0-3mp-ov7670/
  [2]: https://github.com/ArduCAM/Arduino/tree/master/ArduCAM
  [3]: https://github.com/ArduCAM/Arduino/blob/master/ArduCAM/examples/REVC/ArduCAM_OV7670_Camera_Playback/ArduCAM_OV7670_Camera_Playback.ino


body:
I want to build some small wireless temperature measurement boards, to sprinkle around the house. I'd like to power these from a single coin cell battery (CR2032).

For these I'd like to use the DS18B20 sensor. These sensor require a minimal voltage of 3v. A coin cell will however only provide 3v when it's full, and will drop to around 2.6v when 90% discharged.

From what I've read the DS18B20 will give [some strange results](http://openenergymonitor.org/emon/node/2303) when the supply voltage is below 3v. Also the [precision can be off](http://openenergymonitor.org/emon/node/2331), when the supply voltage isn't regulated.

(The ATMega328p and NRF24L01, I plan to use, will work just fine at voltages down to 2v, so only the DS18B20 requires 3.3v.)

So I've come up with the following solutions:

 1. Use two coin cells, and a (low quiescent current) voltage regulator. (Disadvantage: takes more space, more batteries, slightly more expensive.)
 2. Use a boost regulator. (Disadvantage: even more expensive, and a lot more complex (for me at least).)
 3. Implement a voltage doubler to power the DS18B20 when needed (every 15 minutes). To regulate the voltage I'd add a 3.3v zener diode to the output. (dirt cheap to implement)

I tend to lean toward option 3, but my question is, could it even work?

Is there something to look out for?

Or is there an even better solution?

**edit** I was planning to use the Dickson doubler circuit.

[![voltage doubler][2]][2]

  [2]: https://i.stack.imgur.com/J6gVP.png

title: Powering 3.3v sensors from a coin cell

Answers: 1

body:
You're missing out option 4, which is the option I would personally go for:

* Use a different temperature sensor.

A quick parametric search on Microchip (my favourite, I'm a Microchip fanboy after all...) I find quite a nice one - the MCP9844.

>  Microchip Technology Inc.’s MCP9844 digital temperature sensor converts temperature from -40°C and +125°C to a digital word. This sensor meets JEDEC Specification JC42.4-TSE2004B1 mobile Platform Memory Module Thermal Sensor Component. It provides an accuracy of ±0.2°C/±1°C (typical/maximum) from +75°C to +95°C.
>
> Operating Voltage Range (V): +1.7 to +3.6

**However** it is only available as a TDFN which makes prototyping difficult, although it is one of my two preferred footprints for real building - the other being variants of QFN.

I am sure you can search other makers for similarly specified chips that will do the job without the need for fancy boosters or doublers or the expense of multiple batteries etc.

One of the first steps of any design is the component identification. Often the chip or component that many people automatically reach for because it's the first one they used, or it's the one people most often talk about, may not be the right tool for the job. It pays to shop around a bit and look to see if there is something better that will fit the bill and save cost and time in the long run by ending up with a simpler system.


body:
Hello I finally got my nokia 5110 lcd working, I have tested it by displaying bitmap images other people have made. I made my own image and then used lcd assistant to turn it into an array. First look at my code.

    #include "U8glib.h"

U8GLIB_PCD8544 u8g(8, 4, 7, 5, 6);  // CLK=8, DIN=4, CE=7, DC=5, RST=6

int x = 5;
int y = 5;

int level = 5;

const uint8_t rook_bitmap[] U8G_PROGMEM = {
0x7E, 0x82, 0x04, 0x8E, 0x7A, 0x42, 0xB4, 0x24, 0x08, 0xD8, 0x48, 0x08, 0x08, 0x0C, 0x02, 0x22,
0xD9, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1E, 0x11, 0x21, 0x22, 0x14, 0x3B,
0xD4, 0x25, 0x29, 0x68, 0xA8, 0xA8, 0x74, 0x0C, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

void draw(void) {
  // graphic commands to redraw the complete screen should be placed here
  u8g.drawBitmapP( 5, 5, 3,18, rook_bitmap);

 }

void setup(void) {

}

void loop(void) {
  // picture loop
  u8g.firstPage();
  do {
    draw();
  } while( u8g.nextPage() );

 // y++;
  // rebuild the picture after some delay
  delay(1000);
}

The part that goes wrong is at u8g.drawBitmapP(5,5,21,18, rook_bitmap);
I know it is to do with the 21 and 18 being wrong because I don't know where to get those numbers. Is it the width and height of the image when it is in paint.net or what is it?

title: Arduino drawing a bitmap on nokia 5110 lcd

Answers: 1

body:
The 21 and 18 are the dimensions of the image. It's not just pixels though.

The first number (21) is the number of *bytes* in a row of the image - that is one eighth of the width in pixels.  The width *must* be a multiple of 8.

The second number is the number of rows in the image - basically the height in pixels.

The two numbers, when multiplied together, must equal the number of bytes in your array.

From [the documentation:](https://code.google.com/p/u8glib/wiki/userreference#drawBitmap)

>**Description**
>
>Draw a bitmap at the specified x/y position (upper left corner of the bitmap). Parts of the bitmap may be outside the display boundaries. The bitmap is specified by the array bitmap. A cleared bit means: Do not draw a pixel. A set bit inside the array means: Write pixel with the current color index. For a monochrome display, the color index 0 will usually clear a pixel and the color index 1 will set a pixel.
>
>**Arguments:**
>
> * u8g : Pointer to the u8g structure (C interface only).
> * x: X-position (left position of the bitmap).
> * y: Y-position (upper position of the bitmap).
> * cnt: Number of bytes of the bitmap in horizontal direction. The width of the bitmap is cnt*8.
> * h: Height of the bitmap.

----

It would appear your image data is complete gibberish.  This is what I decode it to be:

     ######  #     #  #
     ###   # # ####  #    #
      # ## #  #  #     #
       ## ##   #  #    #
       #      ##     #
     #   #  #  ## #####

            #        ####
    #   #   #    #   #   #
      # #   ## ###    # # ##
    # #  #  #  # #     # ##
       # # #   # # #  # ###
      ##    ##


body:
I'm working on a prototype with a Particle Photon, but I've realized the required number of pins is bigger than the number of pins on my photon.

I thought I could have an Arduino Uno wired to some sensors, and link the Arduino to the photon via a Software Serial from the Arduino (as its serial pins will already be busy) to the Serial pins of the photon.

Is it possible, and is there a better way to solve my problem?

title: Link Arduino Uno to Particle Photon

Answers: 2

body:
Everything is possible, it is programming. People are doing software-only USB on AVRs.

I doubt that the effort is worth it, given how hard it is to debug such low-level code. Besides you can use on-board UART if you don't need the USB connectivity - just disable it.

Main question is - where is the main software run, aka "Who's the Brain"? If Photon, maybe you can use SPI? SPI is dead-simple to emulate in software.

body:
If you just need to get more inputs you could use multiplexing. The multiplexing method is more robust than software serial will be. How to do this is explained [here][1] and [datasheet for the commonly used cd4051 here][2]

You don't specify what kind of sensors you will use. if the sensors are i2c or similar it is possible to daisychain (multiplex too) them.

  [1]: https://cityos.io/tutorial/1958/Use-multiplexer-with-Arduino
  [2]: http://www.ti.com/lit/ds/symlink/cd4053b-mil.pdf