查看完整版本: Arduino gyro問題求教!!!!
頁: [1]

c17283945 發表於 2014-5-23 08:30 AM

Arduino gyro問題求教!!!!

本帖最後由 c17283945 於 2014-5-23 08:31 AM 編輯

當我在執行此程式時,我翻動 LISY300AL 這顆晶片
程式就無法繼續回傳值,想請教如何修改
我的PIN接法:
LISY300AL → Arduino Duemilanove
3.3V → 3v3
GND → GND
X → A0
Y → A1
Z → A2

//Analog Gyro  Serial
//setup variables for Gyroscope
int xRate;
int x45;
int yRate;
int y45;
int Vref;

void setup(){
  Serial.begin(9600);
}

void loop(){

  //read values
  x45 = analogRead(A4);
  y45 = analogRead(A3);
  xRate = analogRead(A2);
  yRate = analogRead(A1);
  Vref = analogRead(A0);

  //print values
  Serial.print("xRate ");
  Serial.println(xRate);
  Serial.print("yRate ");
  Serial.println(yRate);
  Serial.print("Vref ");
  Serial.println(Vref);
  Serial.print("x4.5 ");
  Serial.println(x45);
  Serial.print("y4.5 ");
  Serial.println(y45);
  Serial.println(" ");

  delay(500);

}

...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div><div></div>

kipon123 發表於 2015-1-12 09:21 AM

可能是bug吧!      

m9530225 發表於 2015-1-24 07:28 PM

本帖最後由 m9530225 於 2015-1-24 07:28 PM 編輯

這是網站的範例,你比對http://playground.arduino.cc/Main/Gyro 這個範例的語法再試試看

chevylin0802 發表於 2015-1-29 07:37 AM

養成一個習慣
不管是8051之類的單晶片
還是Atmel AVR
都要先定義過gpio的用法
也就是用來作為輸出還是輸入
用來偵測位準還是做pulse count
類比輸入也是一樣
你在哪邊有定義到A0到A5是輸入?
一個沒有對GPIO做初始化的程式
不管你叫它做什麼工作
都不會動的

enjoyonion 發表於 2015-2-17 04:30 PM

個人認為修改此段為下:
void setup(){
  pinMode(A0, INPUT)
  pinMode(A1, INPUT)
  pinMode(A2, INPUT)
  pinMode(A3, INPUT)
  pinMode(A4, INPUT)
  Serial.begin(9600);
}<br><br><br><br><br><div></div>
頁: [1]