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.
Diff: main.cpp
- Revision:
- 0:f510a9c32a2c
- Child:
- 1:e8fcbd118f4d
diff -r 000000000000 -r f510a9c32a2c main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Jun 11 08:10:57 2017 +0000
@@ -0,0 +1,86 @@
+#include "mbed.h"
+#include "JoystickPS3.h"
+#include "Motor.h"
+
+const float pwmPowerUp = 1.0;
+const float pwmPowerDown = -1.0;
+
+int case_joy;
+bool isLauncher = false;
+bool isReload = false;
+bool ReloadOn = false;
+bool flag_Pneu = false;
+bool flag_paku = false;
+
+bool ready = false;
+
+int case_joystick();
+
+joysticknucleo joystick(PA_0,PA_1);
+Serial pc(USBTX,USBRX);
+
+//DigitalIn infraAtas(PC_9, PullUp);
+DigitalIn limitAtas(PA_9, PullUp);
+DigitalIn limitBawah(PC_7, PullUp);
+DigitalIn limitKiri(PA_7, PullUp);
+DigitalIn limitTengah(PB_7, PullUp);
+DigitalIn limitKanan(PB_9, PullUp);
+
+Motor powerScrew(PB_10, PB_14, PB_13); // pwm, fwd, rev
+
+int case_joystick()
+{
+ int caseJoystick;
+ if ((joystick.lingkaran_click)&&(!joystick.kotak_click)) {
+ // Power Screw Up
+ caseJoystick = 11;
+ }
+ else if ((joystick.kotak_click)&&(!joystick.lingkaran_click)) {
+ // Power Screw Down
+ caseJoystick = 12;
+ }
+ return(caseJoystick);
+}
+
+void aktuator()
+{
+ switch (case_joy)
+ {
+ case (11) :
+ {
+ // Power Screw Up
+ ReloadOn = !ReloadOn;
+ isReload = false;
+ break;
+ }
+ case (12) :
+ {
+ // Power Screw Down
+ ReloadOn = !ReloadOn;
+ isReload = true;
+ break;
+ }
+ }
+}
+
+void reloader()
+{
+ if(ReloadOn){
+ if(isReload){
+ powerScrew.speed(pwmPowerDown);
+ //pc.printf("%.2f\n", jarak_ping);
+ if(!limitBawah){
+ isReload = false;
+ ReloadOn = false;
+ }
+ }
+ else if(!limitAtas){
+ isReload = true;
+ powerScrew.speed(pwmPowerUp);
+ }
+ }
+ else{
+ powerScrew.brake(1);
+ }
+}
+
\ No newline at end of file