ping + display on

Dependencies:   DigitDisplay Motor PID Ping mbed millis

Fork of MainProgram_BaseBaru_20Feb by KRAI 2017

Files at this revision

API Documentation at this revision

Comitter:
franshendri
Date:
Mon Feb 20 13:29:52 2017 +0000
Parent:
41:336a19289c2d
Commit message:
ffdgj

Changed in this revision

DigitDisplay.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DigitDisplay.lib	Mon Feb 20 13:29:52 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/seeed/code/DigitDisplay/#d3173c8bfd48
--- 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