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: USBHost USBHostXpad mbed-rtos mbed
Diff: main.cpp
- Revision:
- 6:e905d3ec8545
- Parent:
- 4:868a07a5496f
- Child:
- 7:c6781a58f666
--- a/main.cpp Wed Nov 26 23:44:10 2014 +0000
+++ b/main.cpp Fri Dec 05 23:25:35 2014 +0000
@@ -17,6 +17,7 @@
//Speaker speaker(p18); // the pin must be the AnalogOut pin - p18
DigitalOut led(LED1);
DigitalOut led4(LED4);
+DigitalOut fire(p8);
Mutex m;
@@ -108,7 +109,7 @@
float x = -1.0 * xpadNormalizeAnalog(controlState.analogLeftX);
//float x = -1.0 * y / abs(y) * xpadNormalizeAnalog(controlState.analogLeftX);
- if(ir > 0.75){ // on collision, stop tank
+ if(ir > 0.65){ // on collision, stop tank
controller.rumble(255,255);
tank.SetMotors(0,0);
}else{
@@ -117,9 +118,11 @@
if(controlState.triggerRight > 0x80){ //shoot
controller.rumble(255,255);
led = 1;
+ fire = 1;
}else{
controller.rumble(0,0);
led = 0;
+ fire = 0;
}
if( sqrt(x*x + y*y) > 0.25 ) {
@@ -139,7 +142,10 @@
}
}
+int start = 0;
+
int main() {
+ if(start == 0) {tank.SetMotors(0,0); fire = 0; start++;}
led = 1;
led4 = 1;
@@ -161,7 +167,8 @@
while(1){
led4 = !led4;
- Thread::wait(500);
+ // fire = !fire;
+ Thread::wait(5000);
}
}
