I wrote a program that will not only answer the above question, it will address any instance that we are taking more juice than what the batteries can provide..
Code Below:
int dcMeter = A3;// Takes in dc (gennie) current
int dcTemp = A4; // Are we going to die?
int specialRly = 3;// Relay that is connected direct to propulsion.
int gennie = 10; // dcMotor
int allGood = 6;// yay we can drive!
void setup() {
pinMode (dcMeter, INPUT); // Input for dcMotor current while driving.
pinMode (specialRly, OUTPUT); // controls relay for extra push
pinMode (gennie, OUTPUT);// dcMotor
pinMode (allGood, OUTPUT); //yay
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int vroomVroom = 1;// change later to reflect driving
if (vroomVroom == 1){
int yoMamaFlo = analogRead(dcMeter);
//Serial.println(" yoMamaFlo_"); Serial.print( yoMamaFlo);
int flow = yoMamaFlo /200 ;
Serial.println("Flow_"); Serial.print(flow);
if (flow >= 2){
motor(HIGH,HIGH);
digitalWrite(allGood, LOW);
}
else{
motor (NULL,LOW);// return control back to primary program
digitalWrite(allGood, HIGH);
}
}
}
void motor(int mtr, int swt){// Motor and battery relay control
digitalWrite(gennie,mtr);
digitalWrite (specialRly, swt);
}
No comments:
Post a Comment