Go to the documentation of this file.00001
00007
00008
00009 #include "batteryCheck.h"
00010
00011
00012 int BatMon1Pin = 2;
00013 int BatMon2Pin = 3;
00014 int Bat1val = 0;
00015 int Bat2val = 0;
00016 float Pin2Voltage = 0;
00017 float Pin3Voltage = 0;
00018 double Battery1Voltage = 0;
00019 double Battery2Voltage = 0;
00020 float Ratio = 5;
00021
00022
00023
00024 double Battery1State()
00025 {
00026 #ifdef __DEBUG__BC__
00027 Serial.println("Getting battery 1 voltage...");
00028 #endif
00029
00030 Bat1val = analogRead(BatMon1Pin);
00031
00032 Pin2Voltage = Bat1val * 0.0048828125;
00033
00034
00035
00036
00037
00038
00039 Battery1Voltage = Pin2Voltage * Ratio;
00040
00041 return (Battery1Voltage);
00042 }
00043
00044
00045
00046 double Battery2State()
00047 {
00048 #ifdef __DEBUG__BC__
00049 Serial.println("Getting battery 2 voltage...");
00050 #endif
00051
00052 Bat2val = analogRead(BatMon2Pin);
00053
00054 Pin3Voltage = Bat2val * 0.0048828125;
00055
00056
00057
00058
00059
00060 Battery2Voltage = Pin3Voltage * Ratio;
00061
00062 return (Battery2Voltage);
00063 }