Kevin Maddox / Mbed 2 deprecated kevin_maddox_Lab3_Part1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
kevinmark13
Date:
Thu Jan 22 01:06:03 2015 +0000
Child:
1:80aea0f0fcbd
Commit message:
Lab3 Part1

Changed in this revision

Function1.h Show annotated file Show diff for this revision Revisions of this file
Function2.h 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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Function1.h	Thu Jan 22 01:06:03 2015 +0000
@@ -0,0 +1,59 @@
+/*
+    Function 1: take a decimal digit (0, 1, 2, ... , 9) and return the segment driver value for this digit
+  
+*/
+
+BusOut digselect(p20, p19, p15, p13, p24);
+// bus from MSB to LSB: L1/L2, digit4, digit3, digit2, digit1
+
+BusOut digit(p26, p28, p25, p18, p16, p23, p27, p14);
+// bus from MSB to LSB: dp, g, f, e, d, c, b, a
+
+
+DigitalOut L1(p17);
+//DigitalOut L2(p24);
+
+void digit0 () {
+digit = 0xC0;
+};
+
+void digit1 () {
+digit = 0xF9;
+};
+
+void digit2 () {
+//digit = 0x24;
+digit = 0xA4;
+};
+
+void digit3 () {
+digit = 0xB0;
+};
+
+void digit4 () {
+digit = 0x99;
+};
+
+void digit5 () {
+digit = 0x92;
+};
+
+void digit6 () {
+digit = 0x82;
+};
+
+void digit7 () {
+digit = 0xF8;
+};
+
+void digit8 () {
+digit = 0x80;
+};
+
+void digit9 () {
+digit = 0x98;
+};
+
+void digit00 () {
+digit = 0xFF;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Function2.h	Thu Jan 22 01:06:03 2015 +0000
@@ -0,0 +1,88 @@
+/*
+    Function 2: take the hour and minute, display the hour and minute in the format 
+    of HH:MM on the 4-bank seven segment LED display for 1 minute with the: blinking 
+    every second (On for half second and Off for half second 1/2s = 500ms)
+    
+    */
+        
+void digitalClock ()
+{
+    
+    int numbers [10] = { 0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x98 };
+    int numbers2 [10] = { 0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x98 };
+    int numbers3 [10] = { 0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x98 };
+    int numbers4 [10] = { 0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x98 };
+          
+
+int a = 0;
+int b = 0;
+int c = 0;
+int d = 0;
+
+while(1){
+    
+           if ( b == 6 )
+           {
+               
+               b = 0;
+               c = c +1;
+               }
+        
+    for ( int i = 0; i < 2; i++ ) //3000 interations = 60s
+    {
+                   
+          digselect = 0x1;  // digit 1 Binary: 0 0 0 1
+          digit = numbers4[d]; 
+          wait_ms(3);
+          
+           digselect = 0x2; //digit 2 Binary: 0 0 1 0
+          digit = numbers2[c];
+          wait_ms(3);
+          
+          digselect = 0x4; //digit 3 Binary: 0 1 0 0
+          digit = numbers3[b];
+          wait_ms(3);
+          
+          digselect = 0x8; //digit 4 Binary: 1 0 0 0
+          digit = numbers[a];
+          wait_ms(3);
+           
+          digselect = 0x10; // position 1 0 0 0 0
+          L1 = 1;
+          wait_ms(3);
+                        
+          digselect = 0x8;
+          digit00();
+          wait_ms(5);
+                    
+         wait_ms(4);
+                   
+       
+    }; 
+    
+           a++;
+            if (( d == 2 ) && ( c == 4) )
+           {
+               a = 0;
+               b = 0;
+               c = 0;
+               d = 0;
+               }
+               
+           if ( a == 10) 
+        { 
+         a = 0;
+         b = b + 1;
+           
+           };
+           if ( c == 10 )
+           {
+               c = 0;
+               d = d + 1;
+               }
+               
+           
+           
+           }; 
+           
+};// end of Function
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jan 22 01:06:03 2015 +0000
@@ -0,0 +1,12 @@
+
+
+#include "mbed.h"
+#include "Function1.h"
+#include "Function2.h"
+
+
+int main()
+{
+    digitalClock ();
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jan 22 01:06:03 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file