filmov
tv
Plotting (Graphing) Accelerometer + Gyro MPU6050 using Arduino and Processing

Показать описание
GET CODE HERE:
The InvenSense MPU-6050 sensor contains a MEMS accelerometer and a MEMS gyro in a single chip. It is very accurate, as it contains 16-bits analog to digital conversion hardware for each channel.
The gyro+ accelerometer simultaneously puts out 6 readings : g, gy, gz, ax, ay, az,
Processing is a flexible software sketchbook and a language for learning how to code within the context of the visual arts. Processing was actually one of the programs that Arduino was originally based on and is a great way to visualise arduino sensor outputs
There are tens of thousands of students, artists, designers, researchers, and hobbyists who use Processing for learning and prototyping.
SOCIAL:
WEBSITES:
code Arduino:
#include "I2Cdev.h" // include the I2Cdev library
#include "MPU6050.h" // include the accelerometer library
MPU6050 accelgyro; // set device to MPU6050
int16_t ax, ay, az, gx, gy, gz; // define accel as ax,ay,az
int baselineX = 0;
void setup() {
baselineX = ax;
}
void loop() {
delay(2);
}
code Processing:
Serial myPort; // The serial port
int xPos = 1; // horizontal position of the graph
float inByte = 0;
void setup () {
// set the window size:
size(1000, 600);
// List all the available serial ports
// I know that the first port in the serial list on my Mac is always my
// Open whatever port is the one you're using.
// don't generate a serialEvent() unless you get a newline character:
// set initial background:
background(0);
}
void draw () {
// draw the line:
stroke(127, 34, 255);
line(xPos, height, xPos, height - inByte);
// at the edge of the screen, go back to the beginning:
if (xPos greater= width) { //careful with this line requires a symbol that is not allowed in YouTube
xPos = 0;
background(0);
} else {
// increment the horizontal position:
xPos++;
}
}
void serialEvent (Serial myPort) {
// get the ASCII string:
if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// convert to an int and map to the screen height:
inByte = float(inString);
println(inByte);
inByte = map(inByte, 0, 1023, 0, height);
}
}
-~-~~-~~~-~~-~-
Latest and Best Arduino Playlist in Collaboratio with DFRobot:
-~-~~-~~~-~~-~-
The InvenSense MPU-6050 sensor contains a MEMS accelerometer and a MEMS gyro in a single chip. It is very accurate, as it contains 16-bits analog to digital conversion hardware for each channel.
The gyro+ accelerometer simultaneously puts out 6 readings : g, gy, gz, ax, ay, az,
Processing is a flexible software sketchbook and a language for learning how to code within the context of the visual arts. Processing was actually one of the programs that Arduino was originally based on and is a great way to visualise arduino sensor outputs
There are tens of thousands of students, artists, designers, researchers, and hobbyists who use Processing for learning and prototyping.
SOCIAL:
WEBSITES:
code Arduino:
#include "I2Cdev.h" // include the I2Cdev library
#include "MPU6050.h" // include the accelerometer library
MPU6050 accelgyro; // set device to MPU6050
int16_t ax, ay, az, gx, gy, gz; // define accel as ax,ay,az
int baselineX = 0;
void setup() {
baselineX = ax;
}
void loop() {
delay(2);
}
code Processing:
Serial myPort; // The serial port
int xPos = 1; // horizontal position of the graph
float inByte = 0;
void setup () {
// set the window size:
size(1000, 600);
// List all the available serial ports
// I know that the first port in the serial list on my Mac is always my
// Open whatever port is the one you're using.
// don't generate a serialEvent() unless you get a newline character:
// set initial background:
background(0);
}
void draw () {
// draw the line:
stroke(127, 34, 255);
line(xPos, height, xPos, height - inByte);
// at the edge of the screen, go back to the beginning:
if (xPos greater= width) { //careful with this line requires a symbol that is not allowed in YouTube
xPos = 0;
background(0);
} else {
// increment the horizontal position:
xPos++;
}
}
void serialEvent (Serial myPort) {
// get the ASCII string:
if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// convert to an int and map to the screen height:
inByte = float(inString);
println(inByte);
inByte = map(inByte, 0, 1023, 0, height);
}
}
-~-~~-~~~-~~-~-
Latest and Best Arduino Playlist in Collaboratio with DFRobot:
-~-~~-~~~-~~-~-
Комментарии