Anyone help please i have a errors in this program. The error tell the Value not declared in this scope. But from the code, I already declared that value. Is there any problem with void loop () {} ?
This program also have current sensor type SCT013 100A:50mA
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows NT (unknown)), Board: "Arduino Uno"
kop.ino: In function 'void loop()':
kop:6: error: 'Current2' was not declared in this scope
kop:6: error: 'x' was not declared in this scope
kop:10: error: 'Current3' was not declared in this scope
kop:14: error: 'Current4' was not declared in this scope
kop:18: error: 'Current' was not declared in this scope
kop:27: error: 'Watt' was not declared in this scope
kop:28: error: 'Price' was not declared in this scope
kop:29: error: 'TPrice' was not declared in this scope
kop:29: error: 'IPrice' was not declared in this scope
kop:30: error: 'Highest' was not declared in this scope
kop:35: error: 'Highest' was not declared in this scope
kop:38: error: 'RMSCurrent' was not declared in this scope
kop:40: error: 'Power' was not declared in this scope
kop:41: error: 'kWh' was not declared in this scope
kop:42: error: 'Price' was not declared in this scope
kop:43: error: 'Watt' was not declared in this scope
kop:44: error: 'TPrice' was not declared in this scope
kop:44: error: 'IPrice' was not declared in this scope
kop:48: error: 'lcd' was not declared in this scope
kop:50: error: 'Watt' was not declared in this scope
kop:54: error: 'TPrice' was not declared in this scope
kop:61: error: 'class HardwareSerial' has no member named 'printIn'
kop:62: error: 'IPrice' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows NT (unknown)), Board: "Arduino Uno"
kop:8: error: expected initializer before 'void'
kop:7: error: expected initializer before 'void'
Hi, thanks for feedback.
Next, I try to declare all the variable,
But, I got some problem at lcd and class HardwareSerial variable. But I think I already declared the LCD library.
Here my new code
// include the library code:
#include <LiquidCrystal.h>
#include <iostream>
#include <string>
using namespace std;
int Current2 ;
int Current3 ;
int x;
int Current4;
int Watt;
int TPrice ;
int IPrice;
int Current;
int Price;
int Highest ;
int RMSCurrent;
int Power;
int kWh;
int lcd;
int main ()
{
float sensorValue2 = analogRead(A1);
Current2 =abs((sensorValue2-x)*710.9/1023);
delay (200);
float sensorValue3 = analogRead(A1);
Current3 =abs((sensorValue3-x)*710.9/1023);
delay (200);
float sensorValue4 = analogRead(A1);
Current4 =abs((sensorValue4-x)*710.9/1023);
delay (200);
float sensorValue = analogRead(A1);
Current =abs((sensorValue-x)*710.9/1023);
if (Current < 0.7)
{
if (Current2 < 0.7)
{
if (Current3 < 0.7)
{
if (Current4 < 0.7)
{ Watt = 0;
Price = 0;
TPrice = Price + IPrice;
Highest = 0;
}
}
}
if (Current>Highest)
{
Highest = Current;
RMSCurrent = Highest/sqrt(3);
Power - (RMSCurrent* 225/1000);
kWh = (Power * 1/3600);
Price - (kWh * 021.80);
Watt = Highest * 240;
TPrice - Price + IPrice;
}
}
lcd.setCursor(0, 0);
lcd.print("Power(Watt):");
lcd.print(Watt);
lcd.setCursor(0, 1);
lcd.print("Price(Cent):");
lcd.print(TPrice);
Serial.print(sensorValue);
Serial.print(" = ");
Serial.print(sensorValue2);
Serial.print(" = ");
Serial.print(sensorValue3);
Serial.print(" = ");
Serial.printIn(sensorValue4);
IPrice = IPrice;
delay(400);
}
The error I got is :
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows NT (unknown)), Board: "Arduino Uno"
kop.ino: In function 'int main()':
kop:67: error: request for member 'setCursor' in 'lcd', which is of non-class type 'int'
kop:68: error: request for member 'print' in 'lcd', which is of non-class type 'int'
kop:69: error: request for member 'print' in 'lcd', which is of non-class type 'int'
kop:71: error: request for member 'setCursor' in 'lcd', which is of non-class type 'int'
kop:72: error: request for member 'print' in 'lcd', which is of non-class type 'int'
kop:73: error: request for member 'print' in 'lcd', which is of non-class type 'int'
kop:80: error: 'class HardwareSerial' has no member named 'printIn'
If it compiles and works that's good, but does it do what you want ? Does the setup() function ever get executed and how many times does the program read the sensors and what does it do with the readings anyway ?
Is there a reason why you felt the need to write your own main() function instead of using the one in the Arduino environment ?