Skip to content

Commit

Permalink
Changed variables for floating point math
Browse files Browse the repository at this point in the history
  • Loading branch information
k105la committed Aug 6, 2020
1 parent bf22a65 commit caede89
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion board/driver/mpx5100.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define MPX5100_H

#include "../driver/adc.h"
#define MAX_PRESSURE 120 // Pressure in KPa
#define MAX_PRESSURE 120.0 // Pressure in KPa

float pascal, adc_val;
void getPascal(void);
Expand Down
2 changes: 1 addition & 1 deletion board/mpx5100/mpx5100.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

void getPascal(void) {
adc_val = adcRead();
pascal = ((adc_val / 1023) * MAX_PRESSURE) * 1000;
pascal = ((adc_val / 1023.0) * MAX_PRESSURE) * 1000.0;
printf("%.2f Pa\n" pascal);
}

0 comments on commit caede89

Please sign in to comment.