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:
@ -230,16 +230,20 @@ void RobotMotorBoard::_analogRead(uint8_t codename){
|
||||
messageOut.sendData();
|
||||
}
|
||||
int RobotMotorBoard::IRread(uint8_t num){
|
||||
IRs.selectPin(num-1); //To make consistant with the pins labeled on the board
|
||||
return _IRread(num-1); //To make consistant with the pins labeled on the board
|
||||
}
|
||||
|
||||
int RobotMotorBoard::_IRread(uint8_t num){
|
||||
IRs.selectPin(num);
|
||||
return IRs.getAnalogValue();
|
||||
}
|
||||
|
||||
|
||||
void RobotMotorBoard::_readIR(){
|
||||
//Serial.println("readIR");
|
||||
int value;
|
||||
messageOut.writeByte(COMMAND_READ_IR_RE);
|
||||
for(int i=1;i<6;i++){
|
||||
value=IRread(i);
|
||||
for(int i=0;i<5;i++){
|
||||
value=_IRread(i);
|
||||
messageOut.writeInt(value);
|
||||
}
|
||||
messageOut.sendData();
|
||||
|
@ -105,6 +105,7 @@ class RobotMotorBoard:public LineFollow{
|
||||
void _digitalWrite(uint8_t codename, bool value);
|
||||
void _analogRead(uint8_t codename);
|
||||
void _digitalRead(uint8_t codename);
|
||||
int _IRread(uint8_t num);
|
||||
void _readIR();
|
||||
void _readTrim();
|
||||
|
||||
|
@ -19,7 +19,7 @@ class LineFollow{
|
||||
//virtual void motorsWrite(int speedL, int speedR)=0;
|
||||
virtual void motorsWritePct(int speedLpct, int speedRpct)=0;
|
||||
virtual void motorsStop()=0;
|
||||
virtual int IRread(uint8_t num)=0;
|
||||
virtual int _IRread(uint8_t num)=0;
|
||||
protected:
|
||||
virtual void reportActionDone()=0;
|
||||
|
||||
|
@ -19,7 +19,7 @@ void setup(){
|
||||
void loop(){
|
||||
bar=String(""); // empty the string
|
||||
// read the sensors and add them to the string
|
||||
bar=bar+RobotMotor.readIR(0)+' '+RobotMotor.readIR(1)+' '+RobotMotor.readIR(2)+' '+RobotMotor.readIR(3)+' '+RobotMotor.readIR(4);
|
||||
bar=bar+RobotMotor.IRread(1)+' '+RobotMotor.IRread(2)+' '+RobotMotor.IRread(3)+' '+RobotMotor.IRread(4)+' '+RobotMotor.IRread(5);
|
||||
// print out the values
|
||||
Serial.println(bar);
|
||||
delay(100);
|
||||
|
@ -79,7 +79,7 @@ void LineFollow::calibIRs(){
|
||||
void LineFollow::runLineFollow(){
|
||||
for(int count=0; count<5; count++)
|
||||
{
|
||||
lectura_sensor[count]=map(IRread(count),sensor_negro[count],sensor_blanco[count],0,127);
|
||||
lectura_sensor[count]=map(_IRread(count),sensor_negro[count],sensor_blanco[count],0,127);
|
||||
acu+=lectura_sensor[count];
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ void LineFollow::ajusta_niveles()
|
||||
int lectura=0;
|
||||
|
||||
for(int count=0; count<5; count++){
|
||||
lectura=IRread(count);
|
||||
lectura=_IRread(count);
|
||||
|
||||
if (lectura > sensor_blanco[count])
|
||||
sensor_blanco[count]=lectura;
|
||||
|
Reference in New Issue
Block a user