Which code for using a LCD to count the moves of a servo


I am trying to run a test on an eyewear with a servo “inflicting pain” to the temples.

Having no clue how to code this, I have been using the "Exemple / Servo / Sweep code and set the angle required.

#include <Servo.h>
Servo myservo;
int pos = 0;
int count = 0;
void setup() {

void loop() {
for (pos = 55; pos <= 125; pos += 1) {
for (pos = 125; pos >= 55; pos -= 1) {
(count = count + 1);

I am now trying in vain to make the LCD count the moves of the servo but cannot find how to code it.
(the LCD circuits seem to be ok as all the Exemples / LiquidCrystal are working just fine.

Thank you very much for your help.


If you've got the examples from the LiquidCrystal library then you've got an example of how to both set up and print to the LCD. What part is giving you trouble?


If this is printing to the Serial Monitor application what you think it should, and you create an instance of the LiquidCrystal class in this sketch, and you add lcd.setCursor() (with valid arguments) and lcd.print(count); after this statement, the value in count should be shown on the LCD.