displays a float (decimal number) to 4 digit, 7 segment LED display LDQ-N514R1 using mbed LPC1768

Dependencies:   mbed

Fork of 7SegmentDisplay by Svend Kaffke

Files at this revision

API Documentation at this revision

Comitter:
captaintim
Date:
Tue Sep 06 06:27:58 2016 +0000
Parent:
2:3cf4eba9de56
Commit message:
Added ability to increment the float number by moving While (1) statement and making a few other changes.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Sep 04 11:54:00 2016 +0000
+++ b/main.cpp	Tue Sep 06 06:27:58 2016 +0000
@@ -82,12 +82,14 @@
 float f = 0.005;
 //enter a float number here (with a decimal in it) starting point
 volatile float temp = 31.45;
+int t = temp * 100;
 
 int main(){
+while (1){
 //finessing the digits out one at a time knowing 2nd digit has the decimal
-int tempasinteger = temp * 100;  //removes decimal and typecasts float to integer
-int temp1a=tempasinteger/1000;    //typecast float to integer for 1st digit (was)
-int temp2 = tempasinteger - temp1a*1000;  //gets last 3 digits
+//int tempasinteger = temp * 100;  //removes decimal and typecasts float to integer
+int temp1a = t/1000;    //typecast float to integer for 1st digit (was)
+int temp2 = t - temp1a*1000;  //gets last 3 digits
 int temp2a = temp2/100;   //typecast float to integer for 2nd digit
 int temp3 = temp2 - temp2a*100;  //get last 2 digits
 
@@ -100,7 +102,7 @@
     Digit2 = 1; //turn off digit2
     Digit3 = 1; //turn off digit3
     Digit4 = 1; //turn off digit4
-    while (1) {       
+//    while (1) {       
         //turns off last led's segments values
         for(int i = 0; i<8;i++){
             led[i] = 0;}
@@ -142,9 +144,17 @@
          //belows holds row of matrix and assign column value from matrix
          Digit4 = 0;             //turns on digit4
             for (int i=0; i<8; i++){
-                led[i] = matrix[temp4a][i];                }  
+                led[i] = matrix[temp4a][i]; 
+                } 
         wait(f);
         Digit4=1;
         
-      }
-}
\ No newline at end of file
+        //loop & increment
+        if (t <3600) 
+        t=t+1;
+        else
+        t=3200;
+        
+        
+      }  //close for while 1
+} //close for main
\ No newline at end of file