Hello,
I was playing with a cheap soil humidity sensor, hooked it up properly and wrote a code, but no matter what I do the serial monitor keeps printing "14". I tried several codes and none of them seemed to change anything. I even tried another arduino board.
int sensorPin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int hum = analogRead(sensorPin);
serial.print(hum);
delay(1000);
}
I'm a real noob when it comes to arduino and programming but I didn't find any answers on the internet and I want to learn how to avoid mistakes like this one.
It's pretty common for sensors to be associated with some form of library, often requiring a #include <libraryname.h> directive near the top of the source file. Does the sensor you're using not use any libraries in the code examples?
I've checked few tutorials and there is no libraries included, or I'm just extremely retarded.
Even if it needed one, why "14" over and over again? Maybe there's something wrong with the sensor.
I've done much much more complicated projects and had no problems, now I cant even get it to print sensor's value.
Don't call my code junk, it DOES compile and that's really it.
Really, I didn't write anything more 'cause I got upset with what I have so far.
As I said I don't really know much about programming but all my projects went without problems.
As I said the code I posted does compile in my case and it keeps repeating "14".
I'm a little ashamed that I got angry while You were trying to help me, I just got it to work, deleted the old code and wrote it differently.
I would say it is rare to an analog sensor alllways giving you exactly the same reading 14. It means something like 14/1024*5V or so. Usually sensors can't make up their mind. Can you measure voltage from the sensor?