mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
Fixed robot libraries and examples for unified Arduino core
This commit is contained in:
@ -43,7 +43,7 @@ void setup() {
|
||||
// These are some general values that work for line following
|
||||
// uncomment one or the other to see the different behaviors of the robot
|
||||
// Robot.lineFollowConfig(11, 5, 50, 10);
|
||||
Robot.lineFollowConfig(14, 9, 50, 10);
|
||||
Robot.lineFollowConfig(11, 7, 60, 5);
|
||||
|
||||
//set the motor board into line-follow mode
|
||||
Robot.setMode(MODE_LINE_FOLLOW);
|
||||
|
@ -56,7 +56,10 @@ void renderUI() {
|
||||
Robot.rect(73, 38, 13, 13); // up
|
||||
Robot.circle(79, 64, 6); // middle
|
||||
Robot.rect(73, 78, 13, 13); // down
|
||||
Robot.circle(26, 116, 18); // knob
|
||||
|
||||
//draw the knob
|
||||
Robot.noFill();
|
||||
Robot.circle(26, 116, 17); // knob
|
||||
|
||||
//draw the vertical bargraph
|
||||
int fullPart=map(pitch, 200, 2000, 0, 58); //length of filled bargraph
|
||||
@ -136,31 +139,27 @@ void keyDown(int keyCode) {
|
||||
oldKey = keyCode;
|
||||
}
|
||||
|
||||
//Draw a circle according to value
|
||||
//of the knob.
|
||||
void drawKnob(int val) {
|
||||
static int x = 0, y = 0, val_old = 0;
|
||||
// radian number, -3.14 to 3.14
|
||||
float ang = map(val, 0, 1023, -PI*1000, PI*1000) / 1000.0;
|
||||
|
||||
// erase the old line
|
||||
if (val_old != val) {
|
||||
Robot.stroke(255, 255, 255);
|
||||
Robot.line(26, 116, x, y);
|
||||
}
|
||||
static int val_old;
|
||||
int r=map(val,0,1023,1,15);
|
||||
|
||||
// the following lines avoid a glitch in the TFT library
|
||||
// that seems to appear when drawing a vertical line
|
||||
if (val < 1011 && val > 265 || val < 253) {
|
||||
//a bit math for drawing the hand inside the clock
|
||||
x = 16*sin(ang)+26;
|
||||
y = 16*cos(ang)+116;
|
||||
}
|
||||
if (val > 265 && val < 253) {
|
||||
x = 10; y = 116;
|
||||
}
|
||||
if (val >= 1011) {
|
||||
x = 27; y = 100;
|
||||
}
|
||||
Robot.stroke(0, 0, 0);
|
||||
Robot.line(26, 116, x, y);
|
||||
val_old = val;
|
||||
//Only updates when the
|
||||
//value changes.
|
||||
if(val_old!=r){
|
||||
Robot.noFill();
|
||||
|
||||
//erase the old circle
|
||||
Robot.stroke(255, 255, 255);
|
||||
Robot.circle(26,116,r+1);
|
||||
|
||||
//draw the new circle
|
||||
Robot.stroke(255, 0, 255);
|
||||
Robot.circle(26,116,r);
|
||||
|
||||
Robot.stroke(0, 0, 0);
|
||||
|
||||
val_old=r;
|
||||
}
|
||||
}
|
||||
|
@ -1,103 +1,38 @@
|
||||
/* 6 Wheel Calibration
|
||||
*
|
||||
* Use this sketch to calibrate the wheels in your robot.
|
||||
* Your robot should drive as straight as possible when
|
||||
* putting both motors at the same speed.
|
||||
*
|
||||
* Run the software and follow the on-screen instructions.
|
||||
* Use the trimmer on the bottom board to make sure the
|
||||
* robot is working at its best!
|
||||
*
|
||||
* (c) 2013 X. Yang
|
||||
*/
|
||||
#include "scripts_library.h"
|
||||
|
||||
Use this sketch to calibrate the wheels in your robot.
|
||||
Your robot should drive as straight as possible when
|
||||
putting both motors at the same speed.
|
||||
|
||||
Run the software and follow the on-screen instructions.
|
||||
Use the trimmer on the motor board to make sure the
|
||||
robot is working at its best!
|
||||
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> // inport the robot librsry
|
||||
// import the utility library
|
||||
// a description of its funtionality is below
|
||||
#include <utility/RobotTextManager.h>
|
||||
|
||||
// arrays to hold the text for instructions
|
||||
char script1[] ="Wheel Calibration";
|
||||
char script2[] ="1. Put Robot on a\n flat surface";
|
||||
char script3[] ="2. Adjust speed with the knob on top";
|
||||
char script4[] ="3. If robot goes\n straight, it's done";
|
||||
char script5[] ="4. Use screwdriver\n on the bottom trim";
|
||||
char script6[] ="- Robot turns left,\n screw it clockwise;";
|
||||
char script7[] ="- Turns right, screw it ct-colockwise;";
|
||||
char script8[] ="5. Repeat 4 until\n going straight";
|
||||
|
||||
int speedRobot; //robot speed
|
||||
int calibrationValue; //value for calibrate difference between wheels
|
||||
#include <ArduinoRobot.h>
|
||||
|
||||
void setup(){
|
||||
//necessary initialization sequence
|
||||
Serial.begin(9600);
|
||||
Robot.begin();
|
||||
Robot.beginTFT();
|
||||
Robot.beginSD();
|
||||
|
||||
Robot.setTextWrap(false);
|
||||
Robot.displayLogos();
|
||||
|
||||
// left and top margin for displaying text
|
||||
// see below for a description of this
|
||||
textManager.setMargin(5,5);
|
||||
// write all instructions at once
|
||||
writeAllscript();
|
||||
writeAllScripts();
|
||||
|
||||
}
|
||||
void loop(){
|
||||
//Control the robot's speed with knob on top
|
||||
int speedRobot=map(Robot.knobRead(),0,1023,-255,255);
|
||||
Robot.motorsWrite(speedRobot,speedRobot);
|
||||
int val=map(Robot.knobRead(),0,1023,-255,255);
|
||||
Serial.println(val);
|
||||
Robot.motorsWrite(val,val);
|
||||
|
||||
//read value of the pot on motor baord,to clibrate the wheels
|
||||
int calibrationValue=map(Robot.trimRead(),0,1023,-30,30);
|
||||
// print the values to the screen
|
||||
Robot.debugPrint(calibrationValue,110,145);
|
||||
int WC=map(Robot.trimRead(),0,1023,-20,20);
|
||||
Robot.debugPrint(WC,108,149);
|
||||
delay(40);
|
||||
|
||||
}
|
||||
|
||||
void writeAllscript(){
|
||||
//prints 8 scripts one after another
|
||||
textManager.writeText(0,0,script1);
|
||||
textManager.writeText(1,0,script2);
|
||||
textManager.writeText(3,0,script3);
|
||||
textManager.writeText(5,0,script4);
|
||||
textManager.writeText(7,0,script5);
|
||||
textManager.writeText(9,0,script6);
|
||||
textManager.writeText(11,0,script7);
|
||||
textManager.writeText(13,0,script8);
|
||||
}
|
||||
|
||||
/**
|
||||
textManager mostly contains helper functions for
|
||||
R06_Wheel_Calibration and R01_Hello_User.
|
||||
|
||||
textManager.setMargin(margin_left, margin_top):
|
||||
Configure the left and top margin for text
|
||||
display. The margins will be used by
|
||||
textManager.writeText().
|
||||
Parameters:
|
||||
margin_left, margin_top: int, the margin values
|
||||
from the top and left side of the screen.
|
||||
Returns:
|
||||
none
|
||||
|
||||
textManager.writeText(line,column,text):
|
||||
Display text on the specific line and column.
|
||||
It's different from Robot.text() which
|
||||
uses pixels for positioning the text.
|
||||
Parameters:
|
||||
line:int, which line is the text displayed. Each line
|
||||
is 10px high.
|
||||
column:int, which column is the text displayed. Each
|
||||
column is 8px wide.
|
||||
text:a char array(string) of the text to be displayed.
|
||||
Returns:
|
||||
none
|
||||
*/
|
||||
|
@ -0,0 +1,43 @@
|
||||
#include <avr/pgmspace.h>
|
||||
#include <ArduinoRobot.h>
|
||||
|
||||
prog_char script1[] PROGMEM="Wheel Calibration\n";
|
||||
prog_char script2[] PROGMEM="1. Put Robot on a flat surface\n";
|
||||
prog_char script3[] PROGMEM="2. Adjust speed with the knob on top\n";
|
||||
prog_char script4[] PROGMEM="3. If robot goes straight, it's done\n";
|
||||
prog_char script5[] PROGMEM="4. Use screwdriver on the trim on bottom\n";
|
||||
prog_char script6[] PROGMEM="Robot turns left, screw it clockwise;\n";
|
||||
prog_char script7[] PROGMEM="Turns right, screw it ct-colockwise;\n";
|
||||
prog_char script8[] PROGMEM="5. Repeat 4 until going straight\n";
|
||||
|
||||
char buffer[42];//must be longer than text
|
||||
|
||||
PROGMEM const char *scripts[]={
|
||||
script1,
|
||||
script2,
|
||||
script3,
|
||||
script4,
|
||||
script5,
|
||||
script6,
|
||||
script7,
|
||||
script8,
|
||||
};
|
||||
|
||||
void getPGMtext(int seq){
|
||||
strcpy_P(buffer,(char*)pgm_read_word(&(scripts[seq])));
|
||||
}
|
||||
|
||||
void writePGMtext(int seq){
|
||||
getPGMtext(seq);
|
||||
Robot.print(buffer);
|
||||
}
|
||||
|
||||
void writeScript(int seq){
|
||||
writePGMtext(seq);
|
||||
}
|
||||
|
||||
void writeAllScripts(){
|
||||
for(int i=0;i<8;i++){
|
||||
writeScript(i);
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
distance sensor, it's capable of detecting and avoiding
|
||||
obstacles, never bumping into walls again!
|
||||
|
||||
You'll need to attach an untrasonic range finder to TK1.
|
||||
You'll need to attach an untrasonic range finder to M1.
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
@ -21,7 +21,7 @@
|
||||
// include the robot library
|
||||
#include <ArduinoRobot.h>
|
||||
|
||||
int sensorPin = TK1; // pin is used by the sensor
|
||||
int sensorPin = M1; // pin is used by the sensor
|
||||
|
||||
void setup() {
|
||||
// initialize the Robot, SD card, and display
|
||||
|
@ -1,35 +1,15 @@
|
||||
/* 08 Remote Control
|
||||
|
||||
*******************
|
||||
***
|
||||
***This example code is in an experimental state.
|
||||
***You are welcome to try this with your robot,
|
||||
***and no harm will come to it. We will provide a
|
||||
***detailed description of an updated version of this
|
||||
***in a future update
|
||||
***
|
||||
*** For this example to work you need:
|
||||
***
|
||||
*** - download and install the IR-Remote library by Ken Shirriff
|
||||
*** to be found at https://github.com/shirriff/Arduino-IRremote
|
||||
*** - get a Sony remote control
|
||||
***
|
||||
*** This example will be updated soon, come back to the Robot
|
||||
*** page on the Arduino server for updates!!
|
||||
***
|
||||
*******************
|
||||
|
||||
If you connect a IR receiver to the robot,
|
||||
you can control it like you control a TV set.
|
||||
Using a Sony compatiable remote control,
|
||||
map some buttons to different actions.
|
||||
You can make the robot move around without
|
||||
even touching it!
|
||||
you can control it like a RC car.
|
||||
Using the remote control comes with sensor
|
||||
pack, You can make the robot move around
|
||||
without even touching it!
|
||||
|
||||
Circuit:
|
||||
* Arduino Robot
|
||||
* Connect the IRreceiver to TDK2
|
||||
* Sony compatible remote control
|
||||
* Connect the IRreceiver to D2
|
||||
* Remote control from Robot sensor pack
|
||||
|
||||
based on the IRremote library
|
||||
by Ken Shirriff
|
||||
@ -45,79 +25,67 @@
|
||||
|
||||
// include the necessary libraries
|
||||
#include <IRremote.h>
|
||||
#include <IRremoteTools.h>
|
||||
#include <ArduinoRobot.h>
|
||||
|
||||
// Define a few commands from your remote control
|
||||
#define IR_CODE_FORWARD 0x2C9B
|
||||
#define IR_CODE_BACKWARDS 0x6C9B
|
||||
#define IR_CODE_TURN_LEFT 0xD4B8F
|
||||
#define IR_CODE_TURN_RIGHT 0x34B8F
|
||||
#define IR_CODE_FORWARD 284154405
|
||||
#define IR_CODE_BACKWARDS 284113605
|
||||
#define IR_CODE_TURN_LEFT 284129925
|
||||
#define IR_CODE_TURN_RIGHT 284127885
|
||||
#define IR_CODE_CONTINUE -1
|
||||
|
||||
int RECV_PIN = TKD2; // the pin the IR receiver is connected to
|
||||
IRrecv irrecv(RECV_PIN); // an instance of the IR receiver object
|
||||
decode_results results; // container for received IR codes
|
||||
boolean isActing=false; //If the robot is executing command from remote
|
||||
long timer;
|
||||
const long TIME_OUT=150;
|
||||
|
||||
void setup() {
|
||||
// initialize the Robot, SD card, display, and speaker
|
||||
Serial.begin(9600);
|
||||
Robot.begin();
|
||||
Robot.beginTFT();
|
||||
Robot.beginSD();
|
||||
|
||||
// print some text to the screen
|
||||
Robot.stroke(0, 0, 0);
|
||||
Robot.text("Remote Control code:", 5, 5);
|
||||
Robot.text("Command:", 5, 26);
|
||||
irrecv.enableIRIn(); // Start the receiver
|
||||
beginIRremote(); // Start the receiver
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// if there is an IR command, process it
|
||||
if (irrecv.decode(&results)) {
|
||||
if (IRrecived()) {
|
||||
processResult();
|
||||
irrecv.resume(); // resume receiver
|
||||
resumeIRremote(); // resume receiver
|
||||
}
|
||||
|
||||
//If the robot does not receive any command, stop it
|
||||
if(isActing && (millis()-timer>=TIME_OUT)){
|
||||
Robot.motorsStop();
|
||||
isActing=false;
|
||||
}
|
||||
}
|
||||
|
||||
void processResult() {
|
||||
unsigned long res = results.value;
|
||||
// print the value to the screen
|
||||
Robot.debugPrint(res, 5, 15);
|
||||
|
||||
if(res == IR_CODE_FORWARD || res == IR_CODE_BACKWARDS || res == IR_CODE_TURN_LEFT || res == IR_CODE_TURN_RIGHT) {
|
||||
Robot.fill(255, 255, 255);
|
||||
Robot.stroke(255, 255, 255);
|
||||
|
||||
Robot.rect(5, 36, 55, 10);
|
||||
}
|
||||
switch(results.value){
|
||||
unsigned long res = getIRresult();
|
||||
switch(res){
|
||||
case IR_CODE_FORWARD:
|
||||
Robot.stroke(0, 0, 0);
|
||||
Robot.text("Forward", 5, 36);
|
||||
Robot.motorsWrite(255, 255);
|
||||
delay(300);
|
||||
Robot.motorsStop();
|
||||
changeAction(1,1); //Move the robot forward
|
||||
break;
|
||||
case IR_CODE_BACKWARDS:
|
||||
Robot.stroke(0, 0, 0);
|
||||
Robot.text("Backwards", 5, 36);
|
||||
Robot.motorsWrite(-255, -255);
|
||||
delay(300);
|
||||
Robot.motorsStop();
|
||||
changeAction(-1,-1); //Move the robot backwards
|
||||
break;
|
||||
case IR_CODE_TURN_LEFT:
|
||||
Robot.stroke(0, 0, 0);
|
||||
Robot.text("Left", 5, 36);
|
||||
Robot.motorsWrite(-255, 255);
|
||||
delay(100);
|
||||
Robot.motorsStop();
|
||||
changeAction(-0.5,0.5); //Turn the robot left
|
||||
break;
|
||||
case IR_CODE_TURN_RIGHT:
|
||||
Robot.stroke(0, 0, 0);
|
||||
Robot.text("Right", 5, 36);
|
||||
Robot.motorsWrite(255, -255);
|
||||
delay(100);
|
||||
Robot.motorsStop();
|
||||
changeAction(0.5,-0.5); //Turn the robot Right
|
||||
break;
|
||||
case IR_CODE_CONTINUE:
|
||||
timer=millis(); //Continue the last action, reset timer
|
||||
break;
|
||||
}
|
||||
}
|
||||
void changeAction(float directionLeft, float directionRight){
|
||||
Robot.motorsWrite(255*directionLeft, 255*directionRight);
|
||||
timer=millis();
|
||||
isActing=true;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ void setup(){
|
||||
// use this to calibrate the line following algorithm
|
||||
// uncomment one or the other to see the different behaviors of the robot
|
||||
// Robot.lineFollowConfig(11, 5, 50, 10);
|
||||
Robot.lineFollowConfig(14, 9, 50, 10);
|
||||
Robot.lineFollowConfig(11, 7, 60, 5);
|
||||
|
||||
// run the rescue sequence
|
||||
rescueSequence();
|
||||
|
@ -27,15 +27,11 @@ void setup(){
|
||||
//necessary initialization sequence
|
||||
Robot.begin();
|
||||
Robot.beginTFT();
|
||||
Robot.beginSpeaker(32000);
|
||||
Robot.beginSD();
|
||||
|
||||
// show the logos from the SD card
|
||||
Robot.displayLogos();
|
||||
|
||||
// play the music file
|
||||
Robot.playFile("menu.sqm");
|
||||
|
||||
// clear the screen
|
||||
Robot.clearScreen();
|
||||
|
||||
|
@ -5,9 +5,9 @@
|
||||
reads/writes from/to them. Uncomment the different lines inside
|
||||
the loop to test the different possibilities.
|
||||
|
||||
The TK inputs on the Control Board are multiplexed and therefore
|
||||
it is not recommended to use them as outputs. The TKD pins on the
|
||||
Control Board as well as the TK pins on the Motor Board go directly
|
||||
The M inputs on the Control Board are multiplexed and therefore
|
||||
it is not recommended to use them as outputs. The D pins on the
|
||||
Control Board as well as the D pins on the Motor Board go directly
|
||||
to the microcontroller and therefore can be used both as inputs
|
||||
and outputs.
|
||||
|
||||
@ -25,9 +25,9 @@
|
||||
#include <ArduinoRobot.h>
|
||||
|
||||
// use arrays to store the names of the pins to be read
|
||||
uint8_t arr[] = { TK0, TK1, TK2, TK3, TK4, TK5, TK6, TK7 };
|
||||
uint8_t arr2[] = { TKD0, TKD1, TKD2, TKD3, TKD4, TKD5 };
|
||||
uint8_t arr3[] = { B_TK1, B_TK2, B_TK3, B_TK4 };
|
||||
uint8_t arr[] = { M0, M1, M2, M3, M4, M5, M6, M7 };
|
||||
uint8_t arr2[] = { D0, D1, D2, D3, D4, D5 };
|
||||
uint8_t arr3[] = { D7, D8, D9, D10 };
|
||||
|
||||
void setup(){
|
||||
// initialize the robot
|
||||
@ -38,34 +38,34 @@ void setup(){
|
||||
}
|
||||
|
||||
void loop(){
|
||||
// read all the TK inputs at the Motor Board as analog
|
||||
analogReadB_TKs();
|
||||
// read all the D inputs at the Motor Board as analog
|
||||
//analogReadB_Ds();
|
||||
|
||||
// read all the TK inputs at the Motor Board as digital
|
||||
//digitalReadB_TKs();
|
||||
// read all the D inputs at the Motor Board as digital
|
||||
//digitalReadB_Ds();
|
||||
|
||||
// read all the TK inputs at the Control Board as analog
|
||||
//analogReadTKs();
|
||||
// read all the M inputs at the Control Board as analog
|
||||
//analogReadMs();
|
||||
|
||||
// read all the TK inputs at the Control Board as digital
|
||||
//digitalReadTKs();
|
||||
// read all the M inputs at the Control Board as digital
|
||||
//digitalReadMs();
|
||||
|
||||
// read all the TKD inputs at the Control Board as analog
|
||||
//analogReadTKDs();
|
||||
// read all the D inputs at the Control Board as analog
|
||||
analogReadT_Ds();
|
||||
|
||||
// read all the TKD inputs at the Control Board as digital
|
||||
//digitalReadTKDs();
|
||||
// read all the D inputs at the Control Board as digital
|
||||
//digitalReadT_Ds();
|
||||
|
||||
// write all the TK outputs at the Motor Board as digital
|
||||
//digitalWriteB_TKs();
|
||||
// write all the D outputs at the Motor Board as digital
|
||||
//digitalWriteB_Ds();
|
||||
|
||||
// write all the TKD outputs at the Control Board as digital
|
||||
//digitalWriteTKDs();
|
||||
delay(5);
|
||||
// write all the D outputs at the Control Board as digital
|
||||
//digitalWriteT_Ds();
|
||||
delay(40);
|
||||
}
|
||||
|
||||
// read all TK inputs on the Control Board as analog inputs
|
||||
void analogReadTKs() {
|
||||
// read all M inputs on the Control Board as analog inputs
|
||||
void analogReadMs() {
|
||||
for(int i=0;i<8;i++) {
|
||||
Serial.print(Robot.analogRead(arr[i]));
|
||||
Serial.print(",");
|
||||
@ -73,8 +73,8 @@ void analogReadTKs() {
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
// read all TK inputs on the Control Board as digital inputs
|
||||
void digitalReadTKs() {
|
||||
// read all M inputs on the Control Board as digital inputs
|
||||
void digitalReadMs() {
|
||||
for(int i=0;i<8;i++) {
|
||||
Serial.print(Robot.digitalRead(arr[i]));
|
||||
Serial.print(",");
|
||||
@ -82,8 +82,8 @@ void digitalReadTKs() {
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
// read all TKD inputs on the Control Board as analog inputs
|
||||
void analogReadTKDs() {
|
||||
// read all D inputs on the Control Board as analog inputs
|
||||
void analogReadT_Ds() {
|
||||
for(int i=0; i<6; i++) {
|
||||
Serial.print(Robot.analogRead(arr2[i]));
|
||||
Serial.print(",");
|
||||
@ -91,8 +91,8 @@ void analogReadTKDs() {
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
// read all TKD inputs on the Control Board as digital inputs
|
||||
void digitalReadTKDs() {
|
||||
// read all D inputs on the Control Board as digital inputs
|
||||
void digitalReadT_Ds() {
|
||||
for(int i=0; i<6; i++) {
|
||||
Serial.print(Robot.digitalRead(arr2[i]));
|
||||
Serial.print(",");
|
||||
@ -100,8 +100,8 @@ void digitalReadTKDs() {
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
// write all TKD outputs on the Control Board as digital outputs
|
||||
void digitalWriteTKDs() {
|
||||
// write all D outputs on the Control Board as digital outputs
|
||||
void digitalWriteT_Ds() {
|
||||
// turn all the pins on
|
||||
for(int i=0; i<6; i++) {
|
||||
Robot.digitalWrite(arr2[i], HIGH);
|
||||
@ -115,8 +115,8 @@ void digitalWriteTKDs() {
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// write all TK outputs on the Motor Board as digital outputs
|
||||
void digitalWriteB_TKs() {
|
||||
// write all D outputs on the Motor Board as digital outputs
|
||||
void digitalWriteB_Ds() {
|
||||
// turn all the pins on
|
||||
for(int i=0; i<4; i++) {
|
||||
Robot.digitalWrite(arr3[i], HIGH);
|
||||
@ -130,8 +130,8 @@ void digitalWriteB_TKs() {
|
||||
delay(500);
|
||||
}
|
||||
|
||||
// read all TK inputs on the Motor Board as analog inputs
|
||||
void analogReadB_TKs() {
|
||||
// read all D inputs on the Motor Board as analog inputs
|
||||
void analogReadB_Ds() {
|
||||
for(int i=0; i<4; i++) {
|
||||
Serial.print(Robot.analogRead(arr3[i]));
|
||||
Serial.print(",");
|
||||
@ -139,8 +139,8 @@ void analogReadB_TKs() {
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
// read all TKD inputs on the Motor Board as digital inputs
|
||||
void digitalReadB_TKs() {
|
||||
// read all D inputs on the Motor Board as digital inputs
|
||||
void digitalReadB_Ds() {
|
||||
for(int i=0; i<4; i++) {
|
||||
Serial.print(Robot.digitalRead(arr3[i]));
|
||||
Serial.print(",");
|
||||
|
@ -23,7 +23,7 @@ void setup() {
|
||||
Robot.begin();
|
||||
|
||||
// initialize the robot's screen
|
||||
Robot.beginLCD();
|
||||
Robot.beginTFT();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@ -31,14 +31,14 @@ void loop() {
|
||||
value=Robot.analogRead(TK4);
|
||||
|
||||
// write the sensor value on the screen
|
||||
Robot.fill(0, 255, 0);
|
||||
Robot.stroke(0, 255, 0);
|
||||
Robot.textSize(1);
|
||||
Robot.text(value, 0, 0);
|
||||
|
||||
delay(500);
|
||||
|
||||
// erase the previous text on the screen
|
||||
Robot.fill(255, 255, 255);
|
||||
Robot.stroke(255, 255, 255);
|
||||
Robot.textSize(1);
|
||||
Robot.text(value, 0, 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user