#define pinA 3
#define pinB 4
#define pinC 5
#define pinD 6
#define pinE 7

int lectura;
int vPreA = 0, vPreB = 0, vPreC = 0, vPreD = 0, vPreE = 0;
boolean outA = false, outB = false, outC = false, outD = false, outE = false;
unsigned long i = 0;
void setup() {
pinMode(pinA, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(pinC, OUTPUT);
pinMode(pinD, OUTPUT);
pinMode(pinE, OUTPUT);
}

void loop() {
lecturaCanalA();
lecturaCanalB();
lecturaCanalC();
lecturaCanalD();
lecturaCanalE();

toogleA
(i);
toogleB(i);
toogleC(i);
toogleD(i);
toogleE(i);

i++;
if(i>1000)
i=0;


/* Serial.print(vPreA);
Serial.print(" ");
Serial.print(vPreB);
Serial.print(" ");
Serial.print(vPreC);
Serial.print(" ");
Serial.print(vPreD);
Serial.print(" ");
Serial.println(vPreE);
delay(200);*/



}

void toogleA(int c){
if(c%vPreA==0){
if(outA){
outA = false;
digitalWrite(pinA, LOW);
}
else{
outA = true;
digitalWrite(pinA, HIGH);
}
}
}
void toogleB(int c){
if(c%vPreB==0){
if(outB){
outB = false;
digitalWrite(pinB, LOW);
}
else{
outB = true;
digitalWrite(pinB, HIGH);
}
}
}
void toogleC(int c){
if(c%vPreC==0){
if(outC){
outC = false;
digitalWrite(pinC, LOW);
}
else{
outC = true;
digitalWrite(pinC, HIGH);
}
}
}
void toogleD(int c){
if(c%vPreD==0){
if(outD){
outD = false;
digitalWrite(pinD, LOW);
}
else{
outD = true;
digitalWrite(pinD, HIGH);
}
}
}
void toogleE(int c){
if(c%vPreE==0){
if(outE){
outE = false;
digitalWrite(pinE, LOW);
}
else{
outE = true;
digitalWrite(pinE, HIGH);
}
}
}
void lecturaCanalA()
{
lectura = analogRead(A0);
if (lectura > 10) {
vPreA = transform(lectura);
}
}
void lecturaCanalB()
{
lectura = analogRead(A1);
if (lectura > 10) {
vPreB = transform(lectura);
}
}
void lecturaCanalC()
{
lectura = analogRead(A2);
if (lectura > 10) {
vPreC = transform(lectura);
}
}
void lecturaCanalD()
{
lectura = analogRead(A3);
if (lectura > 10) {
vPreD = transform(lectura);
}
}
void lecturaCanalE()
{
lectura = analogRead(A4);
if (lectura > 10) {
vPreE = transform(lectura);
}
}
int transform(int dato)
{
int canal;

if (dato > 500 && dato < 520)
canal = 1;
else if (dato > 330 && dato < 350)
canal = 2;
else if (dato > 244 && dato < 264)
canal = 3;
else if (dato > 190 && dato < 210)
canal = 4;
else if (dato > 160 && dato < 180)
canal = 5;
else if (dato > 140 && dato < 170)
canal = 6;
else if (dato > 120 && dato < 160)
canal = 7;

return canal;
}