Jump to content
I2Cdevlib Forums

Recommended Posts

Hello everyone!

 

I am pretty inexperienced when it comes to computer programming, but I am using the program Jeff posted to use the yaw, pitch, and roll values (I really only need the yaw, though) in a feedback system for a UAV. I am using an Arduino Uno to run the gyroscope, and the program works fine by itself. My issue results from me putting the program on a timer so that it only reads the value every, say, 100 ms. Then FIFO overflow then gets triggered (which makes sense because the values are going in faster than they go out.) Is there any way to bypass this? I noticed one of the past iterations of the program read the values directly instead of from the FIFO buffer, but I didn't understand that version of the program, and I also don't think it had a "ypr" option. Is there an easy way to change the programming, or perhaps a better way to do it?

 

Thanks for any help you can give!

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

So I did a little more messing around with my program, and I got it to work well. I decided not to use the interrupts because they were actually messing up the rest of my program. However, it does work. The only problem I have is that it runs a little slow. Another part of the program controls an oscillating servomotor and, right now, it won't really run faster that about 1 hz. I believe is just a processing issue because the program is so big. The main part of the issue is that, as I have the program right now, the gyroscope is taking data as fast as possible is the background and I only sample it even 10 ms or so. I guess my question is there any way around that? I feel like the FIFO buffer is still kind of an "issue"--the time it takes to read into that or something. But the program does have to have the 42 byte packet, right? Or can that be changed? Any help anyone could give even just regarding ways to make the Arduino faster would be greatly appreciated. Thanks!

Link to comment
Share on other sites

  • 3 weeks later...

Hi Vigil,

 

Other than overclocking (not typically a good idea) or switching to a faster CPU (e.g. Arduino Due), one thing you can do to help with I2C transactions is to change the I2C clock rate from 100kHz (default) to 400kHz (assuming you are running at 16MHz, otherwise it will be 200kHz). This is done with the following direct register write after you call "Wire.begin()":

TWBR = 12; // set 400kHz mode @ 16MHz CPU or 200kHz mode @ 8MHz CPU

Alternatively, you can change the DMP output rate by modifying the last bye of the last DMP configuration command on line 261 of the MPU6050_6Axis_MotionApps_20.h file:

 

https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/MPU6050_6Axis_MotionApps20.h#L261

    0x02,   0x16,   0x02,   0x00, 0x01                // D_0_22 inv_set_fifo_rate

    // This very last 0x01 WAS a 0x09, which drops the FIFO rate down to 20 Hz. 0x07 is 25 Hz,
    // 0x01 is 100Hz. Going faster than 100Hz (0x00=200Hz) tends to result in very noisy data.
    // DMP output frequency is calculated easily using this equation: (200Hz / (1 + value))

    // It is important to make sure the host processor can keep up with reading and processing
    // the FIFO output at the desired rate. Handling FIFO overflow cleanly is also a good idea.

You do have to read all of the data that goes into the FIFO in order to prevent an overflow, but you can slow down the data that goes into the FIFO easily enough.

Link to comment
Share on other sites

  • 2 months later...

Dear Jeff,

 

Thanks for all the good work you did on this sensor. Without your work it would probably be worthless to me.

 

I am posting in this forum although I have a MPU-9150 but this topic seems most fitting to my question.

 

By using the faster I2C clock I am now sampling at 11ms per measurement (the 10 ms is in between measurements tells my osciloscoop). I made adjustments in the code as suggested changing the line:

 

02, 0x16, 0x02, 0x00, 0x01 // D_0_22 inv_set_fifo_rate

 

into

 

02, 0x16, 0x02, 0x00, 0x00 // D_0_22 inv_set_fifo_rate

 

 

I changed it in both the MPU6050_6Axis_MotionApps20.h and the MPU6050_9Axis_MotionApps41.h but I don't see the sample rate go down to 6 ms or change at all. Maybe it is set to 100 Hz somewhere else when I initialize the sensor? This is my arduino code:

 

// I2C device class (I2Cdev) demonstration Arduino sketch for MPU9150
// 1/4/2013 original by Jeff Rowberg <jeff@rowberg.net> at https://github.com/jrowberg/i2cdevlib
//          modified by Aaron Weiss <aaron@sparkfun.com>
//
// Changelog:
//     2011-10-07 - initial release
//     2013-1-4 - added raw magnetometer output


/* ============================================
 I2Cdev device library code is placed under the MIT license


 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.
 ===============================================
 */


// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#include "Wire.h"


// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
// for both classes must be in the include path of your project
#include "I2Cdev.h"
#include "AK8975.h"
#include "MPU6050.h"


// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for InvenSense evaluation board)
// AD0 high = 0x69
AK8975 mag(0x0C);
MPU6050 accelgyro; // address = 0x68, the default, on MPU6050 EVB
MPU6050 mpu;


int16_t ax, ay, az;
int16_t gx, gy, gz;
int16_t mx, my, mz;


int16_t mpuData [9] = { 
  0, 0, 0, 0, 0, 0, 0, 0, 0 };
byte mpuDataSend [21] = { 
  127, 128, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
byte metingLSB = 0;
byte metingMSB = 0;
uint8_t mpuIntStatus;


#define LED_PIN 11 // teensy ledpin
bool blinkState = false;


void setup() {
  // join I2C bus (I2Cdev library doesn't do this automatically)
  Wire.begin();
  TWBR = 12; // set 400kHz mode @ 16MHz CPU or 200kHz mode @ 8MHz CPU


  // initialize serial communication
  // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
  // it's really up to you depending on your project)
  Serial.begin(115200);


  // initialize device
  Serial.println("Initializing I2C devices...");
  accelgyro.initialize();
  accelgyro.setI2CBypassEnabled(true);
  mag.initialize();


  // verify connection
  Serial.println("Testing device connections...");
  Serial.println(mag.testConnection() ? "AK8975 connection successful" : "AK8975 connection failed");


  // configure Arduino LED for
  pinMode(LED_PIN, OUTPUT);
}


void loop() {
  // read raw accel/gyro measurements from device
    accelgyro.getMotion6(&mpuData[0], &mpuData[1], &mpuData[2], &mpuData[3], &mpuData[4], &mpuData[5]);


    // read raw heading measurements from device
    mag.getHeading(&mpuData[6], &mpuData[7], &mpuData[8]);




    for (byte i = 0; i <= 8; i++){
      metingMSB = mpuData[i] >> 8;
      metingLSB = mpuData[i] & 255;
      mpuDataSend[3 + (i << 1)] = metingMSB;
      mpuDataSend[4 + (i << 1)] = metingLSB;
    }
      Serial.write (mpuDataSend, 21);


      // blink LED to indicate activity
      blinkState = !blinkState;
      digitalWrite(LED_PIN, blinkState);
}

 

I am looking for this high sample rate because of using it in a musical instrument. A latency under 10 ms is preferable.

 

I hope someone (Jeff) can help me.

 

Best, Hans.

Link to comment
Share on other sites

  • 3 weeks later...

Hi Hans,

 

I suspect the Serial.write() command is slowing you down. Can you double or quadruple the baud rate, or temporarily remove it and check the actual data capture rate by toggling a GPIO or something like that? The motion sensor should be able to read at 200Hz, but the Arduino itself or serial transfer might be the bottleneck.

 

One other note is that I have heard that the 200Hz output rate is rather noisy compared to the 100Hz or lower rates.

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...
On 2013/8/18 at 2:42 AM, Jeff Rowberg said:

Other than overclocking (not typically a good idea) or switching to a faster CPU (e.g. Arduino Due), one thing you can do to help with I2C transactions is to change the I2C clock rate from 100kHz (default) to 400kHz (assuming you are running at 16MHz, otherwise it will be 200kHz). This is done with the following direct register write after you call "Wire.begin()":


TWBR = 12; // set 400kHz mode @ 16MHz CPU or 200kHz mode @ 8MHz CPU

thanks @Jeff Rowberg, new to arduino but this works for me. 

- Arduino Nano and a GY92/65 board(actually MPU9255 embeded).

- baudrate 115200

D_0_22 inv_set_fifo_rate  0x00 for 200Hz output

- Serial.write close.

* for now no FIFO overflow interrupts, doing the checking of noise

Link to comment
Share on other sites

  • 5 weeks later...

Hi,

I am using MPU6050 with a GPS and want to obtain values for MPU6050 against the values of the GPS. I am using Jeff Rowberg's library to obtain raw values of accelerometer and gyroscope. The problem is that for one value of GPS I am getting at least 5-10 samples of MPU6050 data as the update rate of GPS is much lower than that of MPU6050. What can I do to make the IMU to slow down a little bit.?

Help would be appreciated. Thanks in advance.

Regards. 

Link to comment
Share on other sites

  • 3 years later...

Hi there,

I am using MPU6050 with two servos. With some extra addings to example MPU6050_DMP6_using_DMP_V6.12 there was no problem with servos. But when I wanted to use BMP180 and combined all of these in one code I get FIFO overflow. I was looking for solutions but none of them solved my problem exactly(or can't apply correctly). I tried to minimize the readings of datas of BMP180 and I get FIFO overflow less frequently. But servos are still slow and respond the changes of MPU6050 litte lately. So this lagging absolutely ruins the project and I cannot make any progress without solving this problem.

I would be grateful if anyone can help me.

Here is my code:

/*
  Arduino nano için;
    Bmp180 pinleri:
      sda -> a4
      scl -> a5
      vın -> 5v
      gnd -> gnd

    Mpu6050 pinleri:
      vcc -> 5v
      gnd -> gnd
      scl -> a5
      sda -> a4
      int -> d2
      
    RGB Led pinleri:
      d9, d10, d11
    
    Servo Motor pinleri:
      d7, d8

    Buzzer pinleri:
      d12  
 */


#include <Wire.h>
#include <Adafruit_BMP085.h>
#include<Servo.h>
#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
//#include "MPU6050.h" // not necessary if using MotionApps include file

#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
    #include "Wire.h"
#endif

#include <Servo.h>

Servo myservo,myservo2;  // create servo object to control a servo
#define seaLevelPressure_hPa 1013.25
Adafruit_BMP085 bmp;

int R=9;
int G=10;
int B=11;

const int buzzer = 12;

MPU6050 mpu;
// uncomment "OUTPUT_READABLE_QUATERNION" if you want to see the actual
// quaternion components in a [w, x, y, z] format (not best for parsing
// on a remote host such as Processing or something though)
//#define OUTPUT_READABLE_QUATERNION

// uncomment "OUTPUT_READABLE_EULER" if you want to see Euler angles
// (in degrees) calculated from the quaternions coming from the FIFO.
// Note that Euler angles suffer from gimbal lock (for more info, see
// http://en.wikipedia.org/wiki/Gimbal_lock)
//#define OUTPUT_READABLE_EULER

// uncomment "OUTPUT_READABLE_YAWPITCHROLL" if you want to see the yaw/
// pitch/roll angles (in degrees) calculated from the quaternions coming
// from the FIFO. Note this also requires gravity vector calculations.
// Also note that yaw/pitch/roll angles suffer from gimbal lock (for
// more info, see: http://en.wikipedia.org/wiki/Gimbal_lock)
#define OUTPUT_READABLE_YAWPITCHROLL

// uncomment "OUTPUT_READABLE_REALACCEL" if you want to see acceleration
// components with gravity removed. This acceleration reference frame is
// not compensated for orientation, so +X is always +X according to the
// sensor, just without the effects of gravity. If you want acceleration
// compensated for orientation, us OUTPUT_READABLE_WORLDACCEL instead.
//#define OUTPUT_READABLE_REALACCEL

// uncomment "OUTPUT_READABLE_WORLDACCEL" if you want to see acceleration
// components with gravity removed and adjusted for the world frame of
// reference (yaw is relative to initial orientation, since no magnetometer
// is present in this case). Could be quite handy in some cases.
//#define OUTPUT_READABLE_WORLDACCEL

// uncomment "OUTPUT_TEAPOT" if you want output that matches the
// format used for the InvenSense teapot demo
//#define OUTPUT_TEAPOT

#define INTERRUPT_PIN 2  // use pin 2 on Arduino Uno & most boards
#define LED_PIN 11 // (Arduino is 13, Teensy is 11, Teensy++ is 6)
#define SERVO_PIN 7 // use pin 9 for servo control
#define SERVO_PIN2 8
bool blinkState = false;

// MPU control/status vars
bool dmpReady = false;  // set true if DMP init was successful
uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU
uint8_t devStatus;      // return status after each device operation (0 = success, !0 = error)
uint16_t packetSize;    // expected DMP packet size (default is 42 bytes)
uint16_t fifoCount;     // count of all bytes currently in FIFO
uint8_t fifoBuffer[64]; // FIFO storage buffer

// orientation/motion vars
Quaternion q;           // [w, x, y, z]         quaternion container
VectorInt16 aa;         // [x, y, z]            accel sensor measurements
VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements
VectorInt16 aaWorld;    // [x, y, z]            world-frame accel sensor measurements
VectorFloat gravity;    // [x, y, z]            gravity vector
float euler[3];         // [psi, theta, phi]    Euler angle container
float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector

// packet structure for InvenSense teapot demo
uint8_t teapotPacket[14] = { '$', 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, '\r', '\n' };

// ================================================================
// ===               INTERRUPT DETECTION ROUTINE                ===
// ================================================================

volatile bool mpuInterrupt = false;     // indicates whether MPU interrupt pin has gone high
void dmpDataReady() {
    mpuInterrupt = true;
}

// ================================================================
// ===                      INITIAL SETUP                       ===
// ================================================================
  

void setup() {
  
    //Kırmızı renk elde etmek için...
  analogWrite(R,255);
  analogWrite(G,0);
  analogWrite(B,0);
  //delay(500);
  
  Serial.begin(38400);
  Serial.println("Ucus Bilgisayari deneme");
  if (!bmp.begin()) {
  Serial.println("BMP280 bulunamadi!");
  
  analogWrite(R,255);
  analogWrite(G,0);
  analogWrite(B,0);
  while (1) {}
  }
  myservo.attach(SERVO_PIN); 
    myservo2.attach(SERVO_PIN2); 
    myservo.write(0);   

     
    // join I2C bus (I2Cdev library doesn't do this automatically)
    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
        Wire.begin();
        TWBR = 48;
        Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having compilation difficulties
    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
        Fastwire::setup(400, true);
    #endif

   // Serial.begin(115200);
    while (!Serial); // wait for Leonardo enumeration, others continue immediately

    // NOTE: 8MHz or slower host processors, like the Teensy @ 3.3v or Ardunio
    // Pro Mini running at 3.3v, cannot handle this baud rate reliably due to
    // the baud timing being too misaligned with processor ticks. You must use
    // 38400 or slower in these cases, or use some kind of external separate
    // crystal solution for the UART timer.

    // initialize device
    Serial.println(F("Initializing I2C devices..."));
    mpu.initialize();
    pinMode(INTERRUPT_PIN, INPUT);

    // verify connection
    Serial.println(F("Testing device connections..."));
    Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));
    if(!mpu.testConnection()){
      analogWrite(R,255);
      analogWrite(G,0);
      analogWrite(B,0);
    }

    // wait for ready
    Serial.println(F("\nSend any character to begin DMP programming and demo: "));
    while (Serial.available() && Serial.read()); // empty buffer
    while (!Serial.available());                 // wait for data
    while (Serial.available() && Serial.read()); // empty buffer again

    // load and configure the DMP
    Serial.println(F("Initializing DMP..."));
    devStatus = mpu.dmpInitialize();

    // supply your own gyro offsets here, scaled for min sensitivity
    mpu.setXGyroOffset(220);
    mpu.setYGyroOffset(76);
    mpu.setZGyroOffset(-85);
    mpu.setZAccelOffset(1788); // 1688 factory default for my test chip

    // make sure it worked (returns 0 if so)
    if (devStatus == 0) {
        // turn on the DMP, now that it's ready
        Serial.println(F("Enabling DMP..."));
        mpu.setDMPEnabled(true);

        // enable Arduino interrupt detection
        Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)..."));
        attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), dmpDataReady, RISING);
        mpuIntStatus = mpu.getIntStatus();

        // set our DMP Ready flag so the main loop() function knows it's okay to use it
        Serial.println(F("DMP ready! Waiting for first interrupt..."));
        dmpReady = true;

        // get expected DMP packet size for later comparison
        packetSize = mpu.dmpGetFIFOPacketSize();
    } else {
        // ERROR!
        // 1 = initial memory load failed
        // 2 = DMP configuration updates failed
        // (if it's going to break, usually the code will be 1)
        Serial.print(F("DMP Initialization failed (code "));
        Serial.print(devStatus);
        Serial.println(F(")"));
    }

  // configure LED for output
  pinMode(LED_PIN, OUTPUT); 
  }

void loop() {

  //Yeşil renk elde etmek için...
  analogWrite(R,0);
  analogWrite(G,255);
  analogWrite(B,0);
  
 
  //Serial.print("Sicaklik = ");
  Serial.print(bmp.readTemperature());
  //Serial.println(" *C");
    
  //Serial.print("Basinc = ");
  Serial.print(bmp.readPressure());
  //Serial.println(" Pa");

  //Serial.print("Yukseklik = ");
  Serial.print(bmp.readAltitude());
  //Serial.println(" metre");

  //Serial.print("Deniz seviyesinde basinc = ");
  Serial.print(bmp.readSealevelPressure());
  //Serial.println(" Pa");

  //Serial.print("Gercek Yukseklik = ");
  Serial.print(bmp.readAltitude(seaLevelPressure_hPa * 100));
  //Serial.println(" metre");
  Serial.println("");
  
// if programming failed, don't try to do anything
    if (!dmpReady) return;

    // wait for MPU interrupt or extra packet(s) available
    while (!mpuInterrupt && fifoCount < packetSize) {
        // other program behavior stuff here
        // .
        // .
        // .
        // if you are really paranoid you can frequently test in between other
        // stuff to see if mpuInterrupt is true, and if so, "break;" from the
        // while() loop to immediately process the MPU data
        // .
        // .
        // .
    }

    // reset interrupt flag and get INT_STATUS byte
    mpuInterrupt = false;
    mpuIntStatus = mpu.getIntStatus();

    // get current FIFO count
    fifoCount = mpu.getFIFOCount();

    // check for overflow (this should never happen unless our code is too inefficient)
    if ((mpuIntStatus & 0x10) || fifoCount == 1024) {
        // reset so we can continue cleanly
        mpu.resetFIFO();
        Serial.println(F("FIFO overflow!"));

    // otherwise, check for DMP data ready interrupt (this should happen frequently)
    } else if (mpuIntStatus & 0x02) {
        // wait for correct available data length, should be a VERY short wait
        while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();

        // read a packet from FIFO
        mpu.getFIFOBytes(fifoBuffer, packetSize);
        
        // track FIFO count here in case there is > 1 packet available
        // (this lets us immediately read more without waiting for an interrupt)
        fifoCount -= packetSize;

        #ifdef OUTPUT_READABLE_QUATERNION
            // display quaternion values in easy matrix form: w x y z
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            Serial.print("quat\t");
            Serial.print(q.w);
            Serial.print("\t");
            Serial.print(q.x);
            Serial.print("\t");
            Serial.print(q.y);
            Serial.print("\t");
            Serial.println(q.z);
        #endif

        #ifdef OUTPUT_READABLE_EULER
            // display Euler angles in degrees
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            mpu.dmpGetEuler(euler, &q);
            Serial.print("euler\t");
            Serial.print(euler[0] * 180/M_PI);
            Serial.print("\t");
            Serial.print(euler[1] * 180/M_PI);
            Serial.print("\t");
            Serial.println(euler[2] * 180/M_PI);
        #endif

        #ifdef OUTPUT_READABLE_YAWPITCHROLL
            // display Euler angles in degrees
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            mpu.dmpGetGravity(&gravity, &q);
            mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
            Serial.print("ypr\t");
            Serial.print(ypr[0] * 180/M_PI);
            Serial.print("\t");
            Serial.print(ypr[1] * 180/M_PI);
            //Output to servo
            myservo.write(180-(90+ ypr[2] * 180/M_PI));  
            myservo2.write(180-(90+ ypr[1] * 180/M_PI));  
            Serial.print("\t");
            Serial.println(ypr[2] * 180/M_PI);
            
        #endif

        #ifdef OUTPUT_READABLE_REALACCEL
            // display real acceleration, adjusted to remove gravity
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            mpu.dmpGetAccel(&aa, fifoBuffer);
            mpu.dmpGetGravity(&gravity, &q);
            mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
            Serial.print("areal\t");
            Serial.print(aaReal.x);
            Serial.print("\t");
            Serial.print(aaReal.y);
            Serial.print("\t");
            Serial.println(aaReal.z);
        #endif

        #ifdef OUTPUT_READABLE_WORLDACCEL
            // display initial world-frame acceleration, adjusted to remove gravity
            // and rotated based on known orientation from quaternion
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            mpu.dmpGetAccel(&aa, fifoBuffer);
            mpu.dmpGetGravity(&gravity, &q);
            mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
            mpu.dmpGetLinearAccelInWorld(&aaWorld, &aaReal, &q);
            Serial.print("aworld\t");
            Serial.print(aaWorld.x);
            Serial.print("\t");
            Serial.print(aaWorld.y);
            Serial.print("\t");
            Serial.println(aaWorld.z);
        #endif
    
        #ifdef OUTPUT_TEAPOT
            // display quaternion values in InvenSense Teapot demo format:
            teapotPacket[2] = fifoBuffer[0];
            teapotPacket[3] = fifoBuffer[1];
            teapotPacket[4] = fifoBuffer[4];
            teapotPacket[5] = fifoBuffer[5];
            teapotPacket[6] = fifoBuffer[8];
            teapotPacket[7] = fifoBuffer[9];
            teapotPacket[8] = fifoBuffer[12];
            teapotPacket[9] = fifoBuffer[13];
            Serial.write(teapotPacket, 14);
            teapotPacket[11]++; // packetCount, loops at 0xFF on purpose
        #endif

        // blink LED to indicate activity
        blinkState = !blinkState;
        digitalWrite(LED_PIN, blinkState);
    }
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...