Hello,
I am very new to Arduino. I am trying to make a device that plots one axis of accelerometer data to the 2.4" TFT display on the 4Duino. I am using the 9 Axes Motion Shield.
I currently have it running code which steams the data through serial and it is graphed on PC using the serial plotter feature of Arduino IDE.
Does anyone know how I can convert this to graph on the LCD display instead?
Below is the code that I am currently using to output through serial. (The sketch code file is attached as well)
*I will send a small cash incentive via PayPal to anyone who can help me get this working. :-)
Any help is greatly appreciated.
Thanks!
#include "NAxisMotion.h"
#include <Wire.h>
NAxisMotion mySensor;
unsigned long lastStreamTime = 0;
const int streamPeriod = 20; //To stream at 50Hz without using additional timers (time period(ms) =1000/frequency(Hz))
bool updateSensorData = true; //Flag to update the sensor data. Default is true to perform the first read before the first stream
void setup() //This code is executed once
{
//Peripheral Initialization
Serial.begin(115200); //Initialize the Serial Port to view information on the Serial Monitor
I2C.begin(); //Initialize I2C communication to the let the library communicate with the sensor.
//Sensor Initialization
mySensor.initSensor(); //The I2C Address can be changed here inside this function in the library
mySensor.setOperationMode(OPERATION_MODE_NDOF); //Can be configured to other operation modes as desired
mySensor.setUpdateMode(MANUAL); //The default is AUTO. Changing to MANUAL requires calling the relevant update functions prior to calling the read functions
//Setting to MANUAL requires fewer reads to the sensor
}
void loop()
{
if (updateSensorData) //Keep the updating of data as a separate task
{
mySensor.updateLinearAccel();
mySensor.updateCalibStatus(); //Update the Calibration Status
updateSensorData = false;
}
if ((millis() - lastStreamTime) >= streamPeriod)
{
lastStreamTime = millis();
//Acceleration
//Serial.print(" AccelZ: ");
Serial.print(mySensor.readLinearAccelZ());
Serial.print(", ");
Serial.println();
updateSensorData = true;
}
}
I am very new to Arduino. I am trying to make a device that plots one axis of accelerometer data to the 2.4" TFT display on the 4Duino. I am using the 9 Axes Motion Shield.
I currently have it running code which steams the data through serial and it is graphed on PC using the serial plotter feature of Arduino IDE.
Does anyone know how I can convert this to graph on the LCD display instead?
Below is the code that I am currently using to output through serial. (The sketch code file is attached as well)
*I will send a small cash incentive via PayPal to anyone who can help me get this working. :-)
Any help is greatly appreciated.
Thanks!
#include "NAxisMotion.h"
#include <Wire.h>
NAxisMotion mySensor;
unsigned long lastStreamTime = 0;
const int streamPeriod = 20; //To stream at 50Hz without using additional timers (time period(ms) =1000/frequency(Hz))
bool updateSensorData = true; //Flag to update the sensor data. Default is true to perform the first read before the first stream
void setup() //This code is executed once
{
//Peripheral Initialization
Serial.begin(115200); //Initialize the Serial Port to view information on the Serial Monitor
I2C.begin(); //Initialize I2C communication to the let the library communicate with the sensor.
//Sensor Initialization
mySensor.initSensor(); //The I2C Address can be changed here inside this function in the library
mySensor.setOperationMode(OPERATION_MODE_NDOF); //Can be configured to other operation modes as desired
mySensor.setUpdateMode(MANUAL); //The default is AUTO. Changing to MANUAL requires calling the relevant update functions prior to calling the read functions
//Setting to MANUAL requires fewer reads to the sensor
}
void loop()
{
if (updateSensorData) //Keep the updating of data as a separate task
{
mySensor.updateLinearAccel();
mySensor.updateCalibStatus(); //Update the Calibration Status
updateSensorData = false;
}
if ((millis() - lastStreamTime) >= streamPeriod)
{
lastStreamTime = millis();
//Acceleration
//Serial.print(" AccelZ: ");
Serial.print(mySensor.readLinearAccelZ());
Serial.print(", ");
Serial.println();
updateSensorData = true;
}
}
Comment