Help Needed C Programming

Thread Starter

Ralf

Joined Mar 16, 2009
31
i have a problem with this:

let say i type in 7 and it will display a 25
and the max i can type in is 10 and the display number max will be 29

how to i program with this condition using C language?

sorry if u all don't understand what i trying to ask.. please let me know that the information is not clear, so that i can ask my friend to help me rephrase.
 

thatoneguy

Joined Feb 19, 2009
6,359
What is the formula to convert 7-> 25 and 10->29

When you say the Max would display as 29, are there other numbers it could display when 10 is entered?

Are the numbers base 10, hexadecimal, octal, or "other"?

What are you using for a keypad for numeric entry?

Which microcontroller/compiler? (this doesn't matter too much, but they aren't all perfectly compatible)
 

Shmurk

Joined Aug 13, 2007
24
I know nothing about it but here's a beginning of a solution:

7 is 25, 10 is 29, which "could" mean that we increase the value with 4/3 at each step, like this:
  • 7 -> 75/3
  • 8 -> 79/3
  • 9 -> 83/3
  • 10 -> 87/3
and if we go "down" instead, the first value is: 0 -> 47/3.

So a formula "could" be: f(x) = 47/3 + (x * 4/3), which is in C:
Rich (BB code):
float f(float x) {
    return 47.0/3.0 + (x * 4.0/3.0);
}
Edit: If the "max" is 10, then the code would be:
Rich (BB code):
float f(float x) {
    if (x >= 10) return 29;
    return 47.0/3.0 + (x * 4.0/3.0);
}
or something...
 
Last edited:

Thread Starter

Ralf

Joined Mar 16, 2009
31
to thatoneguy

1st qns: no.. the max is 10. and it must display a 29 on my 2 LED
2nd qns: is a decimal number
3rd qns: is a thermistor that sense temperature and i will convert this using ADC to display in 7 segment.
4th qns: Microchip PIC18f24k20 , is a C compiler( when i install C compiler it include mcc18 file inside.)
 
Top