배송 |
---|
상품 정보 | 가격 | 삭제 |
---|---|---|
아두이노 3축 자이로 L3G4200D 센서 모듈 / Arduino GY-50 | ||
TOTAL PRICE(수량) 0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include <Wire.h> #include "I2Cdev.h" #include "L3G4200D.h" L3G4200D gyro; int16_t avx, avy, avz; // 센서의 x, y, z축 각속도에 대한 변수 선언 #define LED_PIN 13 bool blinkState = false; void setup() { Wire.begin(); // 동작시작 Serial.begin(9600); // 통신 속도 9600으로 설정 Serial.println("Initializing I2C devices..."); gyro.initialize(); Serial.println("Testing device connections..."); Serial.println(gyro.testConnection() ? "L3G4200D connection successful" : "L3G4200D connection failed"); pinMode(LED_PIN, OUTPUT); gyro.setFullScale(2000); } void loop() { gyro.getAngularVelocity(&avx, &avy, &avz); // 센서의 x축, y축, z축의 각속도를 읽음 Serial.print("angular velocity:\t"); // 시리얼모니터에 각속도를 출력 Serial.print(avx); Serial.print("\t"); Serial.print(avy); Serial.print("\t"); Serial.println(avz); blinkState = !blinkState; digitalWrite(LED_PIN, blinkState); delay(1000); } | cs |