8 Port relay module + ACS712, delay time not turning on for right amount of time

const int AIN1 = A1;
const int AIN2 = A2;
const int AIN3 = A3;
const int AIN4 = A4;
const int AIN5 = A5;
const int AIN6 = A6;
const int AIN7 = A7;
const int AIN8 = A8;

Why on earth define then at all if all you do is add the 'IN' bit?

Have a look at arrays :wink: That would reduce the code by at least 1/4th and including looking it up saved you halve the time :wink:

Talking about time, delay() will stop EVERYTHING dead in it's tracks. Use millis() or micros() (see Blink without delay) to be able to do other stuff (like, getting the timing straight).

Also, I would suggest to stop using direct port manipulation and just use Arduino functions for the outputs. A heck of a lot easier and more problem free.