message:
Problem with my arduino board

I had attatched a GSM module to my arduino Uno board. The power had been switched on. The GSM 5V pin was connected to my board. I was still midway with my work so for some reason I gave an external power supply to my GSM module. Now smoke started coming out of my Uno board and a burning smell came from it. I immediately switched off the power supply. But now I am unable to burn sketches to my Arduino. It is showing error: Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
On opening the serial monitor it says: Board at COM3 not detected.

Link from wher I bought the GSM module: http://www.ebay.in/itm/GSM-Module-SIM800-Quadband-better-than-SIM-900-or-SIM900A-Modem-with-SMA-Antenna-/252053758680?hash=item3aaf9322d8

body:
Oops.

You let the [Magic Smoke™](https://en.wikipedia.org/wiki/Magic_smoke) escape from your Arduino.  Your Arduino is now somewhat dead.  Depending on *what* died it may be repairable by replacing components, or it may be beyond resurrection and it'll be easier to buy a new one.

Now - why did it happen?  Looking at the board in your link it should have been OK with the 12V power you provided, since it has its own regulator on board that can supposedly take up to 12V.  So one of two things may have happened:

1. What you thought was 12V was actually higher than 12V and the regulator didn't cope with it.
2. You connected the power backwards, so -12V was pumped straight through everything.

There seems to be no polarity protection on the board as far as I can see, and many regulators, if connected backwards, will just pass the power straight through with little or no change to it.  So my money is on having connected the power backwards.  Now, that might not be your fault, since on that site I can see no mention of which polarity the power connector uses - whether it is pin-positive or pin-negative.  The normal way (the way the Arduino board uses) is pin-positive, but that is not always the case.

Either way, the Arduino is now dead, and the GSM module may be dead as well. In fact the whole lot may be dead.


sender: user

message:
How to check if a GSM module is working or not?

I wanted to know if my GSM sim800 is working or not. A mishap occured while I was experimenting around with my GSM module and I arduino uno. The link to the module which I bought: http://www.ebay.in/itm/SIM800-Quad-Band-GSM-Module-with-SMA-Antenna-Better-than-SIM900A-or-SIM900-/301782413058?hash=item4643a22f02:g:8LsAAOSwwbdWMidW I want to know ow can I check if my module is fine?

sender: assistant

body:
Power it up and check the 'status' light.  If it blinks with a 1 blink per second cycle, it is attempting to connect to the network.  If it connects, it does a slow blink at 1 blink/3s, it made the network connection.

I don't know if your board does an auto-power-on, but you might need to push the power button or reset button.


message:
scroll text through multiple i2c connected dot matrix displays

I have 4 dot matrix displays, every one of them connected to an i2c and accessible with `0x70`, `0x71`, `0x72` and `0x73`. All these work just fine when I address them apart. What I want to achieve is a scrolling text throughout all 4 displays. How can I do this? Are there any libraries around that already do this? (I did not find any).

Basically, this is my code:

    #include <Wire.h>
    #include "Adafruit_LEDBackpack.h"
    #include "Adafruit_GFX.h"

    Adafruit_8x8matrix matrix[4];

    void setup() {
      Serial.begin(9600);
      Serial.println("4x(8x8) LED Matrix Test");
      matrix[0].begin(0x70);
      matrix[1].begin(0x71);
      matrix[2].begin(0x72);
      matrix[3].begin(0x73);
    }

body:
This is what I found behind the link @mikael-patel posted, and with a little configuration it does exactly what I want. Basically the `scroll()`-method handles anything neccessary.

    #include <Wire.h>
    #include "Adafruit_LEDBackpack.h"
    #include "Adafruit_GFX.h"

    #define NUM_MATRICES 2
    Adafruit_8x8matrix matrix[NUM_MATRICES];

    void setup() {
      Serial.begin(9600);
      Serial.println("8x8 LED Matrix Test");

      for(uint8_t m=0; m<NUM_MATRICES; m++) {
        matrix[m].begin(0x70 + m);
        matrix[m].clear();
        matrix[m].setTextSize(1);
        matrix[m].setTextWrap(false);  // we dont want text to wrap so it scrolls nicely
        matrix[m].setTextColor(LED_GREEN);
      }
    }

    void loop() {
      scroll("Hello World!");
    }

    void scroll(char* text) {
      int scrollPositions = (strlen(text) * 8) + 32;

      for (int x=(8 * NUM_MATRICES); x>=-scrollPositions; x--) {
       for(uint8_t m=0; m<NUM_MATRICES; m++) {
        matrix[m].clear();
        matrix[m].setCursor((x - (m * 8)), 0);
        matrix[m].print(text);
        matrix[m].writeDisplay();
       }
       delay(80);
      }
    }


message:
Upload with esptool fails with "espcomm_send_command: can't receive slip payload data"

Uploading a sketch to an ESP8266 board fails with:

    error: failed reading byte
    warning: espcomm_send_command: can't receive slip payload data
    warning: espcomm_send_command(FLASH_DOWNLOAD_BEGIN) failed

...or:

    espcomm cmd: receiving 2 bytes of data
    warning: espcomm cmd: no final C0
    warning: espcomm_send_command(FLASH_DOWNLOAD_BEGIN) failed

This is on OS X with a PL2303HXD USB-to-Serial cable, using the latest official Prolific signed [OS X El Capitan-compatible drivers][1].

  [1]: http://prolificusa.com/pl-2303hx-drivers/

body:
This is [a known issue][1] with [the included esptool][2], and for the Arduino IDE there are quite a few blog posts to be found on this problem. But most are outdated, and are not applicable when using [PlatformIO][3] with some other IDE. So, February 2016:

**Install [esptool.py](https://github.com/themadinventor/esptool)**

- `git clone https://github.com/themadinventor/esptool/` (or download the ZIP file)
- `cd esptool`
- `sudo python setup.py install`

**When using Arduino IDE**

- Open `~/Library/Arduino15/packages/esp8266/hardware/esp8266/2.0.0/platform.txt`.
- Find the line `tools.esptool.upload.pattern` and disable that by prefixing with a hash. Check that your version only mentions `-ca 0x00000`, not `-ca 0x10000` as well (like in most outdated blog posts):

        # tools.esptool.upload.pattern="{path}/{cmd}" {upload.verbose} -cd {upload.resetmethod} -cb {upload.speed} -cp "{serial.port}" -ca 0x00000 -cf "{build.path}/{build.project_name}.bin"

- Add the following, referring to the `esptool.py` you installed above and also using different command line parameters:

        # Fix for espcomm_send_command: cant receive slip payload data
        tools.esptool.upload.pattern="/path/to/new/esptool.py" --port "{serial.port}" --baud {upload.speed} write_flash 0x00000 "{build.path}/{build.project_name}.bin"

- Restart the IDE.

(One might be tempted to just change `tools.esptool.path` and `tools.esptool.cmd` instead, but beware that the command line parameters need changing as well.)

**When using PlatformIO**

You will find the same `platform.txt` file somewhere in `~/.platformio/packages/framework-arduinoespressif/platform.txt`, but that file is not used for the upload. [Instead][4]:

- In `platformio.ini` add:

        # ...or whatever your port is named
        upload_port = /dev/cu.usbserial
        extra_script = /path/to/platformio_extra_script.py

- Create a new file `/path/to/platformio_extra_script.py`:

        # Custom settings, as referred to as "extra_script" in platformio.ini
        #
        # See http://docs.platformio.org/en/latest/projectconf.html#extra-script
        # See https://github.com/platformio/platformio/issues/426

        from SCons.Script import DefaultEnvironment

        env = DefaultEnvironment()

        # Must be full path, or use
        # https://docs.python.org/2/library/os.path.html#os.path.expanduser

        env.Replace(
            LOCAL_UPLOADER="/Users/arjan/path/to/new/esptool.py",
            LOCAL_UPLOADERFLAGS=[
                "--port", "$UPLOAD_PORT",
                "--baud", "$UPLOAD_SPEED",
                "write_flash", "0x00000",
            ],
            UPLOADCMD='$LOCAL_UPLOADER $LOCAL_UPLOADERFLAGS $SOURCE'
        )

  [1]: https://github.com/igrr/esptool-ck/issues/9
  [2]: https://github.com/igrr/esptool-ck
  [3]: http://platformio.org
  [4]: https://github.com/platformio/platformio/issues/426


message:
Manual reset is required on power on

I am powering a UNO through the 5V pin. I am using a tftlcd shield (2.8" mcufriend.com) on it.

To be able to use the shield with I2C I had to snip the RST leg from the shield. That was done because the shield used A4 which was required for I2C.
 When I power the UNO through the USB port the program starts correctly and a bitmap is loaded onto the screen. When I power up from the 5V pin or the power adapter, the screen remains white. I have to manually press the reset button on the UNO and then the program loads the bitmap.

The ladyAda examples had this to say;

    #define LCD_CS A3 // Chip Select goes to Analog 3
    #define LCD_CD A2 // Command/Data goes to Analog 2
    #define LCD_WR A1 // LCD Write goes to Analog 1
    #define LCD_RD A0 // LCD Read goes to Analog 0
    #define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
    Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

Does that mean I should solder the lcd RST pin to the RESET on the UNO? (if so I am not sure how I can do that without taking the lcd shield to pieces).

body:
It isn't clear from the description whether your setup has a hardware problem or a software problem.  For example, the rationale for “I had to snip the RST leg from the shield” is unclear.

The comment in ladyAda's example, “Can alternately just connect to Arduino's reset pin”, means that it's suitable to hardware-reset the LCD at the same time the Arduino does a hardware reset.  If the “RST leg from the shield” that you snipped is the LCD reset pin, as opposed to a pin driven by the small tactile reset switch on the 2.8" mcufriend shield, you probably should restore that pin.  In other words, unsolder and remove the stub of the pin you snipped off, insert a new pin, and solder it in place.

Note, just reinstalling the pin might make things work.  It's possible the LCD is sitting there in a permanently-reset  state, due to its RST input hanging open.  It's also possible the library is already driving RST properly but that drive isn't getting through, due to the missing pin.  Whatever the case may be, with the pin in place you should be able to software-reset the LCD by pulsing A4.  (Ie, with consecutive `digitalWrite()` commands, in `setup()` and before shield initialization, take A4 high and then low, or vice versa.)

*Edit:* If A4 isn't available for resetting the LCD (due to its use as the SDA signal for I2C, per comment) you might try adding a jumper wire from the shield's LCD_RS pin (above A4) to an available pin, and adjust the `#define LCD_RESET` statement accordingly.

In general, to add a jumper wire, strip about 5 mm of each end of a short piece of #30 [wire-wrap](https://en.wikipedia.org/wiki/Wire_wrap) wire.  Form a small hook at each end.  Hold a hook onto the solder of the pin you wish to attach to and briefly heat the solder, letting the hook sink into the solder.  If you don't have wire-wrap wire, use a single strand from some old stranded cable (eg, mouse or keyboard).  Use thin heatshrink tubing or a bit of stripped-off cable insulation to insulate the jumper.  To keep pins in place while soldering, seat the pins being worked on into an old disk-drive connector, or another shield, or if you have nothing else, an Uno.

In your particular case, an mcufriend shield on an Uno, no pins are available unless you co-opt one of the SD-card-slot signals.  But before doing that, it's probably worthwhile to try your original idea of wiring to the Uno's RESET pin.  Your jumper would run from J3's second pin (A4) to J4's last pin (Reset), installed on the LCD side of the shield.  You should be able to see the trace between the Reset pin and the Reset switch, when identifying the Reset pin.


message:
Upload Code on Arduino Mega using FTDI Cable

I would like to upload my code to the Arduino Mega 2560.

 1. The USB is fried hence I have to use the FTDI
 2. I've a FTDI cable, but it has only 4 wires, Vcc,GND,TX,RX

How do you upload, as the ATmega is not responding to anything?

body: FTDI cables usually have RTS which is used to bring `Reset` low. If you only have four pins, press the Reset button on the board the moment you start the upload.


message:
How to connect two IMU in one arduino board?

The code below works fine when  one IMU (MPU9250). What I want to know is how can I edit this code to work perfectly with two IMU (MPU9250) in one arduino board ?

Hope someone can help me. THANKS :)

<!-- language: c -->

    ////////////////////////////////////////////////////////////////////////////
          //
          //  This file is part of RTIMULib-Arduino
          //
          //  Copyright (c) 2014-2015, richards-tech
         //
         //  Permission is hereby granted, free of charge, to any person           obtaining a copy of
        //  this software and associated documentation files (the "Software"), to deal in
        //  the Software without restriction, including without limitation the rights to use,
       //  copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
       //  Software, and to permit persons to whom the Software is furnished to do so,
       //  subject to the following conditions:
       //
       //  The above copyright notice and this permission notice shall be included in all
      //  copies or substantial portions of the Software.
      //
      //  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
      //  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
      //  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
      //  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
      //  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
      //  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

      #include <Wire.h>
      #include "I2Cdev.h"
      #include "RTIMUSettings.h"
      #include "RTIMU.h"
      #include "RTFusionRTQF.h"
      #include "RTPressure.h"
      #include "CalLib.h"
      #include <EEPROM.h>

      RTIMU *imu;                                           // the IMU object
      RTPressure *pressure;                                 // the pressure object
      RTFusionRTQF fusion;                                  // the fusion object
      RTIMUSettings settings;                               // the settings object

      //  DISPLAY_INTERVAL sets the rate at which results are displayed

      #define DISPLAY_INTERVAL  300                         // interval between   pose displays

     //  SERIAL_PORT_SPEED defines the speed to use for the debug serial port

     #define  SERIAL_PORT_SPEED  115200

      unsigned long lastDisplay;
      unsigned long lastRate;
      int sampleCount;

      void setup()
      {
      int errcode;

      Serial.begin(SERIAL_PORT_SPEED);
      Wire.begin();
      imu = RTIMU::createIMU(&settings);                        // create the    imu object
      pressure = RTPressure::createPressure(&settings);         // create the  pressure sensor

      if (pressure == 0) {
      Serial.println("No pressure sensor has been configured - terminating");
        while (1) ;
       }

       Serial.print("ArduinoIMU10 starting using IMU "); Serial.print(imu-   >IMUName());
       Serial.print(", pressure sensor "); Serial.println(pressure->pressureName());
       if ((errcode = imu->IMUInit()) < 0) {
       Serial.print("Failed to init IMU: "); Serial.println(errcode);
       }

       if ((errcode = pressure->pressureInit()) < 0) {
       Serial.print("Failed to init pressure sensor: ");
       Serial.println(errcode);
       }

       if (imu->getCalibrationValid())
       Serial.println("Using compass calibration");
       else
       Serial.println("No valid compass calibration data");

        lastDisplay = lastRate = millis();
        sampleCount = 0;

        // Slerp power controls the fusion and can be between 0 and 1
        // 0 means that only gyros are used, 1 means that only accels/compass are used
       // In-between gives the fusion mix.

       fusion.setSlerpPower(0.02);

       // use of sensors in the fusion algorithm can be controlled here
       // change any of these to false to disable that sensor

        fusion.setGyroEnable(true);
        fusion.setAccelEnable(true);
        fusion.setCompassEnable(true);
        }

         void loop()
         {
         unsigned long now = millis();
         unsigned long delta;
         float latestPressure;
         float latestTemperature;
         int loopCount = 1;

          while (imu->IMURead()) {                                // get the latest data if ready yet
          // this flushes remaining data in case we are falling behind
          if (++loopCount >= 10)
             continue;

          fusion.newIMUData(imu->getGyro(), imu->getAccel(), imu->getCompass(), imu->getTimestamp());
          sampleCount++;
          if ((delta = now - lastRate) >= 1000) {
          Serial.print("Sample rate: "); Serial.print(sampleCount);
          if (imu->IMUGyroBiasValid())
          Serial.println(", gyro bias valid");
          else
          Serial.println(", calculating gyro bias");

            sampleCount = 0;
            lastRate = now;
           }
           if ((now - lastDisplay) >= DISPLAY_INTERVAL) {
            lastDisplay = now;
           //          RTMath::display("Gyro:", (RTVector3&)imu->getGyro());
                      // gyro data
            //          RTMath::display("Accel:", (RTVector3&)imu->getAccel());
                         // accel data
           //          RTMath::display("Mag:", (RTVector3&)imu->getCompass());
              // compass data
            RTMath::displayRollPitchYaw("Pose:",   (RTVector3&)fusion.getFusionPose()); // fused output

            if (pressure->pressureRead(latestPressure, latestTemperature)) {
                Serial.print(", pressure: "); Serial.print(latestPressure);
                Serial.print(", temperature: ");
            Serial.print(latestTemperature);
            }
            Serial.println();
            }
            }
            }

EDITED CODE:

           #include <Wire.h>
           #include "I2Cdev.h"
           #include "RTIMUSettings.h"
           #include "RTIMU.h"
           #include "RTFusionRTQF.h"
           #include "RTPressure.h"
           #include "CalLib.h"
           #include <EEPROM.h>

           RTIMU *imu;                                           // the IMU object
          RTPressure *pressure;                                 // the pressure object
          RTFusionRTQF fusion;                                  // the fusion object
          RTIMUSettings settings;                               // the settings object

          //  DISPLAY_INTERVAL sets the rate at which results are displayed

          #define DISPLAY_INTERVAL  300                         // interval between   pose displays

         //  SERIAL_PORT_SPEED defines the speed to use for the debug serial port

         #define  SERIAL_PORT_SPEED  115200

        unsigned long lastDisplay;
        unsigned long lastRate;
        int sampleCount;

        // ================= MPU: 1 =================

       RTIMU *imu1;                                           // the IMU object
       RTPressure *pressure1;                                 // the pressure object
       RTFusionRTQF fusion1;                                  // the fusion object
       RTIMUSettings settings1;                               // the settings object

       unsigned long lastDisplay1;
       unsigned long lastRate1;
       int sampleCount1;

       const int CS_MAX = 2;
       const int CS[CS_MAX] = { 7, 8 };

       void setup()
       {
      for (int i = 0; i < CS_MAX; i++) {
      pinMode(CS[i], OUTPUT);
      digitalWrite(CS[i], HIGH);
      }

      int errcode;

      Serial.begin(SERIAL_PORT_SPEED);
      Wire.begin();
       imu = RTIMU::createIMU(&settings);                        // create the imu object
      pressure = RTPressure::createPressure(&settings);         // create the pressure sensor

      if (pressure == 0) {
      Serial.println("No pressure sensor has been configured - terminating");
      while (1) ;
       }

       Serial.print("ArduinoIMU10 starting using IMU "); Serial.print(imu->IMUName());
       Serial.print(", pressure sensor "); Serial.println(pressure->pressureName());

      for (int i = 0; i < CS_MAX; i++) {
      digitalWrite(CS[i], LOW);
      if ((errcode = imu->IMUInit()) < 0) {
      Serial.print("Failed to init IMU: "); Serial.println(errcode);
      }

      if ((errcode = pressure->pressureInit()) < 0) {
      Serial.print("Failed to init pressure sensor: "); Serial.println(errcode);
      }

      if (imu->getCalibrationValid())
        Serial.println("Using compass calibration");
      else
        Serial.println("No valid compass calibration data");

      lastDisplay = lastRate = millis();
      sampleCount = 0;

       // Slerp power controls the fusion and can be between 0 and 1
       // 0 means that only gyros are used, 1 means that only accels/compass are   used
      // In-between gives the fusion mix.

      fusion.setSlerpPower(0.02);

      // use of sensors in the fusion algorithm can be controlled here
      // change any of these to false to disable that sensor

       fusion.setGyroEnable(true);
       fusion.setAccelEnable(true);
       fusion.setCompassEnable(true);
       digitalWrite(CS[i], HIGH);
       }

       int errcode1;
       Serial.begin(SERIAL_PORT_SPEED);
       Wire.begin();
       imu1= RTIMU::createIMU(&settings1);                        // create the imu object
       pressure1 = RTPressure::createPressure(&settings1);         // create the pressure sensor

        if (pressure1 == 0) {
        Serial.println("No pressure sensor has been configured - terminating");
        while (1) ;
        }

        Serial.print("ArduinoIMU10 starting using IMU "); Serial.print(imu1->IMUName());
        Serial.print(", pressure sensor "); Serial.println(pressure1->pressureName());

        for (int i = 0; i < CS_MAX; i++) {
        digitalWrite(CS[i], LOW);

        if ((errcode1 = imu1->IMUInit()) < 0) {
        Serial.print("Failed to init IMU1: "); Serial.println(errcode1);
        }

        if ((errcode1 = pressure1->pressureInit()) < 0) {
         Serial.print("Failed to init pressure sensor1: ");
         Serial.println(errcode1);
         }

         if (imu1->getCalibrationValid())
        Serial.println("Using compass calibration");
        else
        Serial.println("No valid compass calibration data1");

        lastDisplay1 = lastRate1 = millis();
        sampleCount1 = 0;

        // Slerp power controls the fusion and can be between 0 and 1
        // 0 means that only gyros are used, 1 means that only accels/compass are used
        // In-between gives the fusion mix.

        fusion1.setSlerpPower(0.02);

       // use of sensors in the fusion algorithm can be controlled here
       // change any of these to false to disable that sensor

         fusion1.setGyroEnable(true);
         fusion1.setAccelEnable(true);
         fusion1.setCompassEnable(true);

         digitalWrite(CS[i], HIGH);
         }
         }

         void loop()
         {
         unsigned long now = millis();
         unsigned long delta;
         float latestPressure;
         float latestTemperature;
         int loopCount = 1;

          while (imu->IMURead()) {                                // get the   latest data if ready yet
          // this flushes remaining data in case we are falling behind
          if (++loopCount >= 10)
            continue;

           fusion.newIMUData(imu->getGyro(), imu->getAccel(), imu->getCompass(), imu->getTimestamp());
            sampleCount++;
            if ((delta = now - lastRate) >= 1000) {
            Serial.print("Sample rate: "); Serial.print(sampleCount);
            if (imu->IMUGyroBiasValid())
                Serial.println(", gyro bias valid");
            else
                Serial.println(", calculating gyro bias");

            sampleCount = 0;
            lastRate = now;
            }
            if ((now - lastDisplay) >= DISPLAY_INTERVAL) {
            lastDisplay = now;
            //          RTMath::display("Gyro:", (RTVector3&)imu->getGyro());

             // gyro data
             //          RTMath::display("Accel:", (RTVector3&)imu->getAccel());

             // accel data
            //          RTMath::display("Mag:", (RTVector3&)imu->getCompass());
            // compass data
              RTMath::displayRollPitchYaw("Pose:",
              (RTVector3&)fusion.getFusionPose()); // fused output

             if (pressure->pressureRead(latestPressure, latestTemperature)) {
                Serial.print(", pressure: "); Serial.print(latestPressure);
                Serial.print(", temperature: ");
                Serial.print(latestTemperature);
            }
            Serial.println();
            }
            }

           unsigned long now1 = millis();
          unsigned long delta1;
          float latestPressure1;
          float latestTemperature1;
          int loopCount1 = 1;

          while (imu1->IMURead()) {                                // get the latest data if ready yet
          // this flushes remaining data in case we are falling behind
          if (++loopCount1 >= 10)
            continue;

          fusion1.newIMUData(imu1->getGyro(), imu1->getAccel(), imu1-  >getCompass(), imu1->getTimestamp());
          sampleCount1++;
          if ((delta1 = now1 - lastRate1) >= 1000) {
            Serial.print("Sample rate: "); Serial.print(sampleCount1);
            if (imu1->IMUGyroBiasValid())
                Serial.println(", gyro bias valid");
            else
                Serial.println(", calculating gyro bias");

            sampleCount1 = 0;
            lastRate1 = now1;
        }
        if ((now1 - lastDisplay1) >= DISPLAY_INTERVAL) {
            lastDisplay1 = now1;
          //          RTMath::display("Gyro1:", (RTVector3&)imu1->getGyro());
          // gyro data
          //          RTMath::display("Accel1:", (RTVector3&)imu1->getAccel());
          // accel data
          //          RTMath::display("Mag1:", (RTVector3&)imu1->getCompass());
            // compass data
            RTMath::displayRollPitchYaw("Pose1:", (RTVector3&)fusion1.getFusionPose()); // fused output

            if (pressure1->pressureRead(latestPressure1, latestTemperature1)) {
                Serial.print(", pressure: "); Serial.print(latestPressure1);
                Serial.print(", temperature: "); Serial.print(latestTemperature1);
            }
            Serial.println();
        }
    }
}

body:
Before editing the code to support an additional MPU9X50 you will need to figure out a way to address them on the I2C bus. Hopefully the MPU9X50 module you are using has a pin named AD0.

There are two basic solutions to multiple MPU9X50.

The first solution is to use the two different addresses. AD0 pin LOW on one and AD0 pin HIGH on the other. The sketch above would require two instances (imu), one for each module/address.

The second solution, which works for several modules, is to hold the AD0 pin LOW for the module that is addresses and all other HIGH. The setting must be handled by a digital pin. One for each module. They will be used as chip/module select. Below the example code assumes that the MPU I2C address is with the lowest bit LOW.

In the setup() initiate these pins to output mode and high. The example code uses pin 7 and 8.

    const int CS_MAX = 2;
    const int CS[CS_MAX] = { 7, 8 };

    void setup()
    {
       ...
       for (int i = 0; i < CS_MAX; i++) {
         pinMode(CS[i], OUTPUT);
         digitalWrite(CS[i], HIGH);
       }
       ...
    }

Set the digital pin LOW for the module you want to address before calling an MPU library function and back to HIGH afterwards.

    digitalWrite(CS[0], LOW);
    imu->someMemberFunction();
    digitalWrite(CS[0], HIGH);

If several functions are called in a block it can be convenient to run all of them per module. An example section from the setup:

    for (int i = 0; i < CS_MAX; i++) {
      digitalWrite(CS[i], LOW);

      if ((errcode = imu->IMUInit()) < 0) {
        Serial.print("Failed to init IMU: ");
        Serial.println(errcode);
      }

      if (imu->getCalibrationValid())
        Serial.println("Using compass calibration");
      else
        Serial.println("No valid compass calibration data");

      digitalWrite(CS[i], HIGH);
    }

Cheers!


message:
Led issue with arduino controled by raspberry pi/python

I'm having an issue with my project. My project is 8 leds and a potentiometer on an arduino being read and controlled by a raspberry pi running python.

when I'm using a potentiometer the signal is received by my raspberry pi with python which then tells a set of leds to either turn on or off. However my leds flash on my low threshold when they shouldn't, the leds on my higher threshold work as expected and stay on till my pot is out of that range. How can I fix this?

Here is my script!

    from nanpy import Arduino
    from nanpy import serial_manager
    from time import sleep

    serial_manager.connect('/dev/ttyUSB0')

    POT = 0
    LED1 = 13
    LED2 = 12
    LED3 = 11
    LED4 = 10
    LED5 = 9
    LED6 = 8
    LED7 = 7
    LED8 = 6

    Arduino.pinMode(POT, Arduino.INPUT)
    Arduino.pinMode(13, Arduino.OUTPUT)
    Arduino.pinMode(12, Arduino.OUTPUT)
    Arduino.pinMode(11, Arduino.OUTPUT)
    Arduino.pinMode(10, Arduino.OUTPUT)
    Arduino.pinMode(9, Arduino.OUTPUT)
    Arduino.pinMode(8, Arduino.OUTPUT)
    Arduino.pinMode(7, Arduino.OUTPUT)
    Arduino.pinMode(6, Arduino.OUTPUT)

    print "starting"
    while True:
        pot = Arduino.analogRead(POT)
    #this is the section that is blinking when it should stay solid
       if pot < 450:
            Arduino.digitalWrite(LED1, Arduino.HIGH)
            Arduino.digitalWrite(LED2, Arduino.HIGH)
            Arduino.digitalWrite(LED3, Arduino.HIGH)
            Arduino.digitalWrite(LED4, Arduino.HIGH)
            Arduino.digitalWrite(LED5, Arduino.LOW)
            Arduino.digitalWrite(LED6, Arduino.LOW)
            Arduino.digitalWrite(LED7, Arduino.LOW)
            Arduino.digitalWrite(LED8, Arduino.LOW)
            sleep(.5)
    # end of section
       if pot < 650 > 450:
            Arduino.digitalWrite(LED1, Arduino.LOW)
            Arduino.digitalWrite(LED2, Arduino.LOW)
            Arduino.digitalWrite(LED3, Arduino.LOW)
            Arduino.digitalWrite(LED4, Arduino.LOW)
            Arduino.digitalWrite(LED5, Arduino.LOW)
            Arduino.digitalWrite(LED6, Arduino.LOW)
            Arduino.digitalWrite(LED7, Arduino.LOW)
            Arduino.digitalWrite(LED8, Arduino.LOW)
            sleep(.1)
        if pot > 650:
            Arduino.digitalWrite(LED1, Arduino.LOW)
            Arduino.digitalWrite(LED2, Arduino.LOW)
            Arduino.digitalWrite(LED3, Arduino.LOW)
            Arduino.digitalWrite(LED4, Arduino.LOW)
            Arduino.digitalWrite(LED5, Arduino.HIGH)
            Arduino.digitalWrite(LED6, Arduino.HIGH)
            Arduino.digitalWrite(LED7, Arduino.HIGH)
            Arduino.digitalWrite(LED8, Arduino.HIGH)
            sleep(.5)
        print pot

body:
Your second condition is written wrongly. It should be this way:

    elif pot >= 450 and pot <= 650:
        # do stuff

Your code should be such that only an option is chosen at any time. There should be only one 'if' condition at the top and the rest should be 'elif'.


body:
The problem is you're using multiple **if** statements, whereas the if-blocks should be mutually exclusive, so **elif** would be better.  It's not really clear what you intend in the 2nd clause either, since it's a typo(?) - not valid python syntax anyway.

    if (pot <= 450):
        Arduino.digitalWrite(LED1, Arduino.HIGH)
        ...
        time.sleep(0.5)
    elif (pot > 450 and pot <= 650):
        Arduino.digitalWrite(LED1, Arduino.LOW)
        ...
        time.sleep(0.1)
    else # pot > 650
        Arduino.digitalWrite(LED1, Arduino.LOW)
        ...
        time.sleep(0.5)

I think your LEDs were flashing because both the first and second **if** clauses were evaluating to True, thus both code segments were being executed (were only the first four LEDs flashing?)  Using if/elif/else instead, ensures only ever one clause is run.

If I might make a suggestion, assuming you want an LED bar graph based on the POT reading...

The analogRead() will give you a result 0-1023. Graphed over 8 LEDs, this means one more LED should be illuminated roughly per 128 units.  Since you want a full bar when rounding makes the value near 1023, maybe something like 120 is a better divisor (I just guessed this, it's probably calculable).

A simple loop over your LEDs, summing units over each iteration gives an easy way of turning the LEDs on or off.

    Arduino.analogRead(POT)
    led_bar_per_units = 120   # needs a better name

    ### illuminate the LED-bar
    bar_length = 0
    for led in (LED1, LED2, LED3, LED4, LED5, LED6, LED7, LED8):
        bar_length += led_per_bar_units
        if (bar_length <= pot):
            Arduino.digitalWrite(led, Arduino.HIGH)
        else:
            Arduino.digitalWrite(led, Arduino.LOW)
    time.sleep(0.5)

EDIT: I know you don't need brackets around python **if** statements.  I've been doing C/C++ code for so long I find bracketed-clauses easier to read, and thus code my python this way too.


body:
I figured it out.
Here is my new script.

    from nanpy import Arduino
    from nanpy import serial_manager
    from time import sleep

    serial_manager.connect('/dev/ttyUSB0')

    POT = 0
    LED1 = 13
    LED2 = 12
    LED3 = 11
    LED4 = 10
    LED5 = 9
    LED6 = 8
    LED7 = 7
    LED8 = 6

    Arduino.pinMode(POT, Arduino.INPUT)
    Arduino.pinMode(13, Arduino.OUTPUT)
    Arduino.pinMode(12, Arduino.OUTPUT)
    Arduino.pinMode(11, Arduino.OUTPUT)
    Arduino.pinMode(10, Arduino.OUTPUT)
    Arduino.pinMode(9, Arduino.OUTPUT)
    Arduino.pinMode(8, Arduino.OUTPUT)
    Arduino.pinMode(7, Arduino.OUTPUT)
    Arduino.pinMode(6, Arduino.OUTPUT)

    print "starting"
    while True:
        pot = Arduino.analogRead(POT)
        if pot < 450:
            Arduino.digitalWrite(LED1, Arduino.HIGH)
            Arduino.digitalWrite(LED2, Arduino.HIGH)
            Arduino.digitalWrite(LED3, Arduino.HIGH)
            Arduino.digitalWrite(LED4, Arduino.HIGH)
            Arduino.digitalWrite(LED5, Arduino.LOW)
            Arduino.digitalWrite(LED6, Arduino.LOW)
            Arduino.digitalWrite(LED7, Arduino.LOW)
            Arduino.digitalWrite(LED8, Arduino.LOW)
            sleep(.01)
        elif pot > 650:
            Arduino.digitalWrite(LED1, Arduino.LOW)
            Arduino.digitalWrite(LED2, Arduino.LOW)
            Arduino.digitalWrite(LED3, Arduino.LOW)
            Arduino.digitalWrite(LED4, Arduino.LOW)
            Arduino.digitalWrite(LED5, Arduino.HIGH)
            Arduino.digitalWrite(LED6, Arduino.HIGH)
            Arduino.digitalWrite(LED7, Arduino.HIGH)
            Arduino.digitalWrite(LED8, Arduino.HIGH)
            sleep(.01)
        else:
            Arduino.digitalWrite(LED1, Arduino.LOW)
            Arduino.digitalWrite(LED2, Arduino.LOW)
            Arduino.digitalWrite(LED3, Arduino.LOW)
            Arduino.digitalWrite(LED4, Arduino.LOW)
            Arduino.digitalWrite(LED5, Arduino.LOW)
            Arduino.digitalWrite(LED6, Arduino.LOW)
            Arduino.digitalWrite(LED7, Arduino.LOW)
            Arduino.digitalWrite(LED8, Arduino.LOW)
            sleep(.01)
        print pot


message:
LCDs measuring volts arduino

How do we measure 100 Volts Arduino LCD [Proje][1]

    #include <LiquidCrystal.h>
    LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
    int analogInput = 0;
    float vout = 0.0;
    float vin = 0.0;
    float R1 = 100000.0; // 100K ohm direnç
    float R2 = 10000.0; // 10K ohm direnç
    int value = 0;
    void setup(){
       pinMode(analogInput, INPUT);
       lcd.begin(16, 2);
       lcd.print("DC VOLTMETRE-PROJEHOCAM");
    }
    void loop(){
       // read the value at analog input
       value = analogRead(analogInput);
       vout = (value * 5.0) / 1024.0;
       vin = vout / (R2/(R1+R2));
       if (vin<0.09) {
       vin=0.0;
    }
    lcd.setCursor(0, 1);
    lcd.print("VOLTAJ V= ");
    lcd.print(vin);
    delay(500);
    }

  [1]: http://www.projehocam.com/arduino-lcd-voltmetre-yapimi/

body:
The project that you show as your reference : [link in your question](http://www.projehocam.com/arduino-lcd-voltmetre-yapimi/),  shows this picture :

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

Change R1 to 200 K ohms.   The Arduino will receive 4.76 volts when the input is 100 volts.

You will also need to change your program line for float R1 = 100000.0;

**CAUTION :  Beware of high voltage.  Also, the Arduino is not isolated from the 100 volts.**

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


message:
Sim800 sim card requirements

What kind of a sim card is required for sim800 module? I know it must be activated and must be valid. But about 2g, 3g or LTE...What kind of a sim card in overall should I use with this module?

body:
> What kind of a sim card is required for sim800 module?

*The SIM interface complies with the GSM Phase 1 specification and the new GSM Phase 2+ specification for FAST 64 kbps SIM card. Both 1.8V and 3.0V SIM card
are supported. The SIM interface is powered from an internal regulator in the module.*

For more details see [here][1] and [here][2]. And remember "Google is your friend".

Cheers!

  [1]: https://www.adafruit.com/datasheets/sim800h_hardware_design_v1.00.pdf
  [2]: https://learn.adafruit.com/adafruit-fona-mini-gsm-gprs-cellular-phone-module/obtaining-a-sim


message:
ATtiny85 communication with computer through USB

I am trying to receive and send some data from a computer to an ATtiny through USB. Can an ATtiny85 IC communicate with a computer through USB? If yes, how should it be connected?

body:
> Can an ATtiny85 ic communicate with a computer through USB?if yes,how should be the connection?

Have you checked the web? There are many such projects. Here is a link to one:

http://www.instructables.com/id/Digispark-DIY-The-smallest-USB-Arduino/

Please remember "Google is your friend".

Cheers!


body:
Digispark made a lot of these as part of a "cheap Arduino USB interface" project a while back.

This is my Digispark, it's pretty cute:

[![Digispark][1]][1]

They have a [web page here](https://digistump.com/wiki/digispark).

---

I got them for about $2 each. The board has the ATtiny85, a voltage regulator, and a handful of other parts.

Schematic (courtesy of [Digistump Wiki](https://digistump.com/wiki/digispark/tutorials/digispark)):

[![Digispark schematic][2]][2]

---

More information about the Virtual USB idea at [USB-Keyboard with Arduino and V-USB library, an example](http://blog.petrockblock.com/2012/05/19/usb-keyboard-with-arduino-and-v-usb-library-an-example/).

  [1]: https://i.stack.imgur.com/0oXID.jpg
  [2]: https://i.stack.imgur.com/Iv2bq.png


message:
Can an AT89S52 be programmed using an Arduino as ISP?

Since the AT89S52 controller is ISP programmable is it possible to use an Arduino UNO as a programmer to upload the hex file to the 8952 ?

I've tried various programmer softwares such as progisp, 8051 loader and ISP Prog v1.4 but the Arduino doesnt show up as a programmer on any of these. I've uploaded the ArduinoISP sketch on the UNO and then tried to program the 8952 without any luck.

According to my understanding the ISP programmers use an ATMega8 ,so is what I'm trying to do possible or do I need to purchace an ISP programmer ?

body:
You should be able to use the Arduino as an ISP since an ISP is basically just a serial to SPI interface. If you are trying to use the arduino software to upload your program, you will need to edit your boards.txt file to be able to talk to the chip. If you are just using avrdude you will need to update your avrdude.conf.  [AVR Freaks][1] has a post on someone trying something similar and may be of some help. Without knowing your environment it's difficult to give more specific advice

  [1]: http://www.avrfreaks.net/forum/writing-at89s52-through-usbasp


body:
You might be able to use the programmer sketch I wrote a while back (it runs on a Uno). You need an SD card interface so it can read the .hex file for programming. See: <http://www.gammon.com.au/uploader>

You connect things up roughly like this (Atmega328P shown, your wiring would be different at the target chip side):

[![Chip programmer][1]][1]

You would need to modify the sketch to add the details for the AT89S52. As far as I can make out from the datasheet:

* Signature: 0x1E 0x52 0x06
* PROGMEM: 8k bytes
* RAM: 256 bytes
* Pinouts: Depending on the chip package. You need to identify MOSI/MISO/SCK/RESET along with Vcc and Gnd.
* Fuses: None that I can see
* Flash page size: 256 bytes

Thus you could modify the table of chips to add that one, along these lines:

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

    // see Atmega datasheets
    const signatureType signatures [] PROGMEM =
      {
    //     signature        description   flash size   bootloader  flash  fuse
    //                                                     size    page    to
    //                                                             size   change

      // AT89S52
      { { 0x1E, 0x52, 0x06 }, "AT89S52",   8 * kb,           0,   256,   NO_FUSE },

    // ... other ones here ...

I haven't got an AT89S52 to test it on, so I can't say for sure I got those parameters right. I am assuming that the programming instructions for ICSP programming are the same as for the other chips in their range.

---

* Sketch source: <https://github.com/nickgammon/arduino_sketches>

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


message:
driver is not showing up in Port assignments mac

arduino nano, the driver is not showing up in Port assignments. It has worked with this operating system before. I’ve messed something up.  “OS X EI Capitan ver. 10.11.3 I have check the posts but the serial port is a no show

[![Available Ports ][1]][1]

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

body:
If the port showed in earlier versions of OS X, but never showed after upgrading to El Capitan, then you probably used an unsigned driver, which is no longer allowed by Apple's new [System Integrity Protection][1] (a.k.a. "Rootless"; more details [in a WWDC session][2]).

Any unsigned drivers will have been disabled during the upgrade process. Even more, SIP does not allow *any* non-Apple files in `/System`, `/bin`, `/sbin` and `/usr` (except for `/usr/local`), so anything you had put in there will have been moved away as well. To see what has been disabled:

- `ls -l "/Incompatible Software"`
- `ls -lR /Library/SystemMigration/History/Migration-*/QuarantineRoot/*`

To get it working again: find a signed driver, or [Switch off SIP][3].

  [1]: https://support.apple.com/en-us/HT204899
  [2]: https://developer.apple.com/videos/play/wwdc2015-706/
  [3]: https://apple.stackexchange.com/questions/208478/how-do-i-disable-system-integrity-protection-sip-aka-rootless-on-os-x-10-11


message:
How to wire an LMD18200 and an arduino?

Ive been working with a motor project for a while and i bought this H-bridge(LMD18200). I dont understand how im supposed to connect it to the arduino.

Here is the datasheet for the lmd18200:

![the datasheet](https://imagizer.imageshack.us/v2/484x397q90/924/KkI1QB.png)

body:
Most basic way would be to use only DIR, PWM and Break.

Use Break as enable (put high at begining of the program, put low when you want to start rotation).

Use Dir to change rotation of the motor (usually high is CV, low is CCV, but you need to check the datasheet)

And hook up PWM to [PWM][1] pin on arduino. This will control the speed.

  [1]: https://www.arduino.cc/en/Tutorial/PWM


message:
RC drag strip finish line with mph calculation (using 1" spaced lasers)

My question is: how do I read multiple inputs at the same time without using interrupts on an UNO.  I'm building an RC drag strip with tree and finish line that will calculate run time as well as calculate each run in mph.  I'm using lasers and non modulated laser detectors for the beams and I'm using a 1" beam gap(between 1st beam and 2nd beam) at the finish line(for mph calculation). My concern comes in when two cars come close enough at the finish line for one to break the first beam at set the win flag but the car in the other lane is close enough to cross the 1st beam before the 1st car actually crosses the 2nd beam then the detection loop is going to miss one of them. (just a note: a few of these cars can top 100 mph when crossing the line)

body:
One option, if you want very-real-time processing, for a task like this that break neatly into chunks: Have one Arduino per vehicle.

Arduinos are cheap. If they are too expensive, use AtTiny's - they can be had for about a dollar a piece (depending on your currency). You can share a clock/power between a large number of them.

You can either have a "master" Arduino talk to each individual one, to collect the information, or have daisy-chained bus - each one can pass it's data to the next one in the chain (once is has the data, and the next one in the chain indicates it's ready for it).


body:
**ONE:**

What you can do is use a while loop waiting for the first pulse and then wait until the last pulse, for an idea look at [this code from ][1]Gadjet, he made a [chronograph][2] with a similar operation, you would just need to adapt the design, this might not be as accurate for an 1". Also it will be the issue of having ties between cars. This is short as I don't like this option.

**TWO:**

Another option, although using what you don't want to use, would be using the interrupts on the Arduino. *I am basing the following on the fact that you are using two cars.*

What you can do is have a `finish line` for *both vehicles* and detect a break with a interrupt, one interrupt pin per lane(UNO has to interrupts).

The trick here is that you place both the outputs from one lane onto a single interrupt pin with a edge detector type of [circuit][3]1 to generate a pulse while the vehicle crosses a point, especially important as it will be in the inch area for a while. The code handles the double pulse on one pin. I know this works as I used this on a ballistic chronograph which works in microseconds detecting shots >2000fps over a 0.406 foot distance.

1 This is an example of the circuit you would use at the output of each sensor before the OR gates:
[![enter image description here][6]][6]

The hardware would just become a duplicate for each lane, and to combine the input on one pin you can use an [OR gate IC][4] or you can use diode OR gate:
![from ee.se][5]

Interrupts are actually easy to use with Arduinos, and there are [a lot of examples][7] out there.

Have a look at the below flow chart to get an idea of operation in the code:

[![RSM code][8]][8]

A small thing would be that the code ignores a interrupt once the cars have passed so it doesn't calculate a second time.

  [1]: https://dl.dropboxusercontent.com/u/2253850/Chronograph_7_Seg_on_Nano.ino
  [2]: http://gadjetsblog.blogspot.co.za/2013/02/air-rifle-chronograph.html
  [3]: https://electronics.stackexchange.com/questions/158015/how-to-turn-continuous-signal-into-a-short-pulse-using-logic-gates
  [4]:http://www.digikey.com/product-search/en/integrated-circuits-ics/logic-gates-and-inverters/2556317
  [5]:https://i.stack.imgur.com/ntAAj.gif
  [6]: https://i.stack.imgur.com/eXQMP.png
  [7]: https://www.google.com/search?q=arduino interrupts&spell=1&sa=X&ved=0ahUKEwjg9LD2m9vKAhXFRhQKHTY7A1oQvwUIGigA
  [8]: https://i.stack.imgur.com/88Q1C.png


body:
Building upon Nick Gammon's excellent answer at https://arduino.stackexchange.com/questions/1784/how-many-interrupt-pins-can-an-uno-handle/12958#12958 here's some untested code:

     const int events = 256; // events to store
     unsigned volatile int index;
     byte pinStates[events];
     unsigned int times[events];

     ISR (PCINT1_vect) //  Watch for pin changes on the C port (Uno pins A0-A5)
     {
       if (index == 0) { // start clock
        TCCR1B = bit(CS12) | bit (CS10) ;    // clock/1024 for <4.19s x 64us
        //TCCR1B = bit(CS12);                // clock/256  for <1.05s x 16us
        //TCCR1B = bit(CS11) | bit (CS10) ;  // clock/64   for <0.25s x 4us
        //TCCR1B = bit(CS11) ;               // clock/8    for <0.03s x 0.5us
        //TCCR1B = bit(CS10) ;               // clock/1    for <0.004s x 62ns
       }
       times[index] = TCNT1;
       pinStates[index] = PORTC;
       index = (index+1) & 0xff; // increment and protect from overflow

     }  // end of PCINT1_vect

    void setup ()
      {
      // activate pin change interrupts on port C / pins A0-A5

      PCICR   =  bit (PCIE1);    // enable PCINT[14:8] pin triggers
      PCMSK1 |=  bit (PCINT8) |
                 bit (PCINT9) |
                 bit (PCINT10) |
                 bit (PCINT11) |
                 bit (PCINT12) |
                 bit (PCINT13);     // enable individual pins

      // stop and clear 16 bit timer  CS1[0-2]=0; TCNT1 = 0;
      TCCR1A = 0;  // no comparisons, normal WGM mode, stop the counting
      TCCR1B = 0;
      TCNT1  = 0;  // Clear the counter

      pinMode (A0, INPUT_PULLUP);
      pinMode (A1, INPUT_PULLUP);
      pinMode (A2, INPUT_PULLUP);
      pinMode (A3, INPUT_PULLUP);
      pinMode (A4, INPUT_PULLUP);
      pinMode (A5, INPUT_PULLUP);

      index = 0 ; // nothing happened yet

      pinMode (5, OUTPUT);
      }  // end of setup

    void loop ()
      {

       // check index, parse and report times, check for arming, etc...

      }

The point is to use the pin change interrupt to record state changes on the pins and the times.   The clock/1024 prescaler would give a 1/16MhZ*1024*65536= 4.19s window at 64us resolution timing counts, but you could go to higher resolution with a tighter window by using a smaller prescaler.

Also, if you wanted longer timing windows, you could cascade timer1 into timer0 (messing up millis(), etc.,) and get 24 bits of range before overflow, but a better way than cascading timers might be to add another interrupt to increment a variable.  For much longer timing windows add another quick interrupt to handle for timer1 overflow.

    ...
    volatile unsigned long int t1Cycles,times[events];
    ...

    ISR(TIMER1_OVF_vect){t1Cycles++;}

    void setup(){
        ...
        TIMSK1 = bit(TOIE1);
        t1Cycles = 0;
        ...
    }

    ISR (PCINT1_vect)
    {
        ...
        times[index] = t1Cycles << 16 | TCNT1; // store 32 bit count of clocks
        ...
    }

This is still untested, but it looks like it could be capable of 268 seconds worth of 62ns resolution multichannel timing.  With the longer period, you could move the conditional clock-starting code out of the pin-change ISR.


message:
How do I use Sound Sensor LM393 + Speaker in Arduino

I have this voice sensor:

[![http://s3.amazonaws.com/img.iluria.com/product/22C645/5241CF/450xN.jpg][1]][1]

I need to know how bytes pass through soundsensor into arduino and get this bytes and put out in a speaker.

I read on the net a Lib PCM thats converts chars in voices, but how do I extract bytes from sound sensor in analog-in?

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

body:
Oh, the joys of buying something off the Internet with no datasheet, no part number and no clue how to use it. And then expecting somebody else to tell you how it works.

That module looks like a KY-038, made by Keyes. No guarantees, though, because I'm not telepathic.

Bytes don't "pass through the soundsensor". Bytes don't pass anywhere, in fact. That board has an analogue output, `A0`, which is the amplified audio sensed by the microphone. It swings between 0 and 5 volts, and is 2.5V when no sound is being picked up. The board also has a digital output, `D0`, which is **active-low** when the intensity of the sound picked up by the microphone exceeds a thershold. I have no idea what this threshold is or what volume it represents, or if it can be changed.

Have a look at the pages on [AnalogRead()](https://www.arduino.cc/en/Reference/AnalogRead) for information on how to convert analogue audio to a digital signal.

I don't know what you mean by "a Lib PCM thats converts chars in voices" - 'chars' as in the C-type `chars` or do you mean literal 'characters from a voice', i.e. speech recognition? I cannot tell if you have misunderstood something or there's an unfortunate translation coincidence which is confusing matters.


body:
This post was awhile ago, but I wanted to offer some more definitive info for others like myself who were trying to identify it. What you have there is the Keyes KY-037 "high-sensitivity voice sensor" module. Mine came with the Inland Arduino Uno RFID Learning Kit.

Apparently the KY-037 and the KY-038 are the same except the KY-037 has a higher sensitivity microphone. I could not find any specs to quantify what that sensitivity difference is, however. Both have a LM393 voltage comparator on the board. The same Arduino code ought to work for both.

Here are a few helpful links I found, some also showing a bunch of the other Keyes modules and how to use them:

http://linksprite.com/wiki/index.php5?title=Advanced_Sensors_Kit_for_Arduino

http://brd4.braude.ac.il/~ksamuel/ElIn.31361/Lectures/022-Basic Definitions and Concepts Sensors and Actiators 2013-10-10.pdf  (Page/slide 40)

http://tkkrlab.nl/wiki/Arduino_37_sensors


message:
Serial monitor disconnecting itself

Problem: can't print to the serial monitor, it appears that the serial monitor disconnects itself after uploading a program.

I'm brand new to arduino, and I'm trying to upload a basic program to print to the serial monitor.

I use an arduino uno and my OS is Ubuntu.
I am connecting the arduino to my PC via USB.
Using Arduino Studio Release 0.0.5 experimental build 0.0.5-16058

(I am able to communicate via the digital output pins, tested by making a simple circuit to make the led light blink)

Here is the program:

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

    void loop()
    {
        Serial.print("test");
        delay(500);
    }

Here is the result of the build, look at the last line and it says the serial monitor was disconnected? Why would this happen automatically?

    [2/2/2016 8:51:26 PM] - Start Building
    [2/2/2016 8:51:26 PM] - CPP File Created [/tmp/build1454471486915/test.cpp]
    [2/2/2016 8:51:26 PM] - test.cpp compiled
    [2/2/2016 8:51:26 PM] - CDC.cpp compiled
    [2/2/2016 8:51:27 PM] - HID.cpp compiled
    [2/2/2016 8:51:27 PM] - HardwareSerial.cpp compiled
    [2/2/2016 8:51:27 PM] - HardwareSerial0.cpp compiled
    [2/2/2016 8:51:27 PM] - HardwareSerial1.cpp compiled
    [2/2/2016 8:51:27 PM] - HardwareSerial2.cpp compiled
    [2/2/2016 8:51:27 PM] - HardwareSerial3.cpp compiled
    [2/2/2016 8:51:27 PM] - IPAddress.cpp compiled
    [2/2/2016 8:51:27 PM] - Print.cpp compiled
    [2/2/2016 8:51:27 PM] - Stream.cpp compiled
    [2/2/2016 8:51:27 PM] - Tone.cpp compiled
    [2/2/2016 8:51:27 PM] - USBCore.cpp compiled
    [2/2/2016 8:51:27 PM] - WInterrupts.c compiled
    [2/2/2016 8:51:27 PM] - WMath.cpp compiled
    [2/2/2016 8:51:27 PM] - WString.cpp compiled
    [2/2/2016 8:51:27 PM] - abi.cpp compiled
    [2/2/2016 8:51:27 PM] - hooks.c compiled
    [2/2/2016 8:51:27 PM] - main.cpp compiled
    [2/2/2016 8:51:27 PM] - new.cpp compiled
    [2/2/2016 8:51:28 PM] - wiring.c compiled
    [2/2/2016 8:51:28 PM] - wiring_analog.c compiled
    [2/2/2016 8:51:28 PM] - wiring_digital.c compiled
    [2/2/2016 8:51:28 PM] - wiring_pulse.c compiled
    [2/2/2016 8:51:28 PM] - wiring_shift.c compiled
    [2/2/2016 8:51:28 PM] - CDC.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - HID.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - HardwareSerial.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - HardwareSerial0.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - HardwareSerial1.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - HardwareSerial2.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - HardwareSerial3.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - IPAddress.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - Print.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - Stream.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - Tone.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - USBCore.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - WInterrupts.c.o linked to core.a
    [2/2/2016 8:51:28 PM] - WMath.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - WString.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - abi.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - hooks.c.o linked to core.a
    [2/2/2016 8:51:28 PM] - main.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - new.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - test.cpp.o linked to core.a
    [2/2/2016 8:51:28 PM] - test.ino linked to core.a
    [2/2/2016 8:51:28 PM] - wiring.c.o linked to core.a
    [2/2/2016 8:51:28 PM] - wiring_analog.c.o linked to core.a
    [2/2/2016 8:51:28 PM] - wiring_digital.c.o linked to core.a
    [2/2/2016 8:51:28 PM] - wiring_pulse.c.o linked to core.a
    [2/2/2016 8:51:28 PM] - wiring_shift.c.o linked to core.a
    [2/2/2016 8:51:28 PM] - test.cpp.elf linked to core.a
    [2/2/2016 8:51:28 PM] - test EEPROM
    [2/2/2016 8:51:28 PM] - test.hex builded
    [2/2/2016 8:51:28 PM] - Uploading...
    [2/2/2016 8:51:30 PM] - Uploaded
    [2/2/2016 8:51:30 PM] - [arduino ide - serial monitor] Serial monitor connected to /dev/ttyACM0
    [2/2/2016 8:51:36 PM] - [arduino ide - serial monitor] Serial monitor disconnected from /dev/ttyACM0

body: I'm not sure why your IDE is doing that, but the official Arduino IDE from [Arduino.cc](http://arduino.cc/) works on Ubuntu and does not have that issue. Download from [Arduino Software download page](https://www.arduino.cc/en/Main/Software).


message:
Can I connect an Arduino wifi module directly to my android phone?

I would like to use my arduino even where there's no wifi router. I've only found people saying that it needs to connect to a router, but isn't the phone like a router when it's in tethering mode? Do I still need a mobile internet connection or can I do it directly?

body:
A phone running in wifi tethering (mobile hotspot) mode is no different to a wifi access point or router. So yes, you can use that.

Chances are though that you will need a mobile internet connection in order to activate mobile hotspot mode in the first place.


body:
If you are using the Arduino UNO WiFi Board (http://www.arduino.org/products/boards/arduino-uno-wifi) with the built in ESP8266 chip then your phone can connect directly to the Arduino's network and you can interact with it that way.

With the default firmware, this board can simultaneously connect to a local WiFi network, and create its on access point. This is very handy because it means that you can connect and access its hosted web pages even without a WiFi router with no extra setup steps, or special configuration.


message:
OLED display wrong (using SPI )

I can't figure out where I doing wrong

https://www.youtube.com/watch?v=35NqOANmgUE

This is my question in videos

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

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

The both of two connect the same pin

(so the right display result is the correct  OLED)

My connecting table  (using SPI )

   GND              gnd

   VCC              5V

   D0(OLED_CLK)     10

   D(OLED_MOSI)     9

   RES(OLED_RESET)  13

   D/C(OLED_DC)     11

   CS（OLED_CS）    12

but the left OLED doesn't have the "RES" pin
(so I didn't connect it)

the left OLED just display the upper part
(and its the position of display picture is also wired ,too)

 this is my code

    /*********************************************************************
    This is an example for our Monochrome OLEDs based on SSD1306 drivers
    This example is for a 128x64 size display using SPI to communicate
    4 or 5 pins are required to interface

    Adafruit invests time and resources providing this open source code,
    please support Adafruit and open-source hardware by purchasing
    products from Adafruit!

    Written by Limor Fried/Ladyada  for Adafruit Industries.
    BSD license, check license.txt for more information
    All text above, and the splash screen must be included in any redistribution
    *********************************************************************/

    #include <SPI.h>
    #include <Wire.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>

    // If using software SPI (the default case):
    #define OLED_MOSI   9
    #define OLED_CLK   10
    #define OLED_DC    11
    #define OLED_CS    12
    #define OLED_RESET 13
    Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

    /* Uncomment this block to use hardware SPI
    #define OLED_DC     6
    #define OLED_CS     7
    #define OLED_RESET  8
    Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);
    */

    #define NUMFLAKES 10
    #define XPOS 0
    #define YPOS 1
    #define DELTAY 2

    #define LOGO16_GLCD_HEIGHT 16
    #define LOGO16_GLCD_WIDTH  16
    static const unsigned char PROGMEM logo16_glcd_bmp[] =
    { B00000000, B11000000,
      B00000001, B11000000,
      B00000001, B11000000,
      B00000011, B11100000,
      B11110011, B11100000,
      B11111110, B11111000,
      B01111110, B11111111,
      B00110011, B10011111,
      B00011111, B11111100,
      B00001101, B01110000,
      B00011011, B10100000,
      B00111111, B11100000,
      B00111111, B11110000,
      B01111100, B11110000,
      B01110000, B01110000,
      B00000000, B00110000 };

    #if (SSD1306_LCDHEIGHT != 64)
    #error("Height incorrect, please fix Adafruit_SSD1306.h!");
    #endif

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

      // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
      display.begin(SSD1306_SWITCHCAPVCC);
      // init done

      // Show image buffer on the display hardware.
      // Since the buffer is intialized with an Adafruit splashscreen
      // internally, this will display the splashscreen.
      display.display();
      delay(2000);

      // Clear the buffer.
      display.clearDisplay();

      // draw a single pixel
      display.drawPixel(10, 10, WHITE);
      // Show the display buffer on the hardware.
      // NOTE: You _must_ call display after making any drawing commands
      // to make them visible on the display hardware!
      display.display();
      delay(2000);
      display.clearDisplay();

      // draw many lines
      testdrawline();
      display.display();
      delay(2000);
      display.clearDisplay();

      // draw rectangles
      testdrawrect();
      display.display();
      delay(2000);
      display.clearDisplay();

      // draw multiple rectangles
      testfillrect();
      display.display();
      delay(2000);
      display.clearDisplay();

      // draw mulitple circles
      testdrawcircle();
      display.display();
      delay(2000);
      display.clearDisplay();

      // draw a white circle, 10 pixel radius
      display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
      display.display();
      delay(2000);
      display.clearDisplay();

      testdrawroundrect();
      delay(2000);
      display.clearDisplay();

      testfillroundrect();
      delay(2000);
      display.clearDisplay();

      testdrawtriangle();
      delay(2000);
      display.clearDisplay();

      testfilltriangle();
      delay(2000);
      display.clearDisplay();

      // draw the first ~12 characters in the font
      testdrawchar();
      display.display();
      delay(2000);
      display.clearDisplay();

      // draw scrolling text
      testscrolltext();
      delay(2000);
      display.clearDisplay();

      // text display tests
      display.setTextSize(1);
      display.setTextColor(WHITE);
      display.setCursor(0,0);
      display.println("Hello, world!");
      display.setTextColor(BLACK, WHITE); // 'inverted' text
      display.println(3.141592);
      display.setTextSize(2);
      display.setTextColor(WHITE);
      display.print("0x"); display.println(0xDEADBEEF, HEX);
      display.display();
      delay(2000);

      // miniature bitmap display
      display.clearDisplay();
      display.drawBitmap(30, 16,  logo16_glcd_bmp, 16, 16, 1);
      display.display();

      // invert the display
      display.invertDisplay(true);
      delay(1000);
      display.invertDisplay(false);
      delay(1000);

      // draw a bitmap icon and 'animate' movement
      testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
    }

    void loop() {

    }

    void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
      uint8_t icons[NUMFLAKES][3];

      // initialize
      for (uint8_t f=0; f< NUMFLAKES; f++) {
        icons[f][XPOS] = random(display.width());
        icons[f][YPOS] = 0;
        icons[f][DELTAY] = random(5) + 1;

        Serial.print("x: ");
        Serial.print(icons[f][XPOS], DEC);
        Serial.print(" y: ");
        Serial.print(icons[f][YPOS], DEC);
        Serial.print(" dy: ");
        Serial.println(icons[f][DELTAY], DEC);
      }

      while (1) {
        // draw each icon
        for (uint8_t f=0; f< NUMFLAKES; f++) {
          display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE);
        }
        display.display();
        delay(200);

        // then erase it + move it
        for (uint8_t f=0; f< NUMFLAKES; f++) {
          display.drawBitmap(icons[f][XPOS], icons[f][YPOS],  logo16_glcd_bmp, w, h, BLACK);
          // move it
          icons[f][YPOS] += icons[f][DELTAY];
          // if its gone, reinit
          if (icons[f][YPOS] > display.height()) {
     icons[f][XPOS] = random(display.width());
     icons[f][YPOS] = 0;
     icons[f][DELTAY] = random(5) + 1;
          }
        }
       }
    }

    void testdrawchar(void) {
      display.setTextSize(1);
      display.setTextColor(WHITE);
      display.setCursor(0,0);

      for (uint8_t i=0; i < 168; i++) {
        if (i == '\n') continue;
        display.write(i);
        if ((i > 0) && (i % 21 == 0))
          display.println();
      }
      display.display();
    }

    void testdrawcircle(void) {
      for (int16_t i=0; i<display.height(); i+=2) {
        display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
        display.display();
      }
    }

    void testfillrect(void) {
      uint8_t color = 1;
      for (int16_t i=0; i<display.height()/2; i+=3) {
        // alternate colors
        display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
        display.display();
        color++;
      }
    }

    void testdrawtriangle(void) {
      for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) {
        display.drawTriangle(display.width()/2, display.height()/2-i,
                         display.width()/2-i, display.height()/2+i,
                         display.width()/2+i, display.height()/2+i, WHITE);
        display.display();
      }
    }

    void testfilltriangle(void) {
      uint8_t color = WHITE;
      for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) {
        display.fillTriangle(display.width()/2, display.height()/2-i,
                         display.width()/2-i, display.height()/2+i,
                         display.width()/2+i, display.height()/2+i, WHITE);
        if (color == WHITE) color = BLACK;
        else color = WHITE;
        display.display();
      }
    }

    void testdrawroundrect(void) {
      for (int16_t i=0; i<display.height()/2-2; i+=2) {
        display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, WHITE);
        display.display();
      }
    }

    void testfillroundrect(void) {
      uint8_t color = WHITE;
      for (int16_t i=0; i<display.height()/2-2; i+=2) {
        display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);
        if (color == WHITE) color = BLACK;
        else color = WHITE;
        display.display();
      }
    }

    void testdrawrect(void) {
      for (int16_t i=0; i<display.height()/2; i+=2) {
        display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
        display.display();
      }
    }

    void testdrawline() {
      for (int16_t i=0; i<display.width(); i+=4) {
        display.drawLine(0, 0, i, display.height()-1, WHITE);
        display.display();
      }
      for (int16_t i=0; i<display.height(); i+=4) {
        display.drawLine(0, 0, display.width()-1, i, WHITE);
        display.display();
      }
      delay(250);

      display.clearDisplay();
      for (int16_t i=0; i<display.width(); i+=4) {
        display.drawLine(0, display.height()-1, i, 0, WHITE);
        display.display();
      }
      for (int16_t i=display.height()-1; i>=0; i-=4) {
        display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
        display.display();
      }
      delay(250);

      display.clearDisplay();
      for (int16_t i=display.width()-1; i>=0; i-=4) {
        display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
        display.display();
      }
      for (int16_t i=display.height()-1; i>=0; i-=4) {
        display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
        display.display();
      }
      delay(250);

      display.clearDisplay();
      for (int16_t i=0; i<display.height(); i+=4) {
        display.drawLine(display.width()-1, 0, 0, i, WHITE);
        display.display();
      }
      for (int16_t i=0; i<display.width(); i+=4) {
        display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
        display.display();
      }
      delay(250);
    }

    void testscrolltext(void) {
      display.setTextSize(2);
      display.setTextColor(WHITE);
      display.setCursor(10,0);
      display.clearDisplay();
      display.println("scroll");
      display.display();

      display.startscrollright(0x00, 0x0F);
      delay(2000);
      display.stopscroll();
      delay(1000);
      display.startscrollleft(0x00, 0x0F);
      delay(2000);
      display.stopscroll();
      delay(1000);
      display.startscrolldiagright(0x00, 0x07);
      delay(2000);
      display.startscrolldiagleft(0x00, 0x07);
      delay(2000);
      display.stopscroll();
    }

body:
Check the connections with that required by the software/library. If you intend to use SPI the pins on Arduino Uno are:

    SS   10
    MOSI 11
    MISO 12
    SCK  13

You connections above are:

    VCC             => 5V
    D0(OLED_CLK)    => 10 (SPI SS ??)
    D(OLED_MOSI)    => 9
    RES(OLED_RESET) => 13 (SPI SCK ??)
    D/C(OLED_DC)    => 11 (SPI MOSI ??)
    CS（OLED_CS）     => 12 (SPI MISO ??)
    GND             => GND (??)

That is not correct for SPI. Post link to library, oled hardware, and snippet of your code for more help.

It is more than the video that is out of focus :)

Cheers!


message:
Is a power off sufficient to avoid problems with the Watchdog on Arduino Mega 2560?

I'd like to offer some context about what I'd like to do because I might have misundertood something.

I'm trying to reduce power consumption on my device, an Arduino Mega 2560, and I've found this library

https://github.com/rocketscream/Low-Power

which uses the Watchdog to put Arduino on power saving for a predetermined interval of time; after that it reactivates what has been disabled and let the program continue its flow.

I searched for more information about the Watchdog and I found out several warnings about dealing with Watchdog on an Arduino Mega 2560, stating that it would only work with a modified bootloader:
This scared me a bit because I'm not very keen on risking to brick my Arduino (I absolutely need it to work on the next few days).

Now, I only have two Arduino Mega 2560 at my disposal and if I'm not mistaken, flashing the bootloader on an Arduino Mega 2560 using another Arduino Mega 2560 as a programmer can't be done because the procedure ends with errors:

( see http://forum.arduino.cc/index.php?topic=126160.0 )

Hence my most important question: if I test the watchdog functionality on my code (the sketch) and the Arduino happens to continually reset, can I fix the situation by powering off the Arduino?

(if you can help with my other issues as well, I'd be very grateful, I'm not sure I completely understood how these things work)

body:
The problem you have is that once the watchdog is turned on it is very hard to turn it off again. There are certain procedures you have to go through to ensure it's turned off.

The default bootloader doesn't turn the bootloader off, and a reset doesn't turn it off either. The watchdog then fires whilst the bootloader is still waiting for communication from the PC thus making it reboot before your sketch has had a chance to run. Hence the change needed in the bootooader.

The only way to clear the watchdog is to remove the power. However as soon as your sketch runs and turns the watchdog back on you are then back at square one.

So you need to upload a new sketch to stop that happening, but that is tricky, since the watchdog keeps resetting and interrupting the bootloader. So what do you do? Well, there's a specific sequence you need to do.

1. Unplug the mega
2. Compile the new sketch
3. Hold the reset button on the mega
4. Plug in the mega
5. Press upload
6. As soon as avrdude starts release the reset button.

That way you have a chance of the bootloader running without your sketch having run first and enabled the watchdog. The bootloader runs just the once when the computer is tryung to upload the sketch, and with luck that will happen instead of your sketch running.


message:
Sublime Text 2 with stino, compilation gives "filename ... is incorrect" Arduino IDE 1.7.8

I can't compile a simple blink sketch.

Error is:

    [Stino - Start building "t5"...]
    [  3%] Creating C:\Users\lov\AppData\Local\Temp\Stino_build\t5\t5.ino.cpp.o...
    The filename, directory name, or volume label syntax is incorrect.

See also [see similar question, that answer not working here][1].

Path to IDE app is `C:\Program Files (x86)\added\Arduino`.

  [1]: https://arduino.stackexchange.com/questions/18601/sublime-text-compilation-issue

body:
Sorry but this is too big for a comment.

Firstly please can you check the obvious, in Windows Explorer paste the path C:\Users\lov\AppData\Local\Temp\Stino_build\t5 into the address bar and does the directory exist. (I have fallen for that so many times)

Secondly do you have permission to create a file there?

Have you updated the IDE? Does blink compile?

Have you tried running the IDE as admin?

Hopefully one of those will fix it.


message:
How to copy files from Yun to local computer?

I would like to copy a file that is in the root folder of my Yun, to my Macbook. They are connected with an ethernet cable and I am logged into the Yun through ssh.
The Yun's IP is 192.168.2.16 while the Mac's is 192.168.2.1.

How can I copy a file from the Yun?

Once I tried to copy a file from the Macbook to the Yun using "scp" and it worked, but now I don't know how to do for the other direction

body:
You simply reverse the arguments.  Whatever you used to copy a file *to* the Yun you just do the opposite to copy *from* the Yun.

For instance, if you copied to the Yun using:

    scp /my/local/file root@192.168.2.16:/where/you/want/it

Then you would change it around to copy from the Yun thus:

    scp root@192.168.2.16:/path/to/file /where/you/want/it/to/go


message:
ESP8266 NodeMCU v3 basic questions

Can somebody please tell me what is the operating voltage of ESP8266?

What is the A0 voltage range?

I am powering it up from USB (5v) and have a sensor that comes back with Analog value, to calculate it correctly I am asked to provide "Logical Voltage" value that is either 3300 or 5000 (3.3v or 5v). Sensor is connected to 3.3V port as there is no 5v port on the board.

What do I choose here 3300 or 5000 for NodeMCU V3?

Thank you.

body:
The subtle clue is in the voltage that is available. That is, the only voltage provided on the board is 3.3v. That's a slight hint that the board might run at 3.3v. And you would be right in that assumption.

The ESP8266 chips, as are most modern MCUs more powerful than 8-bit, 3.3v devices.

So you would choose 3300 as your "Logical Voltage" value.  Or better still, measure the 3.3V and find exactly what it is and use that value x 1000 (for example 3317 or 3295).


message:
How to use ITG-3500 evb

[![Picture of the boards][1]][1]

I am trying to make motion capture and someone gave me these boards.

I think it's a test board for MPU 9500. I tried to google but I only found datasheets. What boards are these?

"ITG-3500 evb" is written on the back of the green board.
I think this is <datasheet>[datasheet](http://store.invensense.com/datasheets/invensense/AN-IVS-0001EVB-00-v1-2.pdf) of green board maybe

"EV_ARM_XXAXA_D" is written on the back of the blue board.

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

body:
The green board is an ITG-3500 (3 axis gyroscope) evaluation board of some form.

The blue board is some form of microcontroller evaluation board. It probably has one of the Atmel SAM chips on it since it mentions ARM.

That's about all you'll get from us I'm afraid, unless there is the highly unlikely situation that someone here happens to have the exact same boards as you.


body:
I have had to, briefly, play with these boards a while back, and although I used different revisions and versions of the boards, they are probably the same functionally. Unfortunately, I don't have any of my old notes as I have moved country. Regardless...

As Majenko says in his [answer][1] the green board is an evaluation board for the ITG-3500 3-axis gyroscope, which is presumably the SMD chip (in a QFN format) mounted on it, in the lower part of the board (looking at your photo). A [data sheet on the *similar* ITG-3200][2] (note *not* the evaluation board itself)  can be found on SparkFun. To quote part of the product description:

> The ITG-3200 is the world’s first single-chip, digital-output, 3-axis
> MEMS gyro IC optimized for gaming, 3D mice, and 3D remote control
> applications. The part features enhanced bias and sensitivity
> temperature stability, reducing the need for user calibration. Low
> frequency noise is lower than previous generation devices, simplifying
> application development and making for more-responsive remote
> controls.
>
>The ITG-3200 features three 16-bit analog-to-digital
> converters (ADCs) for digitizing the gyro outputs, a user-selectable
> internal low-pass filter bandwidth, and a Fast-Mode I2C (400kHz)
> interface. Additional features include an embedded temperature sensor
> and a 2% accurate internal oscillator. This breakthrough in gyroscope
> technology provides a dramatic 67% package size reduction, delivers a
> 50% power reduction, and has inherent cost advantages compared to
> competing multi-chip gyro solutions.

In addition, in case it is of any use, here is the [datasheet for the, again similar, ITG-3701][3], which I located on the [Digi sales site][4]. Frustratingly, I am unable to locate a datasheet for the ITG-3500 - however, you mentioned that you found some datasheets - could you edit your answer to include the links, please?

The Blue board is a "Gyroscope Evaluation Board: EV_INV-ARM" manufactured by InvenSense Inc., and to quote its [product description][5]:

>The InvenSense ARM reference board provides a bridge function between InvenSense evaluation boards and a PC. It connects to a PC via USB and to InvenSense evaluation boards via SPI or I2C. The ARM processor on the reference board is not meant to be reprogrammed by the user. It contains all code necessary to be used in conjunction InvenSense evaluation boards. (Note that separate demonstration software may accompany the individual evaluation boards with which this device connects.)

Here is a link to the [EV_INV-ARM DataSheet][6]. The Atmel chip on it is possibly the AT91SAM7SE512 MCU, and here is a link to its [product specification][7].

Software wise, you may find this [Linux kernel driver for the ITG-3500][8] extremely useful.

----

### TL;DR

It seems like you need to get hold of the separate demonstration software for the ITG-3500 evaluation board, according to the EV-INV_ARM's product description, in order to *easily* make it do something.

  [1]: https://arduino.stackexchange.com/questions/20286/how-to-use-itg-3500-evb#answer-20287
  [2]: https://www.sparkfun.com/datasheets/Sensors/Gyro/PS-ITG-3200-00-01.4.pdf
  [3]: http://store.invensense.com/datasheets/invensense/PS-ITG-3701.pdf
  [4]: http://www.digikey.com/product-detail/en/ITG-3701/1428-1050-1-ND/5015524
  [5]: http://store.invensense.com/ProductDetail/EVINVARMG-InvenSense-Inc/425140/
  [6]: http://store.invensense.com/datasheets/invensense/AN-000039 v1.0.pdf
  [7]: http://www.atmel.com/devices/SAM7SE512.aspx
  [8]: https://android.googlesource.com/kernel/tegra.git/+/eb72d0308d4f46ff106f7097a3c040cfda83733d/drivers/staging/iio/imu/inv_mpu/README


message:
Can I power a 9g servo from an arduino nano with USB power only?

I want to run a 9g servo off of the pins from an arduino nano board, using only the 5v USB connection.

The servo specifically is a SG90, which I have measured a stall current of ~250mA - I don't intend to stall it, just have it run with almost no load

I am not sure which pins to power it off of from the arduino itself - do I use the VCC or the +5v? does it matter which ground I use? should I use a breadboard to help me place any other components that may be needed, i.e. a capacitor or something? does the arduino nano negotiate to get more than the default of 100mA from a USB power connection?

body:
<strike>The max current of the Arduino-Nano 5V Pin is 200mA. So if you draw more than that it might damage your Arduino.</strike>

Here is an interesting summary regarding the Maximum Ratings of the Arduino Nano: https://electronics.stackexchange.com/questions/67092/how-much-current-can-i-draw-from-the-arduinos-pins

> The 5V pin of the arduino is not connected through the
> microcontroller. As such, it can source significantly more power. When
> you are powering your arduino from USB, the USB interface limits your
> total power consumption to 500 mA.

So yes, it actually seems you can draw 250mA out of the 5V PIN.

> do I use the VCC or the +5v?

You use +5V, because VCC is for powering your Arduino with an external Power Source. It allows you to use up to 7-12V (recommended), or up to 6-20V (limits).

> does it matter which ground I use?

Doesn't matter

> should I use a breadboard to help me place any other components that may be needed, i.e. a capacitor or something?

A breadboard makes it easier for you, to test your circuit. But you can do it without if you like. Then you possibly have to solder some connections

See also the [offical Arduino Page][1] for the Nano.

  [1]: https://www.arduino.cc/en/Main/ArduinoBoardNano


message:
CLion + Arduino

Please, help me to set up Clion + Arduino.

Clion has an Arduino plugin which I've installed. Here is some instruction on Github but I'm fully noob about `cmake` and other things which are talking about in instruction. I have only used Arduino IDE before for my simple projects. Now in CLion I can create an Arduino projects but autocompletion doesn't work. Actually it works but does it on true C, not for Arduino code.

So if you can please explain like for complete idiot, what I should change to get working Arduino autocompletion.

body:
Rather than using any plugin, I am using CLion with [PlatformIO][1], which supports several IDEs. CLion then not only gives you code completion, but also full support for refactoring, Git, and much much more.

From [its documentation][2]:

> [...] generate project via `platformio init --ide` command:
>
>     platformio init --ide clion --board %TYPE%
>
>     # For example, generate project for Arduino UNO
>     platformio init --ide clion --board uno

Then import the project in CLion and you're about done.

Some hints:

- Make sure your code is in the `src` folder, and that the main file has a `.cpp` extension.

- For other files: either rename all `.ino` files to use `.cpp`, or tell CLion to associate the `.ino` extension with C++ files. (Preferences, Editors, File Types.)

- Whenever adding libraries to the `lib` folder (and using `#include` to refer to them), just run the above `init` command again.

- If you're using ESP-boards and changed `platform.txt` for an alternative `esptool`, then note that PlatformIO [needs a different hack][3].

- Rather than using the CLion Serial Monitor plugin, I simply use a Terminal within CLion to upload and start the monitor as soon as possible:

      pio run -t upload; pio device monitor -b 115200

- If you always want to upload and monitor whenever using `pio run`, then add:

      [env]
      targets = upload, monitor
      upload_protocol = esptool
      upload_speed = 115200
      monitor_speed = 115200

- Nowadays, [CLion has a PlatformIO plugin][4] as well, including a menu Tools, PlatformIO with commands such as Re-init.

  [1]: http://platformio.org/
  [2]: https://docs.platformio.org/en/latest/integration/ide/clion.html
  [3]: https://arduino.stackexchange.com/questions/20219/upload-with-esptool-fails-with-espcomm-send-command-cant-receive-slip-payload/20220#20220http://
  [4]: https://plugins.jetbrains.com/plugin/13922-platformio-for-clion


body:
I know this was asked a long time ago, but maybe it will be useful for someone. I'm a beginner, regarding all this stuff, so if anybody knows a better way to do it, please correct me. here is how I set up CLion for Arduino (on Windows 10):

CLion 2016.1.3 + Arduino 1.6.9 + plugin

1. Download and install the official Arduino IDE (1.6.9).

2. Download and install [MinGW][1] to 'C:\MinGW'

3. In MinGW, install: 'mingw32-base' and 'mingw32-gcc-g++'

4. Download and install [CLion][2].

5. Create an 'untitled' project, just to open CLion.

6. In CLion > Settings > Plugins > Browse Repositories > Search for and install: 'Arduino' (tools integration), and 'Serial Monitor' (misc).

7. In CLion > Settings > Search > type 'MinGW'

8. At the environment select 'Use MinGW home', and browse to MinGW folder ('C:\MinGW'). Press apply, and wait until CLion finds the environment.

9. In File > Close project.

10. Open any file manager and go to 'c:\Users\name\ClionProjects\' and delete the 'untitled' project you just created.

11. Open CLion, select 'New Arduino sketch project'

12. In the project directory > 'open cmakelists.txt' and configure lines:

        6: set board version
        7: set port (you can find out port# from the Arduino IDE)
        8: set the path where you installed your Arduino libraries (Arduino sketch folder)

        set(${CMAKE_PROJECT_NAME}_BOARD uno)
        set(${CMAKE_PROJECT_NAME}_PORT COM3)
        LINK_DIRECTORIES(c:\\ARDUINO\\libraries)

13. In the upper right corner in CLion, near the green 'Play' button, select 'Edit Configuration', on the left select 'Application' > 'Upload', and set:

        -target: 'upload'
        -configuration: 'debug'
        -executable: the project name

 then press ok.

14. In the project .ino file, write some really simple code (blink).

15. Connect an Arduino Uno via USB, and press the green 'play' button to upload the sketch.

16. To start serial monitor:

    - In CLion main window bottom left, click serial monitor tab (in 'the tool buttons')
 - Click the wrench icon to set up port and baud rate.
 - On the top of the wrench icon, click the blue 'connect' icon.
 - If values did not appear 'correctly', click the white 'switch to hex' icon (on the right of the wrench).
 - Before uploading sketch, disconnect the serial monitor.

17. For CLion to properly find the libraries, make sure to use the same name for the lib folder as for the '.h' file. example: for DallasTemperature.h use folder name DallasTemperature. After #inlcude-ing new libs, right click on 'External libraries folder' and select 'Reload cmake project'.

18. You may want to do further configuration in CLion settings like: theme, colours, text size, etc.

19. Also, you can configure some handy 'live templates', like: `serialprintln`, `digitalwrite`, `pinmode`, `switch`, etc. to enhance your productivity.

  [1]: https://sourceforge.net/projects/mingw/files/latest/download?source=files
  [2]: https://www.jetbrains.com/clion/download/#section=windows-version


message:
For loop question-Simulating a robot' s movement on a 2d array

i' m trying to simulate a robot' s movement on a 2d array. In my case, robot goes forward firstly, if it sees a engel, it turns left and continues its movement. The problem is that, i could not present turning left and moving on left-direction on the initial matrix.

Here' s my code:

    #include <Servo.h>
    #define x 7                                         //Matrix dimensions
    #define y 7

    const int trigPin = 12;
    const int echoPin = 11;

    Servo myServo;                                     //variable definations
    Servo myServo2;

    int pos = 0;

    int counter;
    int counter1 = 0;
    int counter2;
    int counter3;

    int integer;
    int integer2;
    int integer4;

    long duration;
    long distance;

    void setup() {
     Serial.begin(9600);
     myServo.attach(9);
     myServo2.attach(10);
     pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
     pinMode(echoPin, INPUT); // Sets the echoPin as an Input
    }

    void loop() {
     int my2dArray[x][y] = {                          // initial matrix
      {1, 1, 1, 1, 1, 1, 1},
      {1, 1, 1, 1, 1, 1, 1},
      {1, 1, 1, 1, 1, 1, 1},
      {1, 1, 1, 0, 1, 1, 1},
      {1, 1, 1, 1, 1, 1, 1},
      {1, 1, 1, 1, 1, 1, 1},
      {1, 1, 1, 1, 1, 1, 1},
     };
     // Clears the trigPin
     digitalWrite(trigPin, LOW);
     delayMicroseconds(2);
    // Sets the trigPin on HIGH state for 10 micro seconds
     digitalWrite(trigPin, HIGH);
     delayMicroseconds(10);
     digitalWrite(trigPin, LOW);
    // Reads the echoPin, returns the sound wave travel time in microseconds
     duration = pulseIn(echoPin, HIGH);
    // Calculating the distance
     distance = duration * 0.034 / 2;
     int robot = my2dArray[3][3];                   // first place of robot

     if (counter1 > 0) {
      for (integer = 0;  integer < counter1; integer += 1) {
       if (distance < 10) {                                  //seeing     the object
        for (pos = 0; pos <= 180 ; pos += 1) {              //turning left
         myServo.write(pos);
        }

        for (pos = 0; pos <= 180  ; pos += 1) {            //moving on after turning
         myServo.write(pos);
         myServo2.write(pos);

         if (pos == 180) {
          counter3 +=  1;
         }
        }

        Serial.println(integer);

        for (integer4 = 0;  integer4 < counter3; integer4 += 1) {     //modifying matrix if there is an object
         my2dArray[3 + integer][3 + integer4] = robot * my2dArray[3 + integer][3 + integer4];
        }

        Serial.println("Break condition.");
        break;
       } else {
        my2dArray[3 + integer][3] = robot * my2dArray[3 + integer][3];    //modifying matrix in case of there is no object
       }
      }
     }

     for (integer2 = 0; integer2 < 7; integer2++) {                          //displaying matrix
      Serial.print(my2dArray[integer2][0]);
      Serial.print("|");
      Serial.print(my2dArray[integer2][1]);
      Serial.print("|");
      Serial.print(my2dArray[integer2][2]);
      Serial.print("|");
      Serial.print(my2dArray[integer2][3]);
      Serial.print("|");
      Serial.print(my2dArray[integer2][4]);
      Serial.print("|");
      Serial.print(my2dArray[integer2][5]);
      Serial.print("|");
      Serial.println(my2dArray[integer2][6]);
     }

     Serial.println();

     for (pos = 0; pos <= 180  ; pos += 1) {                               // moving forward as first movement
      myServo.write(pos);
      myServo2.write(pos);

      if (pos == 180) {
       counter1 +=  1;
      }
     }

     delay(1000);
    }

The problem part is:

    for (integer4 = 0;  integer4 < counter3; integer4 += 1){      //modifying matrix if there is an object

        my2dArray[3 + integer][3+integer4] = robot * my2dArray[3 + integer][3+integer4];

         }

"integer" value does not change in the problem part, it' s always 0 in despite of the first for loop. How can i pass the "integer" to the problem part properly?

body:
Your program is hard to follow with all those meaningless "integer" and "counter" variables, and the logic seems a little odd in places, but I believe the cause of your problems is the `break` statement:

    for (integer = 0; integer < counter1; integer += 1) {
        if (distance < 10) {
            // ...
            for (integer4 = 0;  integer4 < counter3; integer4 += 1) {     //modifying matrix if there is an object
                my2dArray[3 + integer][3 + integer4] = robot * my2dArray[3 + integer][3 + integer4];
            }
            break; // << HERE
        } else {
            // ...
        }
    }

What is the purpose of that `break`? I think you are using it to jump out of the `if` so that it doesn't run the `else`, which it *won't run anyway since it's an else condition*. Instead, what the `break` is actually doing is terminating the `for` loop after the first iteration that hits that inner `if` condition. That is, as long as the distance is less than 10 it will only ever run the `for` once, and so `integer` will only ever be 0.


message:
Arduino on breadboard Tension is 4.4V instead of 5 V,looking for some guidance

I build a circuit that work on breadboard now i try to prototype it,so i start solder it on a prototype board and the arduino is out of sync.So i check the tension and for some reason it's 4.4~4.6 on the Vin pin of Atmega328 so i try to find how to debug.I don't have a lot of theorical knowledge on electronic,but my thougt was as long as everything is plug in parrallel the tension should remain the same ( and i don't have any thing in serie) so for the tension to drop i may have something acting as Resistor, and i try to find how and what.
I use 22AWG 0.7mm wire o create a 5V line and my GND line on each side of the Atmega ( roughly 7 cm on each side),i start to wondering if it was not a bad idea. I have picture of my prototype bellow,but it's messy so not sure it help. My question is how to you proceed to troubleshoot this thing ? What are the step you do to find out where is the problem [![Atmega328][1]][1]

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

body:
The yellow-boxed 5V and Gnd buses on the [freetronics.com.au ProtoShield Basic for Arduino](http://www.freetronics.com.au/products/protoshield-basic#.VrLTZt_U2kA) [like you used] already have copper strips connecting the holes.  The strips run on both sides of the board and the holes are plated-through, so there's no need (for this kind of circuit) to have additional bus wire running along above the boxes.  Having that extra wire there gets in the way of making changes, whether for debugging the circuit or for adding or replacing components.

From the [frontside picture](http://s12.postimg.org/99wap5rr1/MG_3581.jpg), it appears you may have a voltage regulator on board.  (However, I don't see the connections to 5V and Gnd, so might be misinterpreting things.)

If your board input is 5 VDC from an external supply, feeding that 5 V into a regulator will lose half a volt or so, which may account for what you are seeing.

However, let's instead suppose you are putting 7 to 12 VDC into an on-board 5V regulator and then measuring 4.4-4.6 V out.  One possibility is the regulator isn't working.  This can happen if the regulator's input or output capacitors are the wrong sizes or wrong kinds, and cause oscillation.  Diagnosing that kind of problem is straightforward if you look at the 5V line with an oscilloscope.  Another possibility is something drawing a *lot* of current (eg a couple of amps) and taking the 5V line out of regulation.  That's usually easy to diagnose because of all the resulting smoke and heat.

Drawing a good schematic is an excellent step to take to allow better problem debugging.

Other steps to take:

* Measure the amount of current the whole board is drawing, or that the NRF24L01 is drawing.  (For the latter measurement, you might need to lift your ground lead off the NRF24L01 board and put the ammeter into the ground circuit.  In general you want all the grounds to be at the same voltage, so the voltage drop across the ammeter is a problem, but not much of one.)

* Pull the '328P chip and see if that makes any difference.  In general, it's a good idea to work out a prototype board's power supply problems – such as shorts, reversed electrolytics, incorrect resistors – in advance of installing a microcontroller chip onto the board.

* Remove the NRF24L01, if feasible, while debugging the power supply.  If you can't easily remove it, check your schematic and see if all of its pins except 5V and Gnd are open when the '328P chip is pulled.  If so, you can detach the NRF24L01  ground lead to take it out of the circuit.  If, during testing, you unsolder and remove the NRF24L01 board, consider making a socket for it from two 5-pin female header strips.