Download libraries/Robot_Motor/src/ArduinoRobotMotorBoard.h from Beifengdo/Arduino-Development: direct link, hf CLI and curl.
- Browser
- Download file 3.72 kB
-
https://huggingface.co/datasets/Beifengdo/Arduino-Development/resolve/main/libraries/Robot_Motor/src/ArduinoRobotMotorBoard.h
- Command line
-
hf download hf://datasets/Beifengdo/Arduino-Development/libraries/Robot_Motor/src/ArduinoRobotMotorBoard.h
-
curl -L -o ArduinoRobotMotorBoard.h https://huggingface.co/datasets/Beifengdo/Arduino-Development/resolve/main/libraries/Robot_Motor/src/ArduinoRobotMotorBoard.h
3.72 kB
| /* | |
| Copyright (c) 2012 Arduino LLC. All right reserved. | |
| This library is free software; you can redistribute it and/or | |
| modify it under the terms of the GNU Lesser General Public | |
| License as published by the Free Software Foundation; either | |
| version 2.1 of the License, or (at your option) any later version. | |
| This library is distributed in the hope that it will be useful, | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| Lesser General Public License for more details. | |
| You should have received a copy of the GNU Lesser General Public | |
| License along with this library; if not, write to the Free Software | |
| Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
| */ | |
| //Command code | |
| //component codename | |
| //motor board modes | |
| //bottom TKs, just for communication purpose | |
| /* | |
| A message structure will be: | |
| switch mode (2): | |
| byte COMMAND_SWITCH_MODE, byte mode | |
| run (5): | |
| byte COMMAND_RUN, int speedL, int speedR | |
| analogWrite (3): | |
| byte COMMAND_ANALOG_WRITE, byte codename, byte value; | |
| digitalWrite (3): | |
| byte COMMAND_DIGITAL_WRITE, byte codename, byte value; | |
| analogRead (2): | |
| byte COMMAND_ANALOG_READ, byte codename; | |
| analogRead _return_ (4): | |
| byte COMMAND_ANALOG_READ_RE, byte codename, int value; | |
| digitalRead (2): | |
| byte COMMAND_DIGITAL_READ, byte codename; | |
| digitalRead _return_ (4): | |
| byte COMMAND_DIGITAL_READ_RE, byte codename, int value; | |
| read IR (1): | |
| byte COMMAND_READ_IR; | |
| read IR _return_ (9): | |
| byte COMMAND_READ_IR_RE, int valueA, int valueB, int valueC, int valueD; | |
| */ | |
| class RobotMotorBoard:public LineFollow{ | |
| public: | |
| RobotMotorBoard(); | |
| void begin(); | |
| void process(); | |
| void parseCommand(); | |
| int IRread(uint8_t num); | |
| void setMode(uint8_t mode); | |
| void pauseMode(bool onOff); | |
| void motorsWrite(int speedL, int speedR); | |
| void motorsWritePct(int speedLpct, int speedRpct);//write motor values in percentage | |
| void motorsStop(); | |
| private: | |
| float motorAdjustment;//-1.0 ~ 1.0, whether left is lowered or right is lowered | |
| //convert codename to actual pins | |
| uint8_t parseCodename(uint8_t codename); | |
| uint8_t codenameToAPin(uint8_t codename); | |
| void stopCurrentActions(); | |
| //void sendCommand(byte command,byte codename,int value); | |
| void _analogWrite(uint8_t codename, int value); | |
| 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(); | |
| void _refreshMotorAdjustment(); | |
| Multiplexer IRs; | |
| uint8_t mode; | |
| uint8_t isPaused; | |
| EasyTransfer2 messageIn; | |
| EasyTransfer2 messageOut; | |
| //Line Following | |
| void reportActionDone(); | |
| }; | |
| extern RobotMotorBoard RobotMotor; | |