# Output force readings on LCD from 4 inputs

Discussion in 'Embedded Systems and Microcontrollers' started by Amy Yu, Oct 18, 2015.

1. ### Amy Yu Thread Starter New Member

Oct 14, 2015
5
0
'm dealing a project that requires 4 force sensors as analog input of Arduino Uno and output the force readings on a 16x2 LCD. It's actually for the assessment of each finger strength of the rehab patient while using the device as illustrated in the figure below. I'm completely new to this, but I have found somebody posted the coding for displaying the force consecutively. I would like to know if it is possible to display the forces simultaneously, or someone has a better idea on how to make this works? Need advices for coding as well, thanks very much!

Code (C):
1.
2. int fsrVoltage; // the analog reading converted to voltage
3. int fsrVoltage1;
4. unsigned long fsrResistance; // The voltage converted to resistance, can be very big so make "long"
5. unsigned long fsrResistance1;
6. unsigned long fsrConductance;
7. unsigned long fsrConductance1;
8. long fsrForce; // Finally, the resistance converted to force
9. long fsrForce1;
10.
11. #include <Wire.h>
14.
16. void setup()
17. {
18.
19. lcd.begin(16, 2);
20.
21. Serial.begin(9600);
22.
23. }
24.
25. void loop()
26. {
27.
28.
31.
32. fsrVoltage = map(force, 0, 1023, 0, 5000);
33.
34. // The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V
35. // so FSR = ((Vcc - V) * R) / V yay math!
36. fsrResistance = 5000 - fsrVoltage; // fsrVoltage is in millivolts so 5V = 5000mV
37. fsrResistance *= 10000; // 10K resistor
38. fsrResistance /= fsrVoltage;
39. fsrConductance = 1000000; // we measure in micromhos so
40. fsrConductance /= fsrResistance;
41.
42. fsrVoltage1 = map(force1, 0, 1023, 0, 5000);
43.
44. // The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V
45. // so FSR = ((Vcc - V) * R) / V yay math!
46. fsrResistance1 = 5000 - fsrVoltage1; // fsrVoltage is in millivolts so 5V = 5000mV
47. fsrResistance1 *= 10000; // 10K resistor
48. fsrResistance1 /= fsrVoltage1;
49. fsrConductance1 = 1000000; // we measure in micromhos so
50. fsrConductance1 /= fsrResistance1;
51.
52.
53.
54. // Use the two FSR guide graphs to approximate the force
55. if (fsrConductance <= 1000)
56. {
57. fsrForce = fsrConductance / 80;
58. lcd.setCursor(0, 0);
59. lcd.print("Force for 1st FSR: ");
60. lcd.setCursor(0, 1);
61. lcd.print(fsrForce,DEC);
62. } else
63. {
64. fsrForce = fsrConductance - 1000;
65. fsrForce /= 30;
66. lcd.setCursor(0, 0);
67. lcd.print("Force for 1st FSR: ");
68. lcd.setCursor(0, 1);
69. lcd.print(fsrForce,DEC);
70. }
71. delay(5000);
72.
73. if (fsrConductance1 <= 1000)
74. {
75. fsrForce1 = fsrConductance1 / 80;
76. lcd.setCursor(0, 0);
77. lcd.print("Force for 2nd FSR: ");
78. lcd.setCursor(0, 1);
79. lcd.print(fsrForce1,DEC);
80. }
81. else
82. {
83. fsrForce1 = fsrConductance1 - 1000;
84. fsrForce1 /= 30;
85. lcd.setCursor(0, 0);
86. lcd.print("Force for 2nd FSR: ");
87. lcd.setCursor(0, 1);
88. lcd.print(fsrForce1,DEC);
89. }
90. delay(200);
91. }
92.
Moderators note: used code=c tags

Last edited by a moderator: Oct 18, 2015
2. ### GopherT AAC Fanatic!

Nov 23, 2012
6,069
3,839

Every character on a 2x16 can be addressed individually and you can certainly display each value as needed in a given position on the display. There is a good tutorial on LCD displays - an old two part document from EDN article (I think).