multimetro digital

1.    CODIFICACION ARDUINO

#include<LiquidCrystal.h>
#include<DHT11.h>//LIBRERIA PARA EL CENSOR DHT11
DHT11 dht11(10);//ESTO ES PARA CENSOR DHT11
int Vin = 5; //ESTO ES PARA OHM
float Vout = 0; //ESTO ES PARA OHM
float R1 = 1000; //ESTO ES PARA OHM
float R2 = 0; //ESTO ES PARA OHM
float buffer = 0; //ESTO ES PARA OHM
char directo[8] = {32, 34, 36, 38, 40, 42, 44, 46};//PARA LAN TESTER
char cruzado[8] = {36, 42, 32, 38, 40, 34, 44, 46};//PARA LAN TESTER

LiquidCrystal  lcd(2, 3, 4, 5, 6, 7);
void setup() {
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.print("MILTON  - BRANCO");
  lcd.setCursor(0, 1);
  lcd.print("------CESAR-----");
  delay(3000);
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.print("MILTON  - BRANCO");
  lcd.setCursor(0, 1);
  lcd.print("------CESAR-----");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">MILTON  - BRANC");
  lcd.setCursor(0, 1);
  lcd.print("-----CESAR-----<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>MILTON  - BRAN");
  lcd.setCursor(0, 1);
  lcd.print("----CESAR-----<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>MILTON  - BRA");
  lcd.setCursor(0, 1);
  lcd.print("---CESAR-----<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>MILTON  - BR");
  lcd.setCursor(0, 1);
  lcd.print("--CESAR-----<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>MILTON  - B");
  lcd.setCursor(0, 1);
  lcd.print("-CESAR-----<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>MILTON  - ");
  lcd.setCursor(0, 1);
  lcd.print("CESAR-----<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>MILTON  -");
  lcd.setCursor(0, 1);
  lcd.print("ESAR-----<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>MILTON  ");
  lcd.setCursor(0, 1);
  lcd.print("SAR-----<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>>MILTON ");
  lcd.setCursor(0, 1);
  lcd.print("AR-----<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>>>MILTON");
  lcd.setCursor(0, 1);
  lcd.print("R-----<<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>>>>MILTO");
  lcd.setCursor(0, 1);
  lcd.print("-----<<<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>>>>>MILT");
  lcd.setCursor(0, 1);
  lcd.print("----<<<<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>>>>>>MIL");
  lcd.setCursor(0, 1);
  lcd.print("---<<<<<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>>>>>>>MI");
  lcd.setCursor(0, 1);
  lcd.print("--<<<<<<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>>>>>>>>M");
  lcd.setCursor(0, 1);
  lcd.print("-<<<<<<<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>>>>>>>>>");
  lcd.setCursor(0, 1);
  lcd.print("<<<<<<<<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>>>>>>>>M");
  lcd.setCursor(0, 1);
  lcd.print("L<<<<<<<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>>>>>>>MU");
  lcd.setCursor(0, 1);
  lcd.print("AL<<<<<<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>>>>>>MUL");
  lcd.setCursor(0, 1);
  lcd.print("TAL<<<<<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>>>>>>MULT");
  lcd.setCursor(0, 1);
  lcd.print("ITAL<<<<<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>>>>>MULTI");
  lcd.setCursor(0, 1);
  lcd.print("GITAL<<<<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>>>MULTIM");
  lcd.setCursor(0, 1);
  lcd.print("IGITAL<<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>>MULTIME");
  lcd.setCursor(0, 1);
  lcd.print("DIGITAL<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>>MULTIMET");
  lcd.setCursor(0, 1);
  lcd.print("DIGITAL<<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>>MULTIMETR");
  lcd.setCursor(0, 1);
  lcd.print(">DIGITAL<<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>>>MULTIMETRO");
  lcd.setCursor(0, 1);
  lcd.print(">>DIGITAL<<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>>MULTIMETRO<<");
  lcd.setCursor(0, 1);
  lcd.print(">>>DIGITAL<<<<<<");
  delay(100);
  lcd.setCursor(0, 0);
  lcd.print(">>>MULTIMETRO<<<");
  lcd.setCursor(0, 1);
  lcd.print(">>>>DIGITAL<<<<<");
  delay(2000);
  lcd.clear();
  //AQUI VA LA ASIGNACION DE PINES DEL LANTESTER
  pinMode(32, OUTPUT);
  pinMode(34, OUTPUT);
  pinMode(36, OUTPUT);
  pinMode(38, OUTPUT);
  pinMode(40, OUTPUT);
  pinMode(42, OUTPUT);
  pinMode(44, OUTPUT);
  pinMode(46, OUTPUT);
  pinMode(48, INPUT); // SELECCIONA SI ES UN CABLE NORMAL(T268B)O UN CABLE DE CONEXION CRUZADA (T268A)
  pinMode(50, OUTPUT); // EN ESTE PIN VA UN LED QUE INDICA SI EL PIN ESTA SIENDO LEÍDO
}
void loop() {
  digitalWrite(22, HIGH);
  digitalWrite(24, HIGH);
  digitalWrite(26, HIGH);
  digitalWrite(28, HIGH);
  digitalWrite(30, HIGH);
  int estado = 0;
  int conexionA = 0;
  int conexionB = 0;
  int conexionC = 0;
  int conexionD = 0;
  int conexionE = 0;
  if (digitalRead(22) == LOW) {
    estado = 1;
    conexionA = 1;
  }
  if (digitalRead(24) == LOW) {
    estado = 2;
    conexionB = 1;
  }
  if (digitalRead(26) == LOW) {
    estado = 3;
    conexionC = 1;
  }
  if (digitalRead(28) == LOW) {
    estado = 4;
    conexionD = 1;
  }
  if (digitalRead(30) == LOW) {
    estado = 5;
    conexionE = 1;
  }
  int conexiontotal = conexionA + conexionB + conexionC + conexionD + conexionE;
  if (conexiontotal > 1)
  {
    estado = 6;
  }
  if (conexiontotal == 0)
  {
    estado = 7;
  }

  switch (estado) {
    case (1): {
        lcd.setCursor(0, 0);
        lcd.print("<->VOLTIMETRO<->");
        double  sensorValue = analogRead(A0);
        double  voltaje = sensorValue / 29.86807388;
        lcd.setCursor(2, 1);
        if (voltaje >= 1000)
        {
          lcd.print(voltaje / 1000, 2);
          lcd.setCursor(10, 1);
          lcd.print("[KVol]");
        }
        else {
          if (voltaje >= 1) {
            lcd.print(voltaje, 2);
            lcd.setCursor(10, 1);
            lcd.print("[Vol]");
          }
          else {
            if (voltaje <= 1) {
              lcd.print(voltaje * 1000, 2);
              lcd.setCursor(10, 1);
              lcd.print("[mVol]");
            }
          }
        }
        delay(500);
        lcd.clear();
        break;
      }
    case (2): {
        double corriente = (analogRead(0) * (0.00490f)) / (0.00001f); ///(0.01f)

        lcd.setCursor(0, 0);
        lcd.print("<> AMPERIMETRO<>");
        lcd.setCursor(2, 1);
        if (corriente < 1000)
        {
          lcd.print(corriente, 2);
          lcd.setCursor(10, 1);
          lcd.print("[mAmp]");
        }
        else {
          if (corriente < 1000000) {
            lcd.print(corriente / 1000, 2);
            lcd.setCursor(10, 1);
            lcd.print("[Amp]");
          }
          else {
            if (corriente < 1000000000) {
              lcd.print(corriente / 1000000, 2);
              lcd.setCursor(10, 1);
              lcd.print("[kAmp]");
            }
          }
        }
        delay(300);
        lcd.clear();
        break;
      }
    case (3): {
        double raw = analogRead(A1);
        buffer = raw * Vin;
        Vout = (buffer) / 1024.0;
        buffer = (Vin / Vout) - 1;
        R2 = ((R1 * buffer) / 1.02520602) * 10;

        lcd.setCursor(0, 0);
        lcd.print("<-> OHMETRO <->");
        if (R2 < 1000) {
          lcd.setCursor(2, 1);
          lcd.print(R2, 2);
          lcd.setCursor(10, 1);
          lcd.print("ohm");
        }
        if (R2 < 1000000 && R2 > 999) {
          lcd.setCursor(2, 1);
          lcd.print(R2 / 1000, 2);
          lcd.setCursor(10, 1);
          lcd.print("k ohm");
        }
        if (R2 < 1000000000 && R2 > 999999) {
          lcd.setCursor(2, 1);
          lcd.print(R2 / 1000000, 2);
          lcd.setCursor(10, 1);
          lcd.print("M ohm");
        }
        delay(1000);
        lcd.clear();
        break;
      }
    case (4): {

        int err;
        float temp, hum;
        if ((err = dht11.read(hum, temp)) == 0)
        {
          lcd.setCursor(0, 0);
          lcd.print("temp:");
          lcd.setCursor(9, 0);
          lcd.print(temp / 3);
          lcd.setCursor(14, 0);
          lcd.print("oC");
          lcd.setCursor(0, 1);
          lcd.print("humedad: ");
          lcd.setCursor(9, 1);
          lcd.print(hum / 3);
          lcd.setCursor(14, 1);
          lcd.print(" %");
        }
        else {
          lcd.setCursor(5, 0);
          lcd.print(err);
        }
        delay(1000);
        lcd.clear();
        break;
      }
    case (5): {
        if (digitalRead(48) == LOW) { // norma t 568A o ceuzado

          lcd.setCursor(0, 0);
          lcd.print(">UTP:T568A cross");
          delay(500);

          for (int n = 0; n < 8; n++) {

            lcd.setCursor(0, 1);
            lcd.print(n + 1);

            lcd.setCursor(2, 1);
            lcd.print(":a:");

            lcd.setCursor(5, 1);
            lcd.print(((int)cruzado[n] / 2) - 15);

            lcd.setCursor(7, 1);
            lcd.print(",(pin)");

            lcd.setCursor(13, 1);
            lcd.print((int)cruzado[n]);
            delay(1000);

            parpadeo(cruzado[n], 1000);
            parpadeo(50, 50);
          }
        } else { //Norma T 568 B o comun, paralelo

          lcd.setCursor(0, 0);
          lcd.print("UTP:T568B normal");
          delay(500);

          for (int n = 0; n < 8; n++) {

            lcd.setCursor(0, 1);
            lcd.print(n + 1);

            lcd.setCursor(2, 1);
            lcd.print(":a:");

            lcd.setCursor(5, 1);
            lcd.print(((int)directo[n] / 2) - 15);

            lcd.setCursor(7, 1);
            lcd.print(",(pin)");

            lcd.setCursor(13, 1);
            lcd.print((int)directo[n]);
            delay(1000);

            parpadeo(directo[n], 1000);
            parpadeo(50, 50);
          }
          delay(500);
          lcd.clear();
          break;
        }
      }
    case (6): {
        lcd.setCursor(0, 0);
        lcd.print("DOS O MAS SWITCH");
        lcd.setCursor(0, 1);
        lcd.print("HABILITADOS....!");
        delay(500);
        lcd.clear();
        break;
      }
    default : {
        lcd.setCursor(0, 0);
        lcd.print("no hay conexion!");
        char mensaje[26] = "   HABILITA UN SWITCH..!!";
        for (int i = 0; i < 25; i++) {
          lcd.setCursor(0, 1);
          for (int x = i; x < i + 16; x++) {
            if ((int)x >= 25)
            {
              lcd.print(mensaje[x - 25]);
            }
            else {
              lcd.print(mensaje[x]);
            }
          }
          delay(300);
        }
        lcd.clear();
        break;
      }
  }
}
void parpadeo(int pin, int ms)
{
  digitalWrite(pin, HIGH);
  lcd.setCursor(0, 1);
  delay(ms);
  digitalWrite(pin, LOW);

}

No hay comentarios.:

Publicar un comentario