mirror of
https://github.com/esp8266/Arduino.git
synced 2025-08-20 05:03:14 +03:00
.settings
app
arduino-builder
arduino-core
build
docs
hardware
libraries
Adafruit_ILI9341
Audio
Bridge
Esplora
Ethernet
Firmata
GSM
LiquidCrystal
OneWire
RobotIRremote
Robot_Control
examples
explore
learn
AllIOPorts
Beep
CleanEEPROM
Compass
Compass.ino
IRArray
LCDDebugPrint
LCDPrint
LCDWriteText
LineFollowWithPause
Melody
MotorTest
SpeedByPotentiometer
TurnTest
keyboardTest
src
README.adoc
library.properties
Robot_Motor
SD
Scheduler
Servo
SpacebrewYun
Stepper
TFT
Temboo
USBHost
WiFi
.classpath
.gitignore
.project
.travis.yml
README.Arduino.md
README.md
appveyor.yml
format.every.sketch.sh
lib_sync
license.txt
44 lines
675 B
C++
44 lines
675 B
C++
/*
|
|
Compass
|
|
|
|
Try the compass both on the robot's TFT
|
|
and through the serial port.
|
|
|
|
Circuit:
|
|
* Arduino Robot
|
|
|
|
created 1 May 2013
|
|
by X. Yang
|
|
modified 12 May 2013
|
|
by D. Cuartielles
|
|
|
|
This example is in the public domain
|
|
*/
|
|
|
|
#include <ArduinoRobot.h>
|
|
#include <Wire.h>
|
|
#include <SPI.h>
|
|
|
|
void setup() {
|
|
// initialize the robot
|
|
Robot.begin();
|
|
|
|
// initialize the robot's screen
|
|
Robot.beginTFT();
|
|
|
|
// initialize the serial port
|
|
Serial.begin(9600);
|
|
}
|
|
|
|
void loop() {
|
|
// read the compass
|
|
int compass = Robot.compassRead();
|
|
|
|
// print out the sensor's value
|
|
Serial.println(compass);
|
|
|
|
// show the value on the robot's screen
|
|
Robot.drawCompass(compass);
|
|
}
|
|
|