Hi everyone!
i am currently doing a project with my manager and we need some help with some code.
The end game is too display frequency values and its mmH2O that its closest too.
i need some help getting the data from an excel file and then displaying that data on an LCD.
The code
#include <LiquidCrystal.h>
int ontime;
int offtime;
float freq;
float period;
float h20;
const int outputPin = 13;
int rs = 3;
int eE = 4;
int d4 = 5;
int d5 = 6;
int d6 = 7;
int d7 = 8;
LiquidCrystal lcd(rs,eE,d4,d5,d6,d7);
void setup()
{
pinMode(outputPin,INPUT);
lcd.begin(16,2);
lcd.clear();
lcd.print("Freq: ");
lcd.setCursor(0,1);
lcd.print("H2O: ");
}
void loop()
{
ontime = pulseIn(outputPin,HIGH);
offtime = pulseIn(outputPin,LOW);
period = ontime + offtime;
freq = 1000000.0/period;
h20 = (freq-44.712)/-0.0285493333;
if (period == 0)
{
freq = 0;
}
if(freq<1000)
{
lcd.setCursor(5,0);
lcd.print(freq);
lcd.print("Hz");
}
lcd.setCursor(4,1);
lcd.print(h20);
lcd.print("mm");
delay(1000);
}
Data from excel
Polynomial equation | Y | |
---|---|---|
1 | 44.64978683 | 1 |
2 | 44.62352548 | 2 |
3 | 44.5972165 | 3 |
4 | 44.57086043 | 4 |
5 | 44.54445783 | 5 |
6 | 44.51800925 | 6 |
7 | 44.49151522 | 7 |
8 | 44.46497629 | 8 |
9 | 44.43839299 | 9 |
10 | 44.41176587 | 10 |
11 | 44.38509546 | 11 |
12 | 44.35838228 | 12 |
13 | 44.33162687 | 13 |
14 | 44.30482976 | 14 |
15 | 44.27799146 | 15 |
16 | 44.25111251 | 16 |
17 | 44.22419342 | 17 |
18 | 44.1972347 | 18 |
19 | 44.17023688 | 19 |
20 | 44.14320046 | 20 |
21 | 44.11612596 | 21 |
22 | 44.08901388 | 22 |
23 | 44.06186473 | 23 |
24 | 44.03467901 | 24 |
25 | 44.00745722 | 25 |
26 | 43.98019985 | 26 |
27 | 43.95290742 | 27 |
28 | 43.9255804 | 28 |
29 | 43.89821929 | 29 |
30 | 43.87082457 | 30 |
31 | 43.84339674 | 31 |
32 | 43.81593628 | 32 |
33 | 43.78844366 | 33 |
34 | 43.76091937 | 34 |
35 | 43.73336389 | 35 |
36 | 43.70577768 | 36 |
37 | 43.67816122 | 37 |
38 | 43.65051497 | 38 |
39 | 43.62283941 | 39 |
40 | 43.595135 | 40 |
41 | 43.56740221 | 41 |
42 | 43.53964148 | 42 |
43 | 43.51185328 | 43 |
44 | 43.48403806 | 44 |
45 | 43.45619628 | 45 |
46 | 43.42832838 | 46 |
47 | 43.40043481 | 47 |
48 | 43.37251603 | 48 |
49 | 43.34457246 | 49 |
50 | 43.31660456 | 50 |
51 | 43.28861275 | 51 |
52 | 43.26059748 | 52 |
53 | 43.23255917 | 53 |
54 | 43.20449827 | 54 |
55 | 43.17641519 | 55 |
56 | 43.14831036 | 56 |
57 | 43.12018421 | 57 |
58 | 43.09203716 | 58 |
59 | 43.06386963 | 59 |
60 | 43.03568203 | 60 |
61 | 43.00747477 | 61 |
62 | 42.97924828 | 62 |
63 | 42.95100295 | 63 |
64 | 42.92273919 | 64 |
65 | 42.89445742 | 65 |
66 | 42.86615803 | 66 |
67 | 42.83784141 | 67 |
68 | 42.80950798 | 68 |
69 | 42.78115811 | 69 |
70 | 42.75279222 | 70 |
71 | 42.72441067 | 71 |
72 | 42.69601387 | 72 |
73 | 42.6676022 | 73 |
74 | 42.63917604 | 74 |
75 | 42.61073577 | 75 |
76 | 42.58228177 | 76 |
77 | 42.55381441 | 77 |
78 | 42.52533407 | 78 |
79 | 42.49684112 | 79 |
80 | 42.46833593 | 80 |
81 | 42.43981886 | 81 |
82 | 42.41129027 | 82 |
83 | 42.38275054 | 83 |
84 | 42.35420001 | 84 |
85 | 42.32563904 | 85 |
86 | 42.29706799 | 86 |
87 | 42.26848721 | 87 |
88 | 42.23989705 | 88 |
89 | 42.21129785 | 89 |
90 | 42.18268996 | 90 |
91 | 42.15407372 | 91 |
92 | 42.12544947 | 92 |
93 | 42.09681755 | 93 |
94 | 42.06817829 | 94 |
95 | 42.03953203 | 95 |
96 | 42.01087909 | 96 |
97 | 41.98221981 | 97 |
98 | 41.9535545 | 98 |
99 | 41.9248835 | 99 |
100 | 41.89620711 | 100 |
Please ask any questions you have!
Sorry if i am not very clear with what i need.