Hello (I'm french, so I not really speak english, thanks google translate ^^) !
In order to test the serial port, I upload this sketch on my Teensy 3.2 Pins :
..and it works perfectly.
Except that I uploaded this sketch and this time, nothing appears on the serial monitor :
What do I have to do if I want solve this problem ?
There is no error message, the upload of the program works well, but there is nothing on the serial monitor.
The teensy is only connected to a chip GY-87 according to the following hook :
Teensy 3.2 <---> GY-87
3.3V (250 mA max) <---> 3.3V
AGND <---> GND
A5 (SCL0) <--> SOL
A4 ( SDA0) <---> SDA
2 <---> INTA
My pc is running on windows 10 (anniversary update)
Thank you very much in advance !
In order to test the serial port, I upload this sketch on my Teensy 3.2 Pins :
Code:
/* Simple "Hello World" example.
After uploading this to your board, use Serial Monitor
to view the message. When Serial is selected from the
Tools > USB Type menu, the correct serial port must be
selected from the Tools > Serial Port AFTER Teensy is
running this code. Teensy only becomes a serial device
while this code is running! For non-Serial types,
the Serial port is emulated, so no port needs to be
selected.
This example code is in the public domain.
*/
void setup()
{
Serial.begin(9600); // USB is always 12 Mbit/sec
}
void loop()
{
Serial.println("Hello World...");
delay(1000); // do not print too fast!
}
..and it works perfectly.
Except that I uploaded this sketch and this time, nothing appears on the serial monitor :
Code:
#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
#include <HMC5883L.h>
#include "Wire.h"
#define DOUT_TRIGGER 8
#define DIN_ECHO 9
#define DIN_ON 4
boolean ON;
HMC5883L compass;
MPU6050 mpu;
bool dmpReady = false;
uint8_t mpuIntStatus;
uint8_t devStatus;
uint16_t packetSize;
uint16_t fifoCount;
uint8_t fifoBuffer[64];
Quaternion q;
VectorFloat gravity;
float ypr[3];
int tempsActif = 150;
int tempsInactif = 1;
float distance = 0;
volatile bool mpuInterrupt = false;
void dmpDataReady()
{
mpuInterrupt = true;
}
void setup()
{
Serial.begin(115200);
Wire.begin();
pinMode(DOUT_TRIGGER, OUTPUT);
pinMode(DIN_ECHO, INPUT);
pinMode(DIN_ON, INPUT_PULLUP);
mpu.initialize();
devStatus = mpu.dmpInitialize();
mpu.setXGyroOffset(220);
mpu.setYGyroOffset(76);
mpu.setZGyroOffset(-85);
mpu.setZAccelOffset(1788);
if (devStatus == 0)
{
mpu.setDMPEnabled(true);
attachInterrupt(4, dmpDataReady, RISING);
mpuIntStatus = mpu.getIntStatus();
dmpReady = true;
packetSize = mpu.dmpGetFIFOPacketSize();
}
else
{
Serial.print(devStatus);
Serial.println(F(")"));
}
mpu.setI2CBypassEnabled(true);
compass = HMC5883L();
setupHMC5883L();
}
void loop(){
ON = digitalRead(DIN_ON);
if(1){
if (!dmpReady) return;
while (!mpuInterrupt && fifoCount < packetSize){}
mpuInterrupt = false;
mpuIntStatus = mpu.getIntStatus();
fifoCount = mpu.getFIFOCount();
if ((mpuIntStatus & 0x10) || fifoCount == 1024){
mpu.resetFIFO();
}
else if (mpuIntStatus & 0x02){
while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();
mpu.getFIFOBytes(fifoBuffer, packetSize);
fifoCount -= packetSize;
mpu.dmpGetQuaternion(&q, fifoBuffer);
mpu.dmpGetGravity(&gravity, &q);
mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
//Serial.print("Phi: ");
Serial.println(ypr[2] * 180/M_PI);
if (ypr[2] * 180/M_PI<-20)
{
//keyboard.press('k');
}
else if (ypr[2] * 180/M_PI>20)
{
//keyboard.press('m');
}
if (ypr[1] * 180/M_PI<-25)
{
//keyboard.press('l');
}
else if (ypr[1] * 180/M_PI>10)
{
//keyboard.press('o');
}
if (ypr[1] * 180/M_PI<-5 && ypr[1] * 180/M_PI>-20 && ypr[2] * 180/M_PI>-15 && ypr[2] * 180/M_PI<15)
{
float heading = getHeading();
if (heading<290 && heading>200)
{
//keyboard.press('q');
}
else if (heading<200 && heading<350)
{
//keyboard.press('d');
}
}
if (distance>14 && distance <60)
{
//keyboard.press('z');
}
else if (distance<6)
{
//keyboard.press('s');
}
else if (distance>60)
{}
delay(tempsActif);
digitalWrite(DOUT_TRIGGER, LOW);
delayMicroseconds(2);
digitalWrite(DOUT_TRIGGER, HIGH);
delayMicroseconds(10);
digitalWrite(DOUT_TRIGGER, LOW);
distance= pulseIn(DIN_ECHO, HIGH) / 58.0;
//keyboard.releaseAll();
}
delay(tempsInactif);
}
}
void setupHMC5883L()
{
int error;
error = compass.SetScale(1.3);
if(error != 0) Serial.println(compass.GetErrorText(error));
error = compass.SetMeasurementMode(Measurement_Continuous);
if(error != 0) Serial.println(compass.GetErrorText(error));
}
float getHeading()
{
MagnetometerScaled scaled = compass.ReadScaledAxis();
float heading = atan2(scaled.YAxis, scaled.XAxis);
if(heading < 0) heading += 2*PI;
if(heading > 2*PI) heading -= 2*PI;
return heading * RAD_TO_DEG;
}
What do I have to do if I want solve this problem ?
There is no error message, the upload of the program works well, but there is nothing on the serial monitor.
The teensy is only connected to a chip GY-87 according to the following hook :
Teensy 3.2 <---> GY-87
3.3V (250 mA max) <---> 3.3V
AGND <---> GND
A5 (SCL0) <--> SOL
A4 ( SDA0) <---> SDA
2 <---> INTA
My pc is running on windows 10 (anniversary update)
Thank you very much in advance !