/ Freq_Meter
Revision:
3:b6e887e4ac75
Parent:
0:7f4ed364f7ea
--- a/Ammeter_Code.cpp	Wed Apr 01 19:45:59 2020 +0000
+++ b/Ammeter_Code.cpp	Wed Apr 01 20:58:55 2020 +0000
@@ -1,3 +1,35 @@
+/*
+the ammeter reads the voltage accross the shunt resister that is a set value
+this is used to calculate the current in the circuit
+a value for current will be printed in mA on the LCD screen
+
+*/
+
+
 //Case x:
+lcd.locate(0.0)
+lcd.printf("Current: "); 
+
+
+AnalogIn vo(A5);  //reads the voltage across rshunt
 
-jk
\ No newline at end of file
+double vout= (3.3*vo)/4095; //converts from bits in the analog read
+double rshunt = 0.01;       //set value for rshunt
+int i;                      // declares a integer for i
+
+
+i = vout/rshunt;           // equation to find i
+
+if i<= 0.5{ 
+
+ifinal= i*1000; //converts into amps to mA
+lcd.locate(0,1);
+lcd.printf(".3f mA", ifinal);
+    }
+else {
+lcd.locate(0,1);
+lcd.printf("out of range");
+}
+//if and else staments here are based in if the i that has been found is within the parameters 
+  
+    
\ No newline at end of file