LED lighting up on Tinkercad us

Hello! I am trying to create a circuit on Tinkercad which is basically building circuits online. I am trying to make 3 LEDs light up for a specific range of temperature values using an inequality range. However I cannot get the LEDs to turn off outside the range. They either light up only above the lower bound or only below the upper bound.
The code:

const int ovulation_a = 96.98; //set lower ovulation parameter
const int ovulation_b = 98.6; //set upper ovulation parameter

void setup() {
pinMode(A2, INPUT); //sensor
pinMode(2, OUTPUT); //blue
pinMode(3, OUTPUT); //green
pinMode(4, OUTPUT); //red
Serial.begin(9600);
}

void loop() {
int sensor = analogRead(A2);
float voltage = (sensor / 1024.0) * 5.0;
float tempC = (voltage - .5) * 100;
float tempF = (tempC * 1.8) + 32;
Serial.print("temp: ");
Serial.print(tempF);

if (tempF >= ovulation_a && tempF <= ovulation_b) { //ovulating
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
Serial.println("Ovulating");
}

else { //not ovulating
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
Serial.println("Not Ovulating");
}

delay(10);
}

master_224:
const int ovulation_a = 96.98; //set lower ovulation parameter
const int ovulation_b = 98.6; //set upper ovulation parameter

Oops. Twice!

PS.: Please edit your post to add code tags before and after your code.

PS.: "Oops" is a macro:
#define Oops "There's something wrong here, maybe you should reconsider your code." :wink:
// (TheMemberFormerlyKnownAsAWOL, 24 maart 2021.)

I got it to work on my own, but thanks for the help!

set lower ovulation parameter

You do know what ovulation means in English?

Grumpy_Mike:
You do know what ovulation means in English?

Ovulation - Wikipedia

I am sure he does. :grinning:

Do you understand what the purpose of this project is, Mike?

Actually, a single temperature reading is quite useless, it requires daily readings, preferably of vaginal temperature before getting out of bed in the morning at approximately the same time, and comparing them looking for a distinct rise in temperature not an absolute reading.

I never found it particularly effective. Maybe if incorporated into an "intelligent" retained ring pessary using BLE which I believe has been done. :sunglasses:

 const int ovulation_a = 96.98; //set lower ovulation parameter

But an integer specified to two decimal places!

Yeah Paul that is exactly what I have been trying to do. I added more to the circuit to try and make it more adaptable to everyday use. Actually it is a necklace rather than a ring. I included an accelerometer to try and understand when the person is at rest so that would be when the temperature is measured. And to make it more precise I added a code which will measure and calculate the mean temperature when the user is at rest so that it is more personalized. If you are curious I can share the code with you. Also I am having some difficulties at the moment with getting it to work as I want it to but should be there by tomorrow!

In order to work, the device must be worn internally. :astonished:

The most obvious version as I pointed out, would be a ring pessary! :sunglasses:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.