I am using a maxim 7221 to drive 4 7 segment LEDs
This is the code:
http://codepad.org/DAirbBAE
I get bizzare readings from the 7 segments
like "99 F"
or even "8A F"
I dont know what the problem is!
The temperature is legit
please help!
I am using a maxim 7221 to drive 4 7 segment LEDs
This is the code:
http://codepad.org/DAirbBAE
I get bizzare readings from the 7 segments
like "99 F"
or even "8A F"
I dont know what the problem is!
The temperature is legit
please help!
make sure the LedControl is getting the correct values using the serial comm interface first. Arduino doesn't do in-chip debugging so you've got to use serial I/O and debug statements to see what is going on.
Try this:
Add this to the end of your setup() function:
Serial.begin(115200);
Serial.println("Setup() - 0");
make you loop() function look like this:
// new for debugging via serial port
// comment out when not debugging
#define DEBUG true
void loop(){
val = analogRead(thermometer);
int temp = val / 2.05;
ones = temp % 10;
tens = temp / 10;
#ifdef DEBUG
Serial.print("raw Val=");Serial.print(val);
Serial.print(": raw temp="); Serial.println(temp);
Serial.print("ones=");Serial.print(ones);
Serial.print(": tens=");Serial.println(tens);
#endif
lc.setDigit(0,2,tens,false);
lc.setDigit(0,3,ones,false);
lc.setChar(0,0,'F',false);
lc.setChar(0,1,' ',false);
delay(500);
}
Look under your Arduino IDE to setup your Serial port. You'll find the settings in the mentu: Tools-Serial
Once this is setup, load the code, then click the Serial Monitor button on the Arduino IDE to see the output from your program and see where it might be going wrong.
Ok - I forgot to clear the display at the end... but I still get weird values like a value of 78 will fluctuate between 68, 78 and 88 ... maybe the circuit has a problem...
also the led-matrix library does not work when trying to send the characters u,U and R... can anyone replicate this?
maybe you want to average the temp readings to smooth out the noise. I found this helped me but not using 7-seg display, I used an LCD.
Ok now I get the temp and an F to display but weirdness ensues...
I also have a led turning on and off to help me debug the code. And its really weird... It is supposed to turn on an off very slowly.. but instead it sometimes blinks VERY FAST and sometimes normal speed. And sometimes the F will disappear for a while.. and after a while the program stops updating the 7 segments... totally bizzare... anyone have experiences like this?
//We always have to include the library
#include "LedControl.h"
/*
Now we need a LedControl to work with.
***** These pin numbers will probably not work with your hardware *****
pin 12 is connected to the DataIn
pin 11 is connected to the CLK
pin 10 is connected to LOAD
We have only a single MAX72XX.
*/
LedControl lc=LedControl(12,11,10,1);
#define thermometer 5
long val = 0;
int ones = 0;
int tens = 0;
int dec = 0;
void setup() {
analogReference(DEFAULT);
lc.shutdown(0,false);
/* Set the brightness to a medium values /
lc.setIntensity(0,1);
/ and clear the display */
lc.clearDisplay(0);
}
void loop(){
val = analogRead(thermometer);
int temp = val / 2.05;
ones = temp % 10;
tens = temp / 10;
lc.setDigit(0,2,ones,false);
lc.setDigit(0,3,tens,false);
lc.setChar(0,0,'F',false);
lc.setChar(0,1,' ',false);
digitalWrite(13, HIGH);
delay(2000);
digitalWrite(13,LOW);
delay(2000);
lc.clearDisplay(0);
}