Created
August 3, 2018 13:05
-
-
Save hw0k/33dcd931ec74e0b22397777a1081a9c7 to your computer and use it in GitHub Desktop.
알티노 가속도 센서 활용하기
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Altino.h> | |
/** | |
* 가속도 센서 활용하기 | |
*/ | |
SensorData sdata; | |
void setup() { | |
Serial.begin(115200); | |
} | |
void loop() { | |
Sensor(10, &sdata); | |
if (sdata.GSensor[0] > 3000 || sdata.GSensor[0] < -3000) { | |
// 차체가 상하로 비틀어져 있을 때 'X'를 표시합니다. | |
Display('X'); | |
} | |
else if (sdata.GSensor[1] > 3000 || sdata.GSensor[1] < -3000) { | |
// 차체가 좌우로 비틀어져 있을 때 'Y'를 표시합니다. | |
Display('Y'); | |
} | |
else if (sdata.GSensor[2] == 0) { | |
// Z축의 조건과 값을 알 수 없습니다.. | |
Display(0); | |
} | |
else { | |
Display(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment