Last change
on this file since 449 was 136, checked in by ertl-honda, 9 years ago |
ライブラリとOS及びベーシックなサンプルの追加.
|
File size:
675 bytes
|
Line | |
---|
1 | /*
|
---|
2 | Compass
|
---|
3 |
|
---|
4 | Try the compass both on the robot's TFT
|
---|
5 | and through the serial port.
|
---|
6 |
|
---|
7 | Circuit:
|
---|
8 | * Arduino Robot
|
---|
9 |
|
---|
10 | created 1 May 2013
|
---|
11 | by X. Yang
|
---|
12 | modified 12 May 2013
|
---|
13 | by D. Cuartielles
|
---|
14 |
|
---|
15 | This example is in the public domain
|
---|
16 | */
|
---|
17 |
|
---|
18 | #include <ArduinoRobot.h>
|
---|
19 | #include <Wire.h>
|
---|
20 | #include <SPI.h>
|
---|
21 |
|
---|
22 | void setup() {
|
---|
23 | // initialize the robot
|
---|
24 | Robot.begin();
|
---|
25 |
|
---|
26 | // initialize the robot's screen
|
---|
27 | Robot.beginTFT();
|
---|
28 |
|
---|
29 | // initialize the serial port
|
---|
30 | Serial.begin(9600);
|
---|
31 | }
|
---|
32 |
|
---|
33 | void loop() {
|
---|
34 | // read the compass
|
---|
35 | int compass = Robot.compassRead();
|
---|
36 |
|
---|
37 | // print out the sensor's value
|
---|
38 | Serial.println(compass);
|
---|
39 |
|
---|
40 | // show the value on the robot's screen
|
---|
41 | Robot.drawCompass(compass);
|
---|
42 | }
|
---|
43 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.