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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 8:eefbd3880d28
- Parent:
- 7:38def1917030
- Child:
- 9:92895704e1a4
- Child:
- 12:2847b345b5cf
diff -r 38def1917030 -r eefbd3880d28 main.cpp
--- a/main.cpp Wed Mar 11 23:42:10 2015 +0000
+++ b/main.cpp Thu Mar 12 12:18:25 2015 +0000
@@ -16,6 +16,10 @@
//LED to test
DigitalOut led(LED_RED);
+//Hall Effect Sensors
+InterruptIn hall_l (PTA1); //Hall Effect Sensor Output RobotLeft
+InterruptIn hall_r (PTA2); //Hall Effect Sensor Output RobotRight
+float time1_l, time2_l, time3_l, time1_r, time2_r, time3_r;
//Bluetooth Module to debug
Serial blue(PTC4,PTC3);
@@ -91,9 +95,40 @@
}
}
}
+timer h_r, h_l;
+float hall_rt1, hall_lt1, hall_rt2, hall_lt2//hall right time & left time
+int h_f_r, h_f_l //hallflagright and left
+void hallr() //this just reading the various times.
+{
+ if (h_f_r==2) {
+ start.h_r();
+ } else if(h_f_r == 1) {
+ hall_rt1 = read.h_r();
+ h_f_r = 0;
+ } else if (h_f_l == 0) {
+ hall_rt2 = read.h_r();
+ h_f_r = 1;
+ }
+
+}
+void halll()
+{
+
+
+}
int main()
{
+ h_f_r = 2;
+ h_f_l = 2;
+ //attaching hall_r and hall_r so that it calls hall() on a rising and falling edge
+ hall_r.rise(&hallr());
+ hall_r.fall(&hallr());
+
+ hall_l.rise(&halll());
+ hall_l.fall(&halll());
//Set PWM frequency to 1000Hz
+
+
motor_l.period( 1.0f / (float) PWM_FREQ);
motor_r.period( 1.0f / (float) PWM_FREQ);
//Initialise direction to nothing.
@@ -104,6 +139,13 @@
int direction = 0x11;
char rem_dir[2]; //remote_direction
+
+
+
+
+
+ /*BLUETOOTH TEST
+
while(1) {
@@ -150,9 +192,9 @@
angle = input;
*/
- //set_direction(direction, speed, angle);
-
- }
+ //set_direction(direction, speed, angle);
+
+ //}
/* //Also Working Demo
wait(2);