Go Down

Topic: Love-o-meter not working? (Read 2955 times) previous topic - next topic

Lawtown

Aug 21, 2018, 04:15 am Last Edit: Aug 21, 2018, 04:25 am by Lawtown
Hey guys, so a couple weeks back i posted something about my code not working for my project. Well i fixed that issue and finally found myself with time again to finish up the project but ran into something else. After making sure the code was fine and uploading it, i the LEDs do not light up or anything. Like if i open up the serial monitor i can see a bunch of data and it seems that the temperature sensor might be working but i'm not sure. I'll upload pictures of my set up along with my code, just in case there is something wrong with either.

Code: [Select]
Serial.print(sensorVal);
// Convert the ADC reading to voltage
float voltage = (sensorVal/1024.0)*5.0;
Serial.print(" ,Volts: ");
Serial.print(voltage);
Serial.print(" , degrees C: ");
// convert the voltage to temperature in degrees
float temperature = (voltage - .5) * 100;
Serial.print(temperature);
if(temperature < baselineTemp+2){
  digitalWrite(2,LOW);
  digitalWrite(3,LOW);
  digitalWrite(4,LOW);
  }else if(temperature >= baselineTemp+2 && temperature < baselineTemp+4){
    digitalWrite(2,HIGH);
    digitalWrite(3,LOW);
    digitalWrite(4,LOW);
  }else if(temperature >= baselineTemp+4 && temperature < baselineTemp+6){
    digitalWrite(2,HIGH);
    digitalWrite(3,HIGH);
    digitalWrite(4,LOW);
  } else if(temperature >= baselineTemp+2 && temperature < baselineTemp+6){
    digitalWrite(2,HIGH);
    digitalWrite(3,HIGH);
    digitalWrite(4,HIGH);
  }
  delay(1);
}



https://imgur.com/a/vPYvhq7

https://imgur.com/a/lSQTUXB

https://imgur.com/a/bpO0e3L

pert

When you are having troubles the first thing to do is always to remove as much complexity as possible. Right now the problem could be the circuit, the sensor, the code, the Arduino, or the LEDs. Modify the File > Examples > 01.Basics > Blink example sketch to just blink one of the LEDs.

Lawtown

When you are having troubles the first thing to do is always to remove as much complexity as possible. Right now the problem could be the circuit, the sensor, the code, the Arduino, or the LEDs. Modify the File > Examples > 01.Basics > Blink example sketch to just blink one of the LEDs.
So i got one of the LEDs to blink, then i re-uploaded the code for the project again and now only two LEDs turn on. Tried to change the temperature around the sensor by putting my hand around it and other things, however, the LEDs stayed the same, so might it seems that it could still be either the sensor or the circuit right?

pert

You should do the blink test on each of the LEDs to make sure they are all working.

To test the sensor, you will want to print its readings to Serial Monitor and verify that it's reading the temperatures you expect. It looks like the Love-O-Meter sketch already does that so it's not necessary to write a separate test sketch for the sensor. I would increase the delay at the end of loop() to 500 so that it's not printing so fast to Serial Monitor.

Go Up