fork download
  1. #include <stdio.h>
  2.  
  3. int NTC_TempConversion(int ad, int ADC_REF_VCC, int ADC_PRECISION, int R25, int B, int R1 ) {
  4. double d = ad;
  5. d=d*R1/((1<<ADC_PRECISION)-d);
  6. d/=R25;
  7. d = log(d);
  8. d/=B;
  9. d+=(double)1/298;
  10. if(d==0)d =1;
  11. d=1/d;
  12. d-=273;
  13.  
  14. return (int)(d);
  15. }
  16.  
  17.  
  18. int main(void) {
  19. int x;
  20. x = NTC_TempConversion(50,5,10,100000,3950,200000);
  21. printf("%d\n", x);
  22. return 0;
  23. }
Success #stdin #stdout 0s 5312KB
stdin
1
2
10
42
11
stdout
86