Last change
on this file since 206 was 136, checked in by ertl-honda, 9 years ago |
ライブラリとOS及びベーシックなサンプルの追加.
|
File size:
729 bytes
|
Line | |
---|
1 | /*
|
---|
2 | Speed by Potentiometer
|
---|
3 |
|
---|
4 | Control the robot's speed using the on-board
|
---|
5 | potentiometer. The speed will be printed on
|
---|
6 | the TFT screen.
|
---|
7 |
|
---|
8 | Circuit:
|
---|
9 | * Arduino Robot
|
---|
10 |
|
---|
11 | created 1 May 2013
|
---|
12 | by X. Yang
|
---|
13 | modified 12 May 2013
|
---|
14 | by D. Cuartielles
|
---|
15 |
|
---|
16 | This example is in the public domain
|
---|
17 | */
|
---|
18 |
|
---|
19 | #include <ArduinoRobot.h>
|
---|
20 | #include <Wire.h>
|
---|
21 | #include <SPI.h>
|
---|
22 |
|
---|
23 | void setup() {
|
---|
24 | // initialize the robot
|
---|
25 | Robot.begin();
|
---|
26 |
|
---|
27 | // initialize the screen
|
---|
28 | Robot.beginTFT();
|
---|
29 | }
|
---|
30 |
|
---|
31 | void loop() {
|
---|
32 | // read the value of the potentiometer
|
---|
33 | int val = map(Robot.knobRead(), 0, 1023, -255, 255);
|
---|
34 |
|
---|
35 | // print the value to the TFT screen
|
---|
36 | Robot.debugPrint(val);
|
---|
37 |
|
---|
38 | // set the same speed on both of the robot's wheels
|
---|
39 | Robot.motorsWrite(val, val);
|
---|
40 | delay(10);
|
---|
41 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.