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: LSM9DS1_Library2 MotorV2 SRF05 Tracker2 mbed nRF24L01P
Fork of DUMP_TRUCK_SPR2017 by
Revision 5:dc4cf6cc24b3, committed 2017-02-07
- Comitter:
- simplyellow
- Date:
- Tue Feb 07 21:01:20 2017 +0000
- Parent:
- 4:2f1a0f628875
- Child:
- 6:5cc6a9b6f60e
- Child:
- 9:5a35e2a28a47
- Commit message:
- Dump Truck
Changed in this revision
--- a/DumpTruck.cpp Tue Nov 29 20:04:34 2016 +0000
+++ b/DumpTruck.cpp Tue Feb 07 21:01:20 2017 +0000
@@ -1,21 +1,14 @@
#include "DumpTruck.h"
-#include "stdlib.h"
-#include "QEI.h"
+/*#include "stdlib.h"
#include "stdio.h"
-#include "string.h"
+#include "string.h"*/
-
-Serial pc(USBTX, USBRX);
+//Serial pc(USBTX, USBRX);
DumpTruck::DumpTruck(int truckId) : truckNumber(truckId) {
truckNumber = truckId;
}
-QEI wheel (p15, p16, NC, 128, QEI::X4_ENCODING); //orange, yellow
-float pulseCount; //number of pulses detected by encoder
-float encoding = 2; //X2
-float d = 13.25; //inches of circumference
-float distance;
PwmOut DrivePin(p24);
DigitalOut DirPin(p30);
float travelled;
@@ -250,5 +243,7 @@
// float input = AnalogIn(x); // data from potentiometer
// return input;
// }
-//
+//
+*/
+
--- a/DumpTruck.h Tue Nov 29 20:04:34 2016 +0000
+++ b/DumpTruck.h Tue Feb 07 21:01:20 2017 +0000
@@ -37,5 +37,4 @@
//bool isCalibrated;// returns 0 and 1 to check if the robot has been calibrated
};
-
-#endif
\ No newline at end of file
+#endif
--- a/QEI.lib Tue Nov 29 20:04:34 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/aberk/code/QEI/#5c2ad81551aa
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tracker.lib Tue Feb 07 21:01:20 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/Terrabots/code/Tracker/#eb8680da1721
--- a/main.cpp Tue Nov 29 20:04:34 2016 +0000
+++ b/main.cpp Tue Feb 07 21:01:20 2017 +0000
@@ -1,11 +1,71 @@
#include "mbed.h"
-#include "DumpTruck.h"
-DigitalOut myled(LED1);
+// Define buttons
+InterruptIn button_red(p5);
+InterruptIn button_green(p6);
+InterruptIn button_blue(p7);
+
+// Define LED colors
+PwmOut led_red(p21);
+PwmOut led_green(p22);
+PwmOut led_blue(p23);
+// Interrupt Service Routine to increment the red color
+void inc_red() {
-int main() {
- DumpTruck foo(1);
- foo.drive();
+ float pwm;
+
+ // Read in current PWM value and increment it
+ pwm = led_red.read();
+ pwm += 0.1f;
+ if (pwm > 1.0f) {
+ pwm = 0.0f;
+ }
+ led_red.write(pwm);
}
+// Interrupt Service Routine to increment the green color
+void inc_green() {
+
+ float pwm;
+
+ // Read in current PWM value and increment it
+ pwm = led_green.read();
+ pwm += 0.1f;
+ if (pwm > 1.0f) {
+ pwm = 0.0f;
+ }
+ led_green.write(pwm);
+}
+
+// Interrupt Service Routine to increment the blue color
+void inc_blue() {
+
+ float pwm;
+
+ // Read in current PWM value and increment it
+ pwm = led_blue.read();
+ pwm += 0.1f;
+ if (pwm > 1.0f) {
+ pwm = 0.0f;
+ }
+ led_blue.write(pwm);
+}
+
+// Main loop
+int main() {
+
+ // Initialize all LED colors as off
+ led_red.write(0.0f);
+ led_green.write(0.0f);
+ led_blue.write(0.0f);
+
+ // Define three interrupts - one for each color
+ button_red.fall(&inc_red);
+ button_green.fall(&inc_green);
+ button_blue.fall(&inc_blue);
+
+ // Do nothing! We wait for an interrupt to happen
+ while(1) {
+ }
+}
