アナログ入力のテスト(ジョイステック)

Dependencies:   TextLCD mbed

Revision:
0:112b27ac26d5
Child:
1:b24f69657abc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 26 07:39:47 2011 +0000
@@ -0,0 +1,19 @@
+#include "mbed.h"
+#include "TextLCD.h"
+
+TextLCD lcd(p24, p26, p27, p28, p29, p30); // rs, e, d4-d7
+AnalogIn x(p19);
+AnalogIn y(p20);
+
+int main() {
+    float xx,yy;
+    lcd.cls();
+    lcd.printf("ADC TEST\n");
+    while (1) {
+        lcd.locate(0,1);
+        xx=(float)((int)(x.read()*100))/100.0;
+        yy=(float)((int)(y.read()*100))/100.0;
+        lcd.printf("x=%4.2f y=%4.2f",xx,yy);
+        wait(0.1f);
+    }
+}