Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 6:6865930c1135, committed 2022-10-04
- Comitter:
- uld
- Date:
- Tue Oct 04 12:09:19 2022 +0000
- Parent:
- 5:dbd32cb3650a
- Child:
- 7:ac88c8e35048
- Commit message:
- ADD first draft of battery test code
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Oct 04 11:58:03 2022 +0000
+++ b/main.cpp Tue Oct 04 12:09:19 2022 +0000
@@ -18,10 +18,9 @@
int main() {
-
m3pi.sensor_auto_calibrate();
- /*Variable initiation*/
+ /*Base program Variable initiation*/
float right;
float left;
float current_pos_of_line = 0.0;
@@ -29,21 +28,48 @@
float derivative,proportional,integral = 0;
float power;
float speed = MAX;
-
+
+ /*Team 7 Variabels*/
float batVol = m3pi.battery(); //Storing battery voltage in variable
float potVol = m3pi.pot_voltage(); //Storing pot voltage
+ int gotopit = 0; // variabel storing weather or not the robot is heading to pit
- /*Printing test*/
+ /*Digital outs*/
+ DigitalOut led1(LED1);
+
+
+ /*Printing secret cat mission*/
+ m3pi.cls();
+
+ m3pi.locate(0,0);
+ m3pi.printf("eliminate");
+ m3pi.locate(0,1);
+ m3pi.printf("all cats");
+ wait(200.0);
+
m3pi.cls();
m3pi.locate(0,0);
-
m3pi.printf("%f.3 ",batVol);
m3pi.locate(0,1);
m3pi.printf("%f.3 ",b);
- wait(2.0);
+ wait(200.0);
+ m3pi.cls();
+ /*Inital state*/
+ led1 = 0; // Turn off led 1 on the embed
+
while (1) {
-
+
+ /* Test the batteri voltage if the robot is not headed for pit */
+ if (gotopit == 0) {
+ /*Sets the battery voltage to the current voltage of the battery*/
+ batVol = battery ();
+
+ if batteryVoltage <= BATVOLTRESHOLD (){
+ gotopit = 1; // set goto pit condition
+ led1 = 1; // trun on Led 1
+ }
+
// Get the position of the line.
current_pos_of_line = m3pi.line_position();
proportional = current_pos_of_line;
@@ -78,6 +104,8 @@
// set speed
m3pi.left_motor(left);
m3pi.right_motor(right);
+
+
}
}
\ No newline at end of file