Go Down

Topic: New with sensors (Read 1 time) previous topic - next topic

Graynomad

So what's with the code? Just print the values you're getting from the sensor to the serial monitor to get an idea of what's happening.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

tege88


tege88

when I do it, it just keeps coming up with 0

Graynomad

Post the actual code you are using and a schematic or description of the circuit you have.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Erni


int sensorValue = 0;

The sensorvalue could be between 0 and 1023, so you should use

unsigned long sensorValue = 0;

and your test for starting the fan somthing like

if (sensorValue >500){

digitalWrite(fanPin, HIGH);
delay(5000);
digitalWrite(fanPin, LOW);


}

Go Up