Go Down

Topic: Help Displaying Temp On Two 7-Pin LEDs (Read 1 time) previous topic - next topic

jmi0920

Hi  :), I've recently been working on a project with a school arduino for a week now, I was wondering if I could get any help. I've been trying to get the temperature to display on 2 7-segment LEDs buy taking the readings off of a thermistor. Every thing is wired up correctly and I got the LEDs to display correct numbers, but I've been having an issue will it will read the temp, and stay stuck at 69, or 79, well any number always ending with a 9.
http://www.textswell.com/read,4206226243772
here's my coding, any help would be appreciated, also so would a correct temperature conversion.
Thanks

Arrch

Not how you write an if statement:
Code: [Select]
if (temp = 60)

Correct way:
Code: [Select]
if (temp == 60)

jmi0920

Went back and switched them all to "==", but I still have an issue :/.
On the serial monitor, temp reads as 63-64, but no matter what, the two LEDs will only display 69.

MarkT

You really really need to find out about arrays and look at examples of much simpler 7-segment LED drivers out there!

You probably still have  "if (temp = 69)" in your code by the sound of it.

At the very least you should (re)factor the code to avoid all the dumb repetition, something like this as a framework would be a start:

Code: [Select]

void loop ()
{
  read () ;
  int high_digit = temp / 10 ;
  int low_digit = temp % 10 ;
  switch (high_digit)
  {
  case 0:  .... ; break ;
  case 1:  .... ; break ;
  case 2:  .... ; break ;
  ....
  case 9:  .... ; break ;
  }
  switch (low_digit)
  {
  case 0:  .... ; break ;
  case 1:  .... ; break ;
  case 2:  .... ; break ;
  ....
  case 9:  .... ; break ;
  }
  delay (10) ;   // allow time to pass to reduce LED flicker
}


But there's more to do to clean it up - and learn a lot in the process I think.
[ I won't respond to messages, use the forum please ]

jmi0920

I looked over the code, all "=" are gone and it's only "==". I learned a bit on arrays in programming in java last year, most of which I totally forget, would you mind giving a brief/basic rundown on the code you posted?

Go Up