So i started coding this simple project and im having no issues with the compiler, but the sensor output on the analogRead command only returns 0 or 1 depending on how i set the potentiometer on the sensor. heres the code
int SensorValue = analogRead (A5);
int SogliaSensore = 1;
int PinLedRosso = 2;
int PinLedBlu = 4;
int PinLedVerde = 7;
void setup() {
pinMode (PinLedRosso, OUTPUT);
pinMode (PinLedBlu, OUTPUT);
pinMode (PinLedVerde, OUTPUT);
pinMode (A5, INPUT);
Serial.begin(9600);
}
void loop() {
analogRead (A5);
Serial.println(SensorValue);
if (SensorValue > SogliaSensore) {
RGB_controller (255, 0, 0);
Serial.print ("Sensor: ");
Serial.println ("Gas Detected");
}
else
{
RGB_controller (0, 0, 255);
Serial.print ("Sensor: ");
Serial.println ("No Gas Detected");
}
delay(1000);
}
void RGB_controller (int Luminosita_rosso, int Luminosita_blu, int Luminosita_verde) {
digitalWrite( PinLedRosso, Luminosita_rosso);
digitalWrite( PinLedBlu, Luminosita_blu);
digitalWrite( PinLedVerde, Luminosita_verde);
}
ty in advance