Pages: [1]   Go Down
Author Topic: Help Displaying Temp On Two 7-Pin LEDs  (Read 1576 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi  smiley, 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
Logged

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3375
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Correct way:
Code:
if (temp == 60)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12048
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12048
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Post your code as it is now, I'm sceptical about the = / == thing smiley-wink

I'll leave you to the learning process - find some other 7-segment driver code and read it - and find out how it all works, it will be a very useful exercise.
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.textswell.com/read,4206253715402
Unless I'm blind (very possible) There is no more "=" left lol
Logged

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12048
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  void loop()
  {
    read();
   
    {
    if (temp >= 60 && temp < 70)
   
      if (temp == 60)
      {
        showLED6();
        showL0();
      }

See the problem?
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does the "(temp >= 60 && temp < 70)" have to be ">== 60" aswell?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Tried didn't compile, but I saw that there weren't braces after the (temp >= 60 && temp < 70) part, is that it?
Logged

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3375
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

is that it?

You're the one with the hardware already hooked up and ready to test. Fix the issue and let us know.
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 35
Posts: 4299
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you give him the fish you will get Karma.
If you give him fishing lessons he will just get mad at you.
Isn't Karma great?  They got rid of it once, I wonder how long it will take this time.

Don
Logged

Pages: [1]   Go Up
Jump to: