MOREbot_Library  1.3.2
Library to control the MOREbot base robot
MOREbot.h
Go to the documentation of this file.
1 #ifndef MOREbot_h
2 #define MOREbot_h
3 
4 #include "Arduino.h"
5 #include "Wire.h"
6 #include <Adafruit_MotorShield.h>
7 #include <SoftwareSerial.h>
8 
11 class motor{
12 
13  private:
14 
16  Adafruit_DCMotor _motor;
17 
18  public:
19 
23  motor(int motorPort);
24 
29  void counterClockwise(int speed);
30 
35  void clockwise(int speed);
36 
38  void stop();
39 };
40 
43 class ultrasonic{
44  private:
45 
47  int _trig;
48 
50  int _echo;
51 
52  public:
57  ultrasonic(int trig, int echo);
58 
62  float readDistance();
63 };
64 
67 class bluetooth{
68  private:
70  int _rx;
71 
73  int _tx;
74 
76  int speed = -1;
77 
79  int button = -1;
80 
82  int slider = -1;
83 
85  int sliderValue = -1;
86 
88  float direction = -1;
89 
91  int modeButton = 2;
92 
94  String _name = "", text;
95 
97  bool mode = false;
98 
100  SoftwareSerial ble;
101 
102  public:
107  bluetooth(int rx, int tx);
108 
114  bluetooth(String name, int rx, int tx);
115 
117  void setup();
118 
120  void processData();
121 
125  bool getModeButton();
126 
130  int getSpeed();
131 
135  float getDirection();
136 
140  int getButton();
141 
145  int getSlider();
146 
150  int getSliderValue();
151 
155  String getText();
156 };
157 
158 
159 class MOREbot{
160  private:
161 
163  motor _LM;
164 
166  motor _RM;
167 
169  ultrasonic us;
170 
172  bluetooth ble;
173 
175  String _name;
176 
177  public:
178 
183  MOREbot(int LM, int RM);
184 
190  MOREbot(String name, int LM, int RM);
191 
198  MOREbot(int LM, int RM, int trig, int echo);
199 
207  MOREbot(String name, int LM, int RM, int trig, int echo);
208 
218  MOREbot(String name, int LM, int RM, int trig, int echo, int rx, int tx);
219 
221  void setup();
222 
228 
234 
240 
246 
250  void forward(int speed);
251 
255  void backward(int speed);
256 
260  void left(int speed);
261 
265  void right(int speed);
266 
268  void stop();
269 
273  float readDistance();
274 
275 
277  void btControl();
278 
283  void bounce(float targetDistance, float threshold);
284 };
285 #endif
Definition: MOREbot.h:67
float getDirection()
Definition: MOREbot.cpp:242
void btControl()
Definition: MOREbot.cpp:350
Definition: MOREbot.h:159
void setup()
Definition: MOREbot.cpp:129
motor(int motorPort)
Definition: MOREbot.cpp:9
void stop()
Definition: MOREbot.cpp:333
void right(int speed)
Definition: MOREbot.cpp:327
String getText()
Definition: MOREbot.cpp:262
int getButton()
Definition: MOREbot.cpp:247
bluetooth(int rx, int tx)
Definition: MOREbot.cpp:106
ultrasonic(int trig, int echo)
Definition: MOREbot.cpp:59
bluetooth getBluetooth()
Definition: MOREbot.cpp:304
float readDistance()
Definition: MOREbot.cpp:72
motor getLeftMotor()
Definition: MOREbot.cpp:289
void processData()
Definition: MOREbot.cpp:143
void backward(int speed)
Definition: MOREbot.cpp:315
ultrasonic getUltrasonic()
Definition: MOREbot.cpp:299
bool getModeButton()
Definition: MOREbot.cpp:232
void setup()
Definition: MOREbot.cpp:283
void stop()
Definition: MOREbot.cpp:53
float readDistance()
Definition: MOREbot.cpp:339
void counterClockwise(int speed)
Definition: MOREbot.cpp:17
void forward(int speed)
Definition: MOREbot.cpp:309
void clockwise(int speed)
Definition: MOREbot.cpp:35
Definition: MOREbot.h:11
int getSliderValue()
Definition: MOREbot.cpp:257
int getSlider()
Definition: MOREbot.cpp:252
motor getRightMotor()
Definition: MOREbot.cpp:294
void left(int speed)
Definition: MOREbot.cpp:321
int getSpeed()
Definition: MOREbot.cpp:237
Definition: MOREbot.h:43
MOREbot(int LM, int RM)
Definition: MOREbot.cpp:267
void bounce(float targetDistance, float threshold)
Definition: MOREbot.cpp:378