Led blinker example code does not work

Hello, I have this LED blinker example code, that does not want to run.
exit status 1
'class Rotary' has no member named 'process'

#include <EnableInterrupt.h>
#include <Rotary.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

int encoder0Pos = 4;  //--start_value 4*50 =200 mSec---]
int encoder1Pos = 4;
int encoder2Pos = 4;
int encoder3Pos = 4;
float interVal_1 = 0;
float interVal_2 = 0;
float interVal_3 = 0;
float interVal_4 = 0;
float freq_1 = 0;
float freq_2 = 0;
float freq_3 = 0;
float freq_4 = 0;

const int encoderButton = 4;  
const int leftButton = 5; 
const int rightButton = 6; 
int leftButtonState = 0;
int rightButtonState = 0;
int lastrightButtonState = 0;
int lastleftButtonState = 0;
int encoderState = 0; 
int lastencoderState = 0;
int encoderCounter = 0;
int dir_upState = 0;
int dir_downState = 0;

Rotary r = Rotary(2, 3);

//----------Create-Arrow-up-sign------------------------------
byte Arrow_down[] = {
  B00100,
  B00100,
  B00100,
  B00100,
  B00100,
  B10101,
  B01110,
  B00100
};
//----------Create-Arrow-down-sign------------------------------
byte Arrow_up[] = {
  B00100,
  B01110,
  B10101,
  B00100,
  B00100,
  B00100,
  B00100,
  B00100
};

const int ledPin1 =  8;      // the number of the LED pin
const int ledPin2 =  9;      
const int ledPin3 =  10;      
const int ledPin4 =  11;      

// Variables will change :
int ledState1 = LOW;         // ledState used to set the LED
int ledState2 = LOW;             
int ledState3 = LOW;             
int ledState4 = LOW;             

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis1 = 0;  // will store last time LED was updated
unsigned long previousMillis2 = 0; 
unsigned long previousMillis3 = 0;  
unsigned long previousMillis4 = 0; 

//-------------SETUP-----------------------------
void setup() {

  enableInterrupt(2, interruptFunction, CHANGE);
  enableInterrupt(3, interruptFunction, CHANGE);
  pinMode(encoderButton, INPUT);
  pinMode(leftButton, INPUT);
  pinMode(rightButton, INPUT);
  
  lcd.begin(16, 2);
  lcd.createChar(0, Arrow_down);
  lcd.createChar(1, Arrow_up);
  lcd.setCursor(0,0); //go to column 2 of row 1 
  lcd.print("Rotary Encoder  "); // Print text on the LCD.
  lcd.setCursor(0,1); //go to column 2 of row 1  
  lcd.print("menu project    "); // Print text on the LCD.
  delay(1500);
  lcd.clear();
  Serial.begin(9600);
}

void loop() {

//--------------pushbutton encoder---------------------
 freq_1 = (1/interVal_1)*1000;
 freq_2 = (1/interVal_2)*1000;
 freq_3 = (1/interVal_3)*1000;
 freq_4 = (1/interVal_4)*1000;
 
 encoderState = digitalRead(encoderButton);
 leftButtonState = digitalRead(leftButton);
 rightButtonState = digitalRead(rightButton);
 


  // compare the buttonState to its previous state
  if (encoderState != lastencoderState) {
    // if the state has changed, increment the counter
    if (encoderState == HIGH ) {
      // if the current state is HIGH then the button went from off to on:
      encoderCounter++;
      }
    }
  lastencoderState = encoderState;

  if (rightButtonState != lastrightButtonState) {
    // if the state has changed, increment the counter
    if (rightButtonState == HIGH ) {
      // if the current state is HIGH then the button went from off to on:
      encoderCounter++;
      }
    }
    
  
  lastrightButtonState = rightButtonState;  // save the current state as the last state, for next time through the loop

 // compare the buttonState to its previous state
  if (leftButtonState != lastleftButtonState) {
    // if the state has changed, increment the counter
    if (leftButtonState == HIGH && encoderCounter >1) {
      // if the current state is HIGH then the button went from off to on:
      encoderCounter--;
      }
    }
  // save the current state as the last state, for next time through the loop
 
  lastleftButtonState = leftButtonState;
  

 //--------------counter-pushbutton-encoder---------------------------------
  if (encoderCounter > 6) {
      encoderCounter = 0;
  } 
    interVal_1 = encoder0Pos *50; // Interval*50 in order to increse interval with 50 mSec [this because encoderPos+50 not working]
    interVal_2 = encoder1Pos *50; 
    interVal_3 = encoder2Pos *50; 
    interVal_4 = encoder3Pos *50; 
  
 
  //---write-info-to-LCD-if-encodercountervalue-is-0]
  if (encoderCounter == 0){
     lcd.setCursor(0,0); 
     lcd.print("PRESS TO CONTINU"); 
     lcd.setCursor(0,1); 
     lcd.print("       ");
     lcd.setCursor(7, 1);
     lcd.write(0);
     lcd.setCursor(8,1); 
     lcd.print("        "); 
  }
  
  //---write-interval-values-to-LCD-if-encodercountervalue-is-1]
  if (encoderCounter == 1){
     lcd.setCursor(0,0);  
     lcd.print("set time led 1  "); 
    if (interVal_1 <1000){
       lcd.setCursor(2,1); 
       lcd.print(interVal_1,0);
       lcd.setCursor(1,1);
       lcd.print(" ");  
       lcd.setCursor(6,1); 
       lcd.print("mS"); 
       lcd.setCursor(9,1); 
       lcd.print(freq_1); 
       lcd.setCursor(13,1);
       lcd.print(" ");  
       lcd.setCursor(14,1); 
       lcd.print("HZ"); 
    }   
    if (interVal_1 >=1000) {
      lcd.setCursor(1,1); 
      lcd.print(interVal_1,0); 
      lcd.setCursor(6,1); 
      lcd.print("mS"); 
      lcd.setCursor(9,1); 
      lcd.print(freq_1);
      lcd.setCursor(13,1);
      lcd.print(" ");   
      lcd.setCursor(14,1); 
      lcd.print("HZ"); 
    }
    if (interVal_1 <100) {
       lcd.setCursor(3,1); 
       lcd.print(interVal_1,0);
       lcd.setCursor(2,1); 
       lcd.print(" ");   
       lcd.setCursor(6,1);
       lcd.print("mS");
       lcd.setCursor(9,1); 
       lcd.print(freq_1); 
       lcd.setCursor(13,1);
       lcd.print(" ");  
       lcd.setCursor(14,1);
       lcd.print("HZ"); 
    }
     if (dir_upState == 1) {
       lcd.setCursor(0,1); 
       lcd.write(1);
    }   
       if (dir_downState == 1) {
       lcd.setCursor(0,1); 
       lcd.write(0);
    }
  }
  
 //---write-interval-values-to-LCD-if-encodercountervalue-is-2] 
   if (encoderCounter == 2){
     lcd.setCursor(0,0);  
     lcd.print("set time led 2  "); 
    if (interVal_2 <1000){
       lcd.setCursor(2,1); 
       lcd.print(interVal_2,0);
       lcd.setCursor(1,1);
       lcd.print(" ");  
       lcd.setCursor(6,1); 
       lcd.print("mS"); 
       lcd.setCursor(9,1); 
       lcd.print(freq_2); 
       lcd.setCursor(13,1);
       lcd.print(" ");  
       lcd.setCursor(14,1); 
       lcd.print("HZ"); 
    }   
    if (interVal_2 >=1000) {
       lcd.setCursor(1,1); 
       lcd.print(interVal_2,0); 
       lcd.setCursor(6,1); 
       lcd.print("mS"); 
       lcd.setCursor(9,1); 
       lcd.print(freq_2); 
       lcd.setCursor(13,1);
       lcd.print(" ");  
       lcd.setCursor(14,1); 
       lcd.print("HZ"); 
    }
    if (interVal_2 <100) {
       lcd.setCursor(3,1); 
       lcd.print(interVal_2,0);
       lcd.setCursor(2,1); 
       lcd.print(" ");   
       lcd.setCursor(6,1);
       lcd.print("mS");
       lcd.setCursor(9,1); 
       lcd.print(freq_2); 
       lcd.setCursor(13,1);
       lcd.print(" ");  
       lcd.setCursor(14,1);
       lcd.print("HZ"); 
    }
    if (dir_upState == 1) {
       lcd.setCursor(0,1); 
       lcd.write(1);
    }   
    if (dir_downState == 1) {
       lcd.setCursor(0,1); 
       lcd.write(0);
    }
  }

 //---write-interval-values-to-LCD-if-encodercountervalue-is-3]
   if (encoderCounter == 3){
     lcd.setCursor(0,0);  
     lcd.print("set time led 3  "); 
    if (interVal_3 <1000){
       lcd.setCursor(2,1); 
       lcd.print(interVal_3,0);
       lcd.setCursor(1,1);
       lcd.print(" ");  
       lcd.setCursor(6,1); 
       lcd.print("mS"); 
       lcd.setCursor(9,1); 
       lcd.print(freq_3); 
       lcd.setCursor(13,1);
       lcd.print(" ");  
       lcd.setCursor(14,1); 
       lcd.print("HZ"); 
    }   
    if (interVal_3 >=1000) {
       lcd.setCursor(1,1); 
       lcd.print(interVal_3,0); 
       lcd.setCursor(6,1); 
       lcd.print("mS"); 
       lcd.setCursor(9,1); 
       lcd.print(freq_3); 
       lcd.setCursor(13,1);
       lcd.print(" ");  
       lcd.setCursor(14,1); 
       lcd.print("HZ"); 
    }
    if (interVal_3 <100) {
       lcd.setCursor(3,1); 
       lcd.print(interVal_3,0);
       lcd.setCursor(2,1); 
       lcd.print(" ");   
       lcd.setCursor(6,1);
       lcd.print("mS");
       lcd.setCursor(9,1); 
       lcd.print(freq_3); 
       lcd.setCursor(13,1);
       lcd.print(" ");  
       lcd.setCursor(14,1);
       lcd.print("HZ"); 
    }
     if (dir_upState == 1) {
       lcd.setCursor(0,1); 
       lcd.write(1);
    }   
     if (dir_downState == 1) {
       lcd.setCursor(0,1); 
       lcd.write(0);
    }
  }

  //---write-interval-values-to-LCD-if-encodercountervalue-is-4] 
 if (encoderCounter == 4){
     lcd.setCursor(0,0);  
     lcd.print("set time led 4  "); 
    if (interVal_4 <1000){
       lcd.setCursor(2,1); 
       lcd.print(interVal_4,0);
       lcd.setCursor(1,1);
       lcd.print(" ");  
       lcd.setCursor(6,1); 
       lcd.print("mS"); 
       lcd.setCursor(9,1); 
       lcd.print(freq_4); 
       lcd.setCursor(13,1);
       lcd.print(" ");  
       lcd.setCursor(14,1); 
       lcd.print("HZ"); 
    }       
    if (interVal_4 >=1000) {
       lcd.setCursor(1,1); 
       lcd.print(interVal_4,0); 
       lcd.setCursor(6,1); 
       lcd.print("mS"); 
       lcd.setCursor(9,1); 
       lcd.print(freq_4); 
       lcd.setCursor(13,1);
       lcd.print(" ");  
       lcd.setCursor(14,1); 
       lcd.print("HZ"); 
    }    
    if (interVal_4 <100) {
       lcd.setCursor(3,1); 
       lcd.print(interVal_4,0);
       lcd.setCursor(2,1); 
       lcd.print(" ");   
       lcd.setCursor(6,1);
       lcd.print("mS");
       lcd.setCursor(9,1); 
       lcd.print(freq_4); 
       lcd.setCursor(13,1);
       lcd.print(" ");  
       lcd.setCursor(14,1);
       lcd.print("HZ"); 
    }    
     if (dir_upState == 1) {
        lcd.setCursor(0,1); 
        lcd.write(1);
    }      
     if (dir_downState == 1) {
        lcd.setCursor(0,1); 
        lcd.write(0);
    }
  }
  
 if (encoderCounter == 5){
     lcd.setCursor(0,0); 
     lcd.print("all together !  ");
     lcd.setCursor(0,1);  
     lcd.print("                ");
    
  }
  if (encoderCounter == 6){
     lcd.setCursor(0,0); 
     lcd.print("Police-lights   "); 
     lcd.setCursor(0,1);  
     lcd.print("                ");
     
  }
  
  //----------------------------------------
  unsigned long currentMillis1 = millis();
  unsigned long currentMillis2 = millis();
  unsigned long currentMillis3 = millis();
  unsigned long currentMillis4 = millis();

 //-----------------LEDSTATE-1------------------------------
  if (currentMillis1 - previousMillis1 >= interVal_1) {
    // save the last time you blinked the LED
    previousMillis1 = currentMillis1;

    // If the led is off turn it on otherwise turn it off.
   if (ledState1 == LOW) {
       ledState1 = HIGH;
    } else {
        ledState1 = LOW;
    }
  }

  //-----------------LEDSTATE-2-----------------------------
  if (currentMillis2 - previousMillis2 >= interVal_2) {
    // save the last time you blinked the LED
    previousMillis2 = currentMillis2;

    if (ledState2 == LOW) {
        ledState2 = HIGH;
    } else {
        ledState2 = LOW;
    }
  }

  //-----------------LEDSTATE-3-----------------------------
  if (currentMillis3 - previousMillis3 >= interVal_3) {
    // save the last time you blinked the LED
    previousMillis3 = currentMillis3;

    if (ledState3 == LOW) {
        ledState3 = HIGH;
    } else {
        ledState3 = LOW;
    }
  }

  //-----------------LEDSTATE-4-----------------------------
  if (currentMillis4 - previousMillis4 >= interVal_4) {
    // save the last time you blinked the LED
    previousMillis4 = currentMillis4;

    if (ledState4 == LOW) {
        ledState4 = HIGH;
    } else {
        ledState4 = LOW;
  }
}
  //-----------------[Control LEDS]----------------------
  if (encoderCounter == 0 || encoderCounter == 1 || encoderCounter == 2 || encoderCounter == 3 || encoderCounter == 4) {
     digitalWrite(ledPin1, ledState1);
     digitalWrite(ledPin2, ledState2);
     digitalWrite(ledPin3, ledState3);
     digitalWrite(ledPin4, ledState4);
}

 //-----------------[Control-LEDS-with-interval-1]---------
  if (encoderCounter == 5) {
     digitalWrite(ledPin1, ledState1);
     digitalWrite(ledPin2, ledState1);
     digitalWrite(ledPin3, ledState1);
     digitalWrite(ledPin4, ledState1);
  }
  //-----------------[Police-Lights-]---------
  if (encoderCounter == 6) {
     digitalWrite(ledPin2,HIGH);
     delay(40);
     digitalWrite(ledPin2,LOW);
     delay(30);
     digitalWrite(ledPin2,HIGH);
     delay(40);
     digitalWrite(ledPin2,LOW);
     delay(30);
     digitalWrite(ledPin2,HIGH);
     delay(40);
     digitalWrite(ledPin2,LOW);
     delay(30);
     //----------------------------
     digitalWrite(ledPin4,HIGH);
     delay(40);
     digitalWrite(ledPin4,LOW);
     delay(30);
     //----------------------------
     digitalWrite(ledPin3,HIGH);
     delay(40);
     digitalWrite(ledPin3,LOW);
     delay(30);
     digitalWrite(ledPin3,HIGH);
     delay(40);
     digitalWrite(ledPin3,LOW);
     delay(30);
     digitalWrite(ledPin3,HIGH);
     delay(40);
     digitalWrite(ledPin3,LOW);
     delay(30);
    //------------------------------
     digitalWrite(ledPin1,HIGH);
     delay(40);
     digitalWrite(ledPin1,LOW);
     delay(30);
  }
}

//---------Interupt-function-for-encoder--------------------------------
void interruptFunction() {
  
unsigned char result = r.process();
    
  if (result == DIR_NONE) {
    // do nothing
  }
 //-----------------position-encoder-0------------------------------------------------------------------------------]
  else if (result == DIR_CW && encoder0Pos < 40 && encoderCounter == 1 ) {// Lowest time interval = 50*40= 2000mSec
    encoder0Pos++;
    dir_upState = 1;
    dir_downState = 0;
  }
  
  else if (result == DIR_CCW && encoder0Pos > 1 && encoderCounter == 1) {//Highest time interval = 50*1= 50mSec
     encoder0Pos--;
     dir_downState = 1;
     dir_upState = 0;
  }
  
 //-----------------position-encoder-1-----------------------------------------------------------------------------]
  else if (result == DIR_CW && encoder1Pos < 40 && encoderCounter == 2) {
    encoder1Pos++;
    dir_upState = 1;
    dir_downState = 0;
  }

  else if (result == DIR_CCW && encoder1Pos > 1 && encoderCounter == 2) {
     encoder1Pos--;
      dir_downState = 1;
      dir_upState = 0;
  }
 //-----------------position-encoder-2-----------------------------------
   else if (result == DIR_CW && encoder2Pos < 40 && encoderCounter == 3) {
    encoder2Pos++;
    dir_upState = 1;
    dir_downState = 0;
  }

  else if (result == DIR_CCW && encoder2Pos > 1 && encoderCounter == 3) {
     encoder2Pos--;
      dir_downState = 1;
      dir_upState = 0;
  }
 //-----------------position-encoder-3-----------------------------------
  else if (result == DIR_CW && encoder3Pos < 40 && encoderCounter == 4) {
    encoder3Pos++;
    dir_upState = 1;
    dir_downState = 0;
  }

  else if (result == DIR_CCW && encoder3Pos > 1 && encoderCounter == 4) {
     encoder3Pos--;
      dir_downState = 1;
     dir_upState = 0;
  }
}

The error message seems quite clear

Where did you get the code and the Rotary library ?

The rotary library was downloaded from library manager (rotary v1.0.0 by KAthir)
code was sent by author from this video

I'm new to arduino and simply trying to make this compile.

There is almost certainly more than one Rotary library.

Try this one

it does have a process() function but may still not be the correct library but it does have examples

Thank you, the sketch compiles OK now. However even the LCD does not work :frowning_face:
This is what I see


test files i2c 16x2 LCD example with Arduino
confirm display is working

the microcontroller-world is not superstandardised like USB-devices.

You have to take care of more details than just "does the plug fit into the socket?"
And there are a lot of people online who don't care too much about sufficient documentation of their projects.

One reason might be the I2C-Adress of the LCD.
The Arduino-IDE comes with an example code I2C-Scanner run this code to determine the I2C-Adress of your LCD

If no I2C-device is found then there is something wrong with your wiring

You should provide a hand-drawn schematic. Under all circumstances avoid a fritzing-picture.
fritzing-pictures are

  • unprofessional
  • have a lot of non-relevant information
    and therefore hard to analyse

best regards Stefan

Well the author seems to have share unfinished code, that is also old. New IDE does not want to build it. I have managed to make it work.

I removed the

lcd.begin(16, 2);

Replaced it with the

 lcd.init(); // initialize the lcd

Also had to add

  lcd.backlight(); // turn on lcd backlight

The changes that you made lead me to believe that a different LCD library was used originally. There are certainly several with the same name and they have different functions

Seems I spoke too soon, the arduino code hangs if I have lcd code

// lcd.begin(16, 2);
lcd.init(); // initialize the lcd
lcd.backlight(); // turn on lcd backlight

Works after reset button press, fine. Hmm. What other LCD library I can try?

The hd44780 LCD library has a good reputation and its author (@bperrybap) participates in the forum

And that hd44780 library figures out the address on its own, and has various diagnostics.

It's in the IDE library manager.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.