convert_KeilToMbed
Dependencies: DigitDisplay Motor PID mbed millis
Fork of DagonFly__RoadToJapan_15Mei_Ultimate by
Diff: main.cpp
- Revision:
- 42:6caf8bd5abbc
- Parent:
- 41:336a19289c2d
- Child:
- 43:3807a95aa284
--- a/main.cpp Sat Feb 18 11:33:00 2017 +0000 +++ b/main.cpp Mon Feb 20 13:29:52 2017 +0000 @@ -44,6 +44,8 @@ #include "encoderKRAI.h" #include "millis.h" #include "Ping.h" +#include "DigitDisplay.h" + /***********************************************/ /* Konstanta dan Variabel */ /***********************************************/ @@ -89,6 +91,7 @@ unsigned long int currentMillis2; unsigned long int previousMillis3 = 0; // Pneumatik unsigned long int previousMillis4 = 0; // Ping +unsigned long int previousMillis5 = 0; // Display /* Variabel Stick */ //Logic untuk masuk aktuator @@ -141,6 +144,9 @@ /*deklarasi PING ultrasonic*/ Ping pingAtas(PC_9); +/*Deklarasi Display*/ +DigitDisplay display (D15, D4); + /****************************************************/ /* Deklarasi Fungsi dan Procedure */ /****************************************************/ @@ -241,13 +247,13 @@ if (target_rpm>maxRPM-2){ target_rpm = maxRPM-2; } - if (target_rpm<minRPM+8){ + if (target_rpm<minRPM){ target_rpm = minRPM; } if (target_rpm2>maxRPM){ target_rpm2 = maxRPM; } - if (target_rpm2<minRPM+2+8){ + if (target_rpm2<minRPM+2){ target_rpm2 = minRPM+2; } } @@ -515,5 +521,15 @@ { joystick.idle(); } + + if(millis() - previousMillis5 >= 400){ + display.write(0,((int) target_rpm2-2) / 10); + display.write(1,((int)target_rpm2-2) % 10); + display.write(2, (int)target_rpm2 / 10); + display.write(3, (int)target_rpm2 % 10); + display.setColon(true); + + previousMillis5 = millis(); + } } } \ No newline at end of file