This is my Arduino Multi Trickle Charger Device

Video

 

 

Sketch

 

Code

#include <RBD_Timer.h> // https://github.com/alextaujenis/RBD_Timer
RBD::Timer timer24; // 24 hour timer

int relay[9] = { 2,3,4,5,6,7,8,9,11 } ; //define digital output pins
int a0; // defind analog input pin a0
int day; // Holds which day we are on. Repete every 30 days
int buttonApin = 12;
#define interval 500
void setup() {
// put your setup code here, to run once:
// initialize digital pin LED_BUILTIN as an output. not useing this project
pinMode(LED_BUILTIN, OUTPUT); //this is the built in led
pinMode(relay[0], OUTPUT); //Relay for Battery 1 - Digital Arduino Pin 2
pinMode(relay[1], OUTPUT); //Relay for Battery 2 - Digital Arduino Pin 3
pinMode(relay[2], OUTPUT); //Relay for Battery 3 - Digital Arduino Pin 4
pinMode(relay[3], OUTPUT); //Relay for Battery 4 - Digital Arduino Pin 5
pinMode(relay[4], OUTPUT); //Relay for Battery 5 - Digital Arduino Pin 6
pinMode(relay[5], OUTPUT); //Relay for Battery 6 - Digital Arduino Pin 7
pinMode(relay[6], OUTPUT); //Relay for Battery 7 - Digital Arduino Pin 8
pinMode(relay[7], OUTPUT); //Relay for Check-Voltage - Digital Arduino Pin 9
pinMode(relay[8], OUTPUT); //Relay for Charger 120V - Digital Arduino Pin 11
pinMode(buttonApin, INPUT_PULLUP); // use button on prototype board to increase day
pinMode(14, INPUT); // Analog pin a0 either pin works //pinMode(0, INPUT);

digitalWrite(LED_BUILTIN, HIGH); //turn off on board LED
digitalWrite(relay[0], HIGH); //turn off all relays
digitalWrite(relay[1], HIGH); //turn off all relays
digitalWrite(relay[2], HIGH); //turn off all relays
digitalWrite(relay[3], HIGH); //turn off all relays
digitalWrite(relay[4], HIGH); //turn off all relays
digitalWrite(relay[5], HIGH); //turn off all relays
digitalWrite(relay[6], HIGH); //turn off all relays
digitalWrite(relay[7], HIGH); //turn off all relays
digitalWrite(relay[8], HIGH); //turn off all relays
Serial.begin(115200);
timer24.setTimeout(24L*60L*60L*1000L); // 24 hours in ms
//timer24.setTimeout(60L*1000L); // 1 minuet in ms
//timer24.setTimeout(60L*60L*1000L); // 1 hours in ms
//timer24.setTimeout(10000L); // 10 seconds in ms
day = 0; //Set day to day 0
}
void loop() {
 

if (digitalRead(buttonApin) == LOW)
{
day = day + 1; // 24 hours just went buy increase day by one
Serial.print("\n");
Serial.print("We Just Skipped day Increased To Day ");
Serial.println(day + 1);
delay(250);
//timer24.stop();// start the 24 hour
//delay(interval);
//timer24.restart();// start the 24 hour
//timer24.onRestart();// start the 24 hour
//delay(interval);
}

// put your main code here, to run repeatedly:
if(timer24.onExpired()) { //SetTimeout sets the inteval. each time the timer runs out we run below this if statement
// timer just expired, Time to change the day and move to next battery

day = day + 1; // 24 hours just went buy increase day by one
Serial.print("\n");
Serial.println(".........*.........*.........**Timer Restarted**.........*.........*.........*"); digitalWrite(relay[8],HIGH); // turn off relay(8)120V Charger
switch (day) { //do a select case to find which day/battery we are charging
case 1: // Battery one is the power supply for arduino we dont need to ck voltage just start charging it
Serial.print("\n");
Serial.println("day1");
digitalWrite(relay[0],LOW); // turn on relay Battery 1
delay(interval);
digitalWrite(relay[8],LOW); // turn on the 120V Charger
delay(interval);
Serial.println("Charging");
break;
case 2:
Serial.print("\n");
Serial.println("day2");
digitalWrite(relay[0],HIGH); //turn off relay(0) Battery 1
delay(interval);
digitalWrite(relay[1],LOW); // turn on relay Battery 2
delay(interval);

digitalWrite(relay[7],LOW); // turn on relay check for voltage
delay(interval);
a0 = analogRead(14); // read the voltage to see if a battery is hooked up
digitalWrite(relay[7],HIGH); // turn off relay check for voltage
delay(interval);

Serial.print ("VoltageCK=");
Serial.print (a0) ;
if (a0 > 250) { // find out the 50% of voltage before using, should never get a value over 450 range is between 0 and 1024
digitalWrite(relay[8],LOW); // turn on the 120V Charger
delay(interval);
Serial.println("Charging");
}
else{
Serial.println("Not-Charging");
digitalWrite(relay[1],HIGH); //turn off relay(0) Battery 2
delay(interval);
}
break; case 3:
Serial.print("\n");
Serial.println("day3");
// statements
digitalWrite(relay[1],HIGH); //turn off relay(1) Battery 2
delay(interval);
digitalWrite(relay[2],LOW); // turn on relay Battery 3
delay(interval); digitalWrite(relay[7],LOW); // turn on relay check for voltage
delay(interval);
a0 = analogRead(14); // read the voltage to see if a battery is hooked up
digitalWrite(relay[7],HIGH); // turn off relay check for voltage
delay(interval);

Serial.print ("VoltageCK=");
Serial.print (a0) ;
if (a0 > 250) { // find out the 50% of voltage before using, should never get a value over 450 range is between 0 and 1024
digitalWrite(relay[8],LOW); // turn on the 120V Charger
delay(interval);
Serial.println("Charging");
}
else{
Serial.println("Not-Charging");
digitalWrite(relay[2],HIGH); //turn off relay(2) Battery 3
delay(interval);
}
break;

case 4:
Serial.print("\n");
Serial.println("day4");
// statements
digitalWrite(relay[2],HIGH); //turn off relay(2) Battery 3
delay(interval);
digitalWrite(relay[3],LOW); // turn on relay Battery 4
delay(interval);

digitalWrite(relay[7],LOW); // turn on relay check for voltage
delay(interval);
a0 = analogRead(14); // read the voltage to see if a battery is hooked up
digitalWrite(relay[7],HIGH); // turn off relay check for voltage
delay(interval);

Serial.print ("VoltageCK=");
Serial.print (a0) ;
if (a0 > 250) { // find out the 50% of voltage before using, should never get a value over 450 range is between 0 and 1024
digitalWrite(relay[8],LOW); // turn on the 120V Charger
delay(interval);
Serial.println("Charging");
}
else{
Serial.println("Not-Charging");
digitalWrite(relay[3],HIGH); //turn off relay(3) Battery 4
delay(interval);
}
break;

case 5:
Serial.print("\n");
Serial.println("day5");
// statements
digitalWrite(relay[3],HIGH); //turn off relay(3) Battery 4
delay(interval);
digitalWrite(relay[4],LOW); // turn on relay Battery 5
delay(interval);

digitalWrite(relay[7],LOW); // turn on relay check for voltage
delay(interval);
a0 = analogRead(14); // read the voltage to see if a battery is hooked up
digitalWrite(relay[7],HIGH); // turn off relay check for voltage
delay(interval);

Serial.print ("VoltageCK=");
Serial.print (a0) ;
if (a0 > 250) { // find out the 50% of voltage before using, should never get a value over 450 range is between 0 and 1024
digitalWrite(relay[8],LOW); // turn on the 120V Charger
delay(interval);
Serial.println("Charging");
}
else{
Serial.println("Not-Charging");
digitalWrite(relay[4],HIGH); //turn off relay(4) Battery 5
delay(interval);
}
break;

case 6:
Serial.print("\n");
Serial.println("day6");
// statements
digitalWrite(relay[4],HIGH); //turn off relay(4) Battery 5
delay(interval);
digitalWrite(relay[5],LOW); // turn on relay Battery 6
delay(interval);

digitalWrite(relay[7],LOW); // turn on relay check for voltage
delay(interval);
a0 = analogRead(14); // read the voltage to see if a battery is hooked up
digitalWrite(relay[7],HIGH); // turn off relay check for voltage
delay(interval);

Serial.print ("VoltageCK=");
Serial.print (a0) ;
if (a0 > 250) { // find out the 50% of voltage before using, should never get a value over 450 range is between 0 and 1024
digitalWrite(relay[8],LOW); // turn on the 120V Charger
delay(interval);
Serial.println("Charging");
}
else{
Serial.println("Not-Charging");
digitalWrite(relay[5],HIGH); //turn off relay(5) Battery 6
delay(interval);
}
break;

case 7:
Serial.print("\n");
Serial.println("day7");
// statements
digitalWrite(relay[5],HIGH); //turn off relay(0) Battery 6
delay(interval);
digitalWrite(relay[6],LOW); // turn on relay Battery 7
delay(interval);

digitalWrite(relay[7],LOW); // turn on relay check for voltage
delay(interval);
a0 = analogRead(14); // read the voltage to see if a battery is hooked up
digitalWrite(relay[7],HIGH); // turn off relay check for voltage
delay(interval);

Serial.print ("VoltageCK=");
Serial.print (a0) ;
if (a0 > 250) { // find out the 50% of voltage before using, should never get a value over 450 range is between 0 and 1024
digitalWrite(relay[8],LOW); // turn on the 120V Charger
delay(interval);
Serial.println("Charging");
}
else{
Serial.println("Not-Charging");
digitalWrite(relay[6],HIGH); //turn off relay(6) Battery 7
delay(interval);
}
break;

case 11:
Serial.print("\n");
Serial.println("day11");
digitalWrite(relay[0],LOW); // turn on relay Battery 1
delay(interval);
digitalWrite(relay[8],LOW); // turn on the 120V Charger
delay(interval);
Serial.println("Charging");
break;
case 21:
Serial.print("\n");
Serial.println("day21");
digitalWrite(relay[0],LOW); // turn on relay Battery 1
delay(interval);
digitalWrite(relay[8],LOW); // turn on the 120V Charger
delay(interval);
Serial.println("Charging");
break;
case 30:
day = 0; //We have reached the end of the month start over
break;

default: // we are between charging days, turn everything off!
Serial.print("\n");
Serial.print("day");
Serial.println (day); digitalWrite(relay[0], HIGH); //Turn off Relays
delay(interval);
digitalWrite(relay[1], HIGH); //Turn off Relays
delay(interval);
digitalWrite(relay[2], HIGH); //Turn off Relays
delay(interval);
digitalWrite(relay[3], HIGH); //Turn off Relays
delay(interval);
digitalWrite(relay[4], HIGH); //Turn off Relays
delay(interval);
digitalWrite(relay[5], HIGH); //Turn off Relays
delay(interval);
digitalWrite(relay[6], HIGH); //Turn off Relays
delay(interval);
digitalWrite(relay[7], HIGH); //Turn off Relays
delay(interval);
digitalWrite(relay[8], HIGH); //Turn off Relays
delay(interval);
if (day > 30) {
day = 0;
}
break;} // END OF SWITCH (day)
// we have setup the days routing now restart the timer
timer24.restart();// start the 24 hour

} //END OF IF (timer24.isExpired()

else { // You could add a routing here to see if the battery is fully charged then turn off the 120V relay
//Serial.print("Timer is running");
// Serial.print("\n");
//timer24.stop(); } // END OF ELSE

} //END OF LOOP







//#####################################################################################

// Arduino RBD Timer Library v1.3.0 - Manage many timed events.
// https://github.com/alextaujenis/RBD_Timer
// Copyright 2016 Alex Taujenis
// MIT License#ifndef RBD_TIMER_H
#define RBD_TIMER_H#include "Arduino.h"namespace RBD {
class Timer {
public:
Timer(); // constructor with zero timeout, starts in "expired" state by default
Timer(unsigned long value); // overloaded constructor: provide a setTimeout in milliseconds, starts in "expired" state by default
void setTimeout(unsigned long value); // set/change how long the timer will run until it expires in milliseconds
void setHertz(int value); // set/change how many times onRestart will return true in one second
void restart(); // reset and start the timer
void stop(); // stop the timer
bool isActive(); // check if time is left
bool isExpired(); // returns true if time has run out
bool isStopped(); // returns true if the timer is stopped
bool onRestart(); // returns true if the timer is expired and restarts the timer automatically
bool onActive(); // returns true once the timer is active, then waits for it to expire and go active again
bool onExpired(); // returns true once the timer is expired, then waits for it to go active and expire again
unsigned long getTimeout(); // returns the value of setTimeout, which is how long the timer will run until it expires in milliseconds
int getHertz(); // returns the value of setHertz, which is how many times onRestart will return true in one second
unsigned long getValue(); // how many milliseconds that have passed since the start of the timer
unsigned long getInverseValue(); // how many milliseconds the timer has until finished
int getPercentValue(); // how much time has passed as a percentage of the interval
int getInversePercentValue(); // how much time is left as a percentage of the interval
private:
unsigned long _timeout = 0; // how long this timer should run for
unsigned long _waypoint = 0; // the point in time the timer was started or reset
int _hertz = 0; // the value given to setHertz
bool _has_been_active = false; // helps fire the onActive event only once
bool _has_been_expired = false; // helps fire the onExpired event only once
void _updateState(); // maintains timer current state, helps eliminate rollover issues
enum {ACTIVE, EXPIRED, STOPPED} _state = EXPIRED; // timer internal states, constructed in "expired" state by default
};
}
#endif

 

 

Parts

Description Price qty Link
Arduino Uno R3 5pk 5.23 1 Online
8 Chanel Relay 5.99 1 Online
Prototyp Shield 2.398 1 Online
50' Wire 16Guage Red/Blk 11.95 1 Online
BreadBoard Jumpers Wires 2 pk 5.945 1 Online
1 Channel Relay 5pk 1.798 1 Online
Arduino Holder Kit 0 1 Online
LM2596 DC to DC 5pk 2.156 1 Online
Cord With Remote On/Off 8.18 1 Online
Alligator Clips 100 PC 1.85285714 1 Online
Screws Standoffs      
Case Clear Lid 230*150*85      
Case Clear Lid 200*150*75 6.58    
Solid 16 Guage Wire 1    
Screws 3/4" 7/16 2 nuts 1    
e-volt PC Blue Ring Crimp 0.33316667 1 Online
Zip tie   1  
Wire Nuts   1  
Inline Fuse 12V 16G 3pk 3.915 1 Online
SP16 IP68 waterproof connector male plug & female socket 1.95    
Cheater 3 prong plug