thought the problem might be electrical but ill attatch the code for you to look at.
but I get about 1.1 amps when i do the maths there so its a little out.
cheers
#include <LiquidCrystal.h>
LiquidCrystal lcd(13,12,11,10,9,8);
// These constants won't change:
const int analogPin = A4; // pin that the sensor is attached to
const int ledPin = 6; // pin that the LED is attached to
const int threshold = 365; // an arbitrary threshold level that's in the range of the analog input
int analoginput0 = 3; //analoge pin 2
int analoginput1 = 4; //analoge pin 5
float vout1 = 0.0;
float vout2 = 0.0;
int value1 = 0;
int value2 = 0;
float R1 = 5100.0; // !! resistance of R1 !!
float R2 = 2193.0; // !! resistance of R2 !!
float vin1 = 0.0;
float vin2 = 0.0;
void setup(){
lcd.begin (16,2);
lcd.setCursor (5,0);
lcd.print ("G'day");
delay (1000);
lcd.setCursor (6,1);
lcd.print ("Mate");
delay (2000);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize serial communications:
Serial.begin(9600);
// declaration of pin modes
pinMode(analoginput0, INPUT);
pinMode(analoginput1, INPUT);
lcd.begin(16, 2);
}
void loop(){
// read the value on analog input
value1 = analogRead(analoginput0); //voltage value
vout1 = (value1 * 4.555)/1023.0;
vin1 = vout1 / (R2/(R1+R2));
value2 = analogRead(analoginput1); //Amp output
vout2 = (value2 * 4.555)/1023.0; //4.555=voltage threshold (1023=4.555V);
vin2 = vout2*2; //vin2 = value2;
lcd.setCursor(12,0);
lcd.print(" ");
lcd.setCursor(8,0);
lcd.print(vin1+0.1);
lcd.setCursor(8,1);
lcd.print(vin2);
lcd.setCursor(0,0);
lcd.print("Volts");
lcd.setCursor(0,1);
lcd.print("Amps");
// read the value of the potentiometer:
int analogValue = analogRead(analogPin);
// if the analog value is high enough, sound alarm:
// if (analogValue > threshold)
if (vin2 > 3.2) // Set amp alarm value
{
digitalWrite; //(ledPin, HIGH); //ledpin for led
tone(7, 3);
delay(100);
}
else{
digitalWrite(ledPin,LOW);
noTone(7);
}
delay(100);
}
(code symbols added by moderator)