정보나눔

오픈소스하드웨어 프로젝트에 대한 다양한 정보를 나누는 공간입니다.

아두이노 코드 질문 2.
kiwon | 2018-04-02
#include "Wire.h"
#include "I2Cdev.h"
#include "MPU6050.h"
#include "Servo.h"
MPU6050 mpu;
 
int16_t ax, ay, az;
int16_t gx, gy, gz;
 
Servo myservo;
 
int val;
int prevVal;
int sw = 10;
int led = 6;
int state = LOW;
int previous = LOW;
int reading;
long time = 0;
long debounce = 100;
void setup()
{
    pinMode(sw, INPUT_PULLUP);
    pinMode(led, OUTPUT);
    Wire.begin();
    Serial.begin(38400);
 
    Serial.println("Initialize MPU");
    mpu.initialize();
    Serial.println(mpu.testConnection() ? "Connected" : "Connection failed");
    myservo.attach(9);
}
 
void loop()
{
    reading = digitalRead(sw);
    if (reading == HIGH && previous == LOW && millis() - time > debounce)
    {
      if (state == HIGH)
        state = LOW;
      else
        state = HIGH;
      time = millis();
    }
    digitalWrite(led, state);
    previous = reading;
   
    mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
 
    val = map(ay, -17000, 17000, 0, 179);
    if (val != prevVal)
    {
        myservo.write(val);
        prevVal = val;
    }
    delay(50);
}
 
mpu6050이 움직일때 서보모터가 움직이는 코드에다가 led 전구 스위치를 단건데 
C:\Users\湲곗썝\Documents\Arduino\z_led\z_led.ino: In function 'void loop()':
C:\Users\湲곗썝\Documents\Arduino\z_led\z_led.ino:39:63: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:64:14: warning: #warning Using current Arduino IDE with Wire library is functionally limiting. [-Wcpp]
             #warning Using current Arduino IDE with Wire library is functionally limiting.
              ^
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:65:14: warning: #warning Arduino IDE v1.0.1+ with I2CDEV_BUILTIN_FASTWIRE implementation is recommended. [-Wcpp]
             #warning Arduino IDE v1.0.1+ with I2CDEV_BUILTIN_FASTWIRE implementation is recommended.
              ^
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:66:14: warning: #warning This I2Cdev implementation does not support: [-Wcpp]
             #warning This I2Cdev implementation does not support:
              ^
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:67:14: warning: #warning - Timeout detection (some Wire requests block forever) [-Wcpp]
             #warning - Timeout detection (some Wire requests block forever)
              ^
C:\Program Files (x86)\Arduino\libraries\MPU6050\MPU6050.cpp:1718:113: warning: unused parameter 'mx' [-Wunused-parameter]
 void MPU6050::getMotion9(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16_t* gy, int16_t* gz, int16_t* mx, int16_t* my, int16_t* mz) {
                                                                                                                 ^
C:\Program Files (x86)\Arduino\libraries\MPU6050\MPU6050.cpp:1718:126: warning: unused parameter 'my' [-Wunused-parameter]
 void MPU6050::getMotion9(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16_t* gy, int16_t* gz, int16_t* mx, int16_t* my, int16_t* mz) {
                                                                                                                              ^
C:\Program Files (x86)\Arduino\libraries\MPU6050\MPU6050.cpp:1718:139: warning: unused parameter 'mz' [-Wunused-parameter]
 void MPU6050::getMotion9(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16_t* gy, int16_t* gz, int16_t* mx, int16_t* my, int16_t* mz) {
                                                                                                                                           ^
스케치는 프로그램 저장 공간 5894 바이트(18%)를 사용. 최대 32256 바이트.
전역 변수는 동적 메모리 522바이트(25%)를 사용, 1526바이트의 지역변수가 남음.  최대는 2048 바이트.
avrdude: ser_open(): can't set com-state for "\\.\COM4"
스케치를 업로드 하는 동안 에러가 발생하였습니다.
 
이렇게 길게 오류가 뜨는데 어떻게 해야하나요 ..
이전글   |    아두이노 mpu6050 코드 질문!! 2018-04-02
다음글   |    아두이노 카메라 모듈 2018-04-02