Hi i've just got into Arduinos and programming and its great,
Ive made this Cable tester that lets you see voltage drop and resistance on an LCD screen and notifies you when the cable is broken.
This only works with one cable attached, i would like to expand the code so it checks 3 cables via my arduino mega analog inputs, but i'm at a loss on how to add extra inputs into my code and have it work the same, could someone have a look and advise?
ive attached Code and a screen shot of the wiring.
Many Thanks
Dan
#include <LiquidCrystal.h>
LiquidCrystal lcd(4, 6, 10, 11, 12, 13);
int analogPin = 1;//Read
int raw = 0;
int Vin = 5;// Voltage from Arduino
float Vout = 0;
float R1 = 220;
float R2 = 0;
float buffer = 0;
void setup()
{
lcd.begin(16, 2);
}
void loop()
{
raw = analogRead(analogPin);
if (raw)
{
buffer = raw * Vin;
Vout = (buffer) / 1024.0;
buffer = (Vin / Vout) - 1;
R2 = R1 * buffer;
if (R2 > 1000 )
{
lcd.print("Broken cable");
delay(1000);
lcd.clear();
delay(5);
}
else (R2 != 225060);
{
lcd.setCursor(0, 1);
lcd.print(5 - Vout, 1);
lcd.print("V");
lcd.setCursor(9 - 11, 0);
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print(R2, 0);
lcd.print(" Ohms");
delay(1000);
lcd.clear();
delay(5);
}
}
}
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.
