Hi everyone, I hope you are all well, I'm not so much, I do not speak much English so I counted on the help of google translator to write.
I am facing serious problems with my source code while compiling in the Arduino IDE, it gives the error in the following passage: sensor = analogRead (A5); And says: sensor not declared in this scope.
I ask for your help. grateful.
here is the code:
int bomba = 8;
#define SP 95
void setup() {
Serial.begin(9600);
pinMode (A5, INPUT);
pinMode (8, OUTPUT);
// put your setup code here, to run once:
}
void loop(){
int sensor = analogRead(A5);
if (sensor > SP){
digitalWrite (bomba, HIGH);
// put your main code here, to run repeatedly:
}
else{
digitalWrite (bomba, LOW);
}
Serial.print("valor do sensor de humidade do solo: ");
Serial.println(sensor);
delay(1000);
}
Artino:
Hi everyone, I hope you are all well, I'm not so much, I do not speak much English so I counted on the help of google translator to write.
I am facing serious problems with my source code while compiling in the Arduino IDE, it gives the error in the following passage: sensor = analogRead (A5); And says: sensor not declared in this scope.
I ask for your help. grateful.
here is the code:
int bomba = 8;
#define SP 95
void setup() {
Serial.begin(9600);
pinMode (A5, INPUT);
pinMode (8, OUTPUT);
// put your setup code here, to run once:
}
void loop(){
int sensor = analogRead(A5);
if (sensor > SP){
digitalWrite (bomba, HIGH);
// put your main code here, to run repeatedly:
}
else{
digitalWrite (bomba, LOW);
}
Serial.print("valor do sensor de humidade do solo: ");
Serial.println(sensor);
delay(1000);
}
it compiled fine for me, but I got a warning about #define SP... so in arduino it is already defined
try:
#define SP_VALUE 95
int bomba = 8;
void setup() {
Serial.begin(9600);
pinMode (A5, INPUT);
pinMode (8, OUTPUT);
}
void loop()
{
int sensor = analogRead(A5);
if (sensor > SP_VALUE)
{
digitalWrite (bomba, HIGH);
// put your main code here, to run repeatedly:
}
else
{
digitalWrite (bomba, LOW);
}
Serial.print("valor do sensor de humidade do solo: ");
Serial.println(sensor);
delay(1000);
}
Ohh worked, thank you very much.