This is my first time using an Arduino and I have everything working except that instead of one LED going on, I have both. I'll paste my code in below so that anyone can maybe see where my problem is.
I want the yellow LED to go on if the Fahrenheit Temperature is below 70, otherwise the red LED should come on.
The problem I am getting is that they are both coming on and I don't know why. It's my first semester in college, so I'm sure it's something stupid that I've done.
//Input
int tempPin = A0;
int temp = 0;
int tempC = 0;
int tempF = 0;
int redLed = 13, yellowLed = 12;
void setup() { Serial.begin(9600);
pinMode (redLed, OUTPUT); // Red LED for tempF >= 70
pinMode (yellowLed, OUTPUT); // Yellow LED for tempF < 70
}
Thank you jurs. That was my problem. I simply used the first example you gave and it worked. My issue was I was trying to figure out how to put together and LED-only example and a Temperature Sensor-only example and I didn't too too good of a job.
I didn't fully understand the way the connections are made and once I looked at what you wrote and adjusted my connections, it worked! I'm glad I understand the basics now. I'm sure my next project will come much easier.