MOREbot Library  v1.1.1
MOREbot.h
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 M;
17 
18  public:
19 
23  motor(int MX);
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:
53 
58  ultrasonic(int trig, int echo);
59 
63  float readDistance();
64 };
65 
68 class bluetooth{
69  private:
71  int _rx;
72 
74  int _tx;
75 
77  int speed = -1;
78 
80  int button = -1;
81 
83  int slider = -1;
84 
86  int sliderValue = -1;
87 
89  float direction = -1;
90 
92  int modeButton = 2;
93 
95  String _name = "", text;
96 
98  bool mode = false;
99 
101  SoftwareSerial ble;
102 
103  public:
108  bluetooth(int rx, int tx);
109 
115  bluetooth(String name, int rx, int tx);
116 
118  void setup();
119 
121  void processData();
122 
126  bool getModeButton();
127 
131  int getSpeed();
132 
136  float getDirection();
137 
141  int getButton();
142 
146  int getSlider();
147 
151  int getSliderValue();
152 
156  String getText();
157 };
158 
159 
160 class MOREbot{
161  private:
162 
164  motor _LM;
165 
167  motor _RM;
168 
170  ultrasonic us;
171 
173  bluetooth ble;
174 
176  String _name;
177 
178  public:
179 
184  MOREbot(int LM, int RM);
185 
192  MOREbot(int LM, int RM, int trig, int echo);
193 
203  MOREbot(String name, int LM, int RM, int trig, int echo, int rx, int tx);
204 
206  void setup();
207 
213 
219 
225 
231 
235  void forward(int speed);
236 
240  void backward(int speed);
241 
245  void left(int speed);
246 
250  void right(int speed);
251 
253  void stop();
254 
258  float readDistance();
259 
260 
262  void btControl();
263 
265  void bounce();
266 };
267 #endif
Bluetooth BLE class.
Definition: MOREbot.h:68
float getDirection()
Call function for the last direction recieved.
Definition: MOREbot.cpp:149
void btControl()
Operation function for full control from a BLE connection.
Definition: MOREbot.cpp:225
void bounce()
Operation function for full control to maintain distance to object in front.
Definition: MOREbot.cpp:242
Definition: MOREbot.h:160
void setup()
Checks that the module is responding and attempts to rename it if a name was given during constructio...
Definition: MOREbot.cpp:80
void stop()
Drive function for MOREbot to stop.
Definition: MOREbot.cpp:216
void right(int speed)
Drive function for MOREbot to drive right.
Definition: MOREbot.cpp:211
String getText()
Call function for the last text recieved.
Definition: MOREbot.cpp:165
int getButton()
Call function for the last button id recieved.
Definition: MOREbot.cpp:153
bluetooth(int rx, int tx)
Basic Bluetooth constructor.
Definition: MOREbot.cpp:69
ultrasonic(int trig, int echo)
Ultrasonic constructor.
Definition: MOREbot.cpp:40
bluetooth getBluetooth()
Call function for the bluetooth object.
Definition: MOREbot.cpp:192
float readDistance()
Function to get distance from the Ultrasonic.
Definition: MOREbot.cpp:47
motor getLeftMotor()
Call function for the left motor motor object.
Definition: MOREbot.cpp:180
void processData()
Reads the BLE stream for any data that the module has recieved.
Definition: MOREbot.cpp:89
void backward(int speed)
Drive function for MOREbot to drive backward.
Definition: MOREbot.cpp:201
ultrasonic getUltrasonic()
Call function for the ultrasonic object.
Definition: MOREbot.cpp:188
bool getModeButton()
Call function for the current mode status, inverts when the mode button id (2) is recieved.
Definition: MOREbot.cpp:141
void setup()
Robot setup.
Definition: MOREbot.cpp:175
void stop()
Stop motor function.
Definition: MOREbot.cpp:35
float readDistance()
Distance sensing function.
Definition: MOREbot.cpp:221
void counterClockwise(int speed)
counterClockwise motor function.
Definition: MOREbot.cpp:13
void forward(int speed)
Drive function for MOREbot to drive forward.
Definition: MOREbot.cpp:196
void clockwise(int speed)
Backward motor function.
Definition: MOREbot.cpp:24
Motor class.
Definition: MOREbot.h:11
int getSliderValue()
Call function for the last slider value recieved.
Definition: MOREbot.cpp:161
int getSlider()
Call function for the last slider id recieved.
Definition: MOREbot.cpp:157
motor getRightMotor()
Call function for the right motor motor object.
Definition: MOREbot.cpp:184
motor(int MX)
Motor constructor.
Definition: MOREbot.cpp:9
void left(int speed)
Drive function for MOREbot to drive left.
Definition: MOREbot.cpp:206
int getSpeed()
Call function for sthe last speed recieved.
Definition: MOREbot.cpp:145
Ultrasonic class.
Definition: MOREbot.h:43
MOREbot(int LM, int RM)
Two motor MOREbot constructor.
Definition: MOREbot.cpp:169