Member #520217

Member Since: February 12, 2014

Country: United States

  • I still cannot connect two chips with the simple code there http://www.arduino.cc/playground/InterfacingWithHardware/Nrf2401 I’m wondering whether have wrongly connect the pins. DR1 is digital pin2. But the 3,4,5,6 is digital pin or the analog in pins?

  • Is 3,4,5,6 Analog in or Digital?

  • Hi Jeff, I just got the arduino UNO board and I connect the pins like VDD - Arduino 3.3v GND - Arduino GND INT - Arduino digital pin 2 FSYNC - leave unconnected SCL - Arduino SCL (dedicated pin or Analog 5) SDA - Arduino SDA (dedicated pin or Analog 4) VIO - Arduino 3.3v CLK - leave unconnected ASCL - leave unconnected ASDA - leave unconnected, then I type the c code in arduino SDK:

    include “I2Cdev.h”

    include “MPU6050.h”

    if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE

    #include "Wire.h"
    

    endif

    MPU6050 accelgyro;

    int16_t ax, ay, az; int16_t gx, gy, gz;

    define OUTPUT_READABLE_ACCELGYRO

    define LED_PIN 13

    bool blinkState = false;

    void setup() {

    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
        Wire.begin();
    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
        Fastwire::setup(400, true);
    #endif
    
    Serial.begin(38400);
    
    Serial.println("Initializing I2C devices...");
    accelgyro.initialize();
    
    Serial.println("Testing device connections...");
    Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
    
    // use the code below to change accel/gyro offset values
    /*
    Serial.println("Updating internal sensor offsets...");
    // -76  -2359   1688    0   0   0
    Serial.print(accelgyro.getXAccelOffset()); Serial.print("\t"); // -76
    Serial.print(accelgyro.getYAccelOffset()); Serial.print("\t"); // -2359
    Serial.print(accelgyro.getZAccelOffset()); Serial.print("\t"); // 1688
    Serial.print(accelgyro.getXGyroOffset()); Serial.print("\t"); // 0
    Serial.print(accelgyro.getYGyroOffset()); Serial.print("\t"); // 0
    Serial.print(accelgyro.getZGyroOffset()); Serial.print("\t"); // 0
    Serial.print("\n");
    accelgyro.setXGyroOffset(220);
    accelgyro.setYGyroOffset(76);
    accelgyro.setZGyroOffset(-85);
    Serial.print(accelgyro.getXAccelOffset()); Serial.print("\t"); // -76
    Serial.print(accelgyro.getYAccelOffset()); Serial.print("\t"); // -2359
    Serial.print(accelgyro.getZAccelOffset()); Serial.print("\t"); // 1688
    Serial.print(accelgyro.getXGyroOffset()); Serial.print("\t"); // 0
    Serial.print(accelgyro.getYGyroOffset()); Serial.print("\t"); // 0
    Serial.print(accelgyro.getZGyroOffset()); Serial.print("\t"); // 0
    Serial.print("\n");
    */
    
    // configure Arduino LED for
    pinMode(LED_PIN, OUTPUT);
    

    }

    void loop() { // read raw accel/gyro measurements from device accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

    // these methods (and a few others) are also available
    //accelgyro.getAcceleration(&ax, &ay, &az);
    //accelgyro.getRotation(&gx, &gy, &gz);
    
    #ifdef OUTPUT_READABLE_ACCELGYRO
        // display tab-separated accel/gyro x/y/z values
        Serial.print("a/g:\t");
        Serial.print(ax); Serial.print("\t");
        Serial.print(ay); Serial.print("\t");
        Serial.print(az); Serial.print("\t");
        Serial.print(gx); Serial.print("\t");
        Serial.print(gy); Serial.print("\t");
        Serial.println(gz);
    #endif
    
    #ifdef OUTPUT_BINARY_ACCELGYRO
        Serial.write((uint8_t)(ax >> 8)); Serial.write((uint8_t)(ax & 0xFF));
        Serial.write((uint8_t)(ay >> 8)); Serial.write((uint8_t)(ay & 0xFF));
        Serial.write((uint8_t)(az >> 8)); Serial.write((uint8_t)(az & 0xFF));
        Serial.write((uint8_t)(gx >> 8)); Serial.write((uint8_t)(gx & 0xFF));
        Serial.write((uint8_t)(gy >> 8)); Serial.write((uint8_t)(gy & 0xFF));
        Serial.write((uint8_t)(gz >> 8)); Serial.write((uint8_t)(gz & 0xFF));
    #endif
    
    // blink LED to indicate activity
    blinkState = !blinkState;
    digitalWrite(LED_PIN, blinkState);
    

    } but it says NPU6050 does not name a type and shows all the errors: sketch_feb18a.ino:36:20: error: I2Cdev.h: No such file or directory sketch_feb18a.ino:37:21: error: MPU6050.h: No such file or directory sketch_feb18a:49: error: ‘MPU6050’ does not name a type sketch_feb18a.ino: In function ‘void setup()’: sketch_feb18a:87: error: ‘accelgyro’ was not declared in this scope sketch_feb18a.ino: In function ‘void loop()’: sketch_feb18a:122: error: ‘accelgyro’ was not declared in this scope how can I fix these?

No public wish lists :(