I’ve setup my arduino duemilanove to output to 3 digit 7-segment leds. I can print out any 3 digit combination manually. Now I want to use analog input from a temperature sensor to print out the numbers but I’m having problems with the analogRead function.
If I use the analogRead function, the LEDs print out gibberish.
If I comment out the analogRead function and manually set the digits, the LEDs output correctly.
This is my code for reading the temperature sensor:
The temperatureArray data will be used for the 3 7-segment LEDs. Right now I have manually entered data for it, but it’s showing gibberish if the analogRead() function is uncommented.
The expesssion “tempReading/1023” divides one integer by another probably resulting in an integer division, not a floating point division. Try change tempReading to a floating point and make the constant 1023 a real as in 1023.0
nonfiction:
I’ve setup my arduino duemilanove to output to 3 digit 7-segment leds. I can print out any 3 digit combination manually. Now I want to use analog input from a temperature sensor to print out the numbers but I’m having problems with the analogRead function.
If I use the analogRead function, the LEDs print out gibberish.
If I comment out the analogRead function and manually set the digits, the LEDs output correctly.
This is my code for reading the temperature sensor:
The temperatureArray data will be used for the 3 7-segment LEDs. Right now I have manually entered data for it, but it's showing gibberish if the analogRead() function is uncommented.
Do I need to set pinMode for the analog input?
Try making “byte temperatureArray[3];” defined in the definitions portion of the program. I’m wondering this as you are returning a pointer to an array that is on the stack (or heap, not sure of name) as it is local, and that gets destroyed when you exit the fuction.