Muslija Adnan Agic Lejla

Dependencies:   mbed

Revision:
0:e7b37797a254
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Mar 24 08:28:23 2014 +0000
@@ -0,0 +1,85 @@
+#include "mbed.h"
+
+/*BusOut display(dp2, dp1, dp28, dp6, dp5, dp27, dp26);
+BusOut digits(dp23,dp24,dp25);
+#define max_volt 2.1
+#define min_volt 0.7
+
+DigitalOut point(dp4);*/
+
+BusOut display(dp26, dp27, dp5, dp6, dp28, dp1, dp2);
+DigitalOut point(dp4);
+int numbers[10]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x078,0x0,0x10};
+int chars[6]={0x08,0x60,0x31,0x42,0x30,0x38};
+BusOut digits(dp23,dp24,dp25);
+
+AnalogIn input(dp9);
+
+/*int numbers[10] = {0x01, 0x4f, 0x12, 0x06, 0x4c, 0x24, 0x20, 0x0f, 0x0, 0x04};
+int chars[6]={0x08,0x60,0x31,0x42,0x30,0x38};
+*/
+void showDigit(int input)
+{
+    if(input>=0 && input<=9)
+        display=numbers[input];
+    else
+        display=0x7f;
+}
+
+
+void displayValue(float value)
+{
+    int third=(value-int(value))*10;
+    int second=int(value)%10;
+    int first=int(value)/10;
+    
+    digits=6;//bilo  = 1
+    showDigit(first);
+    wait_ms(1);
+    digits=7;
+    
+    showDigit(second);    
+    digits=5;
+ 
+    wait_ms(1);
+
+    
+    digits=7;
+    showDigit(third);
+    digits=3;//bilo = 4
+    wait_ms(1);
+    digits=0;  
+}
+
+
+
+float unesi_niz()
+{
+    
+    float sum=0;
+    for(int i=0;i<100;i++)
+        sum+=input*3.3;
+    return sum;
+}
+
+
+
+int main() {
+    float max_volt=1.9;
+    float min_volt=0.7;
+    float ratio=0;
+    float diff_volt=max_volt-min_volt;
+    float ain=input*3.3;
+    int i=0;
+    while(1) {
+        if(i%100==0)
+            ain=input*3.3;
+            
+        if(ain>=min_volt && ain<=max_volt)      
+            ratio=1-(ain-min_volt)/diff_volt;
+        else
+            ratio=0;
+        displayValue(ratio*100);
+        i++;
+    }
+}
\ No newline at end of file