Multi Function Shield errors

I am revisiting a Multi Function Shield. When previously used the #include was MultiFuncShield.h, however this seems to have been replaced with MultiFunctionShield.h. Now when I compile I get error messages such as
MFS not declared in this scope Any advice?

Start by posting a sketch that causes the error and the the full error copied from the IDE using the "Copy error message" button

Put the sketch and error message in code tags when you post them

Also, please post a link to the shield (and if not available through library manager, the libraries).

1 Like

//_24_Alarm_Clock

#include <TimerOne.h>
#include <Wire.h>
#include <MultiFunctionShield.h>

/*
button 1 : hold to set time or alarm
button 2 : press to view alarm time or cancel alarm if in progress
button 3 : increment hour / minute when setting (alarm) time. Hold to toggle alarm setting.

LED1 : on = alarm enabled
*/

volatile unsigned int clockMilliSeconds = 0;
volatile byte clockSeconds = 0;
volatile byte clockMinutes = 0;
volatile byte clockHours = 12;
volatile byte clockEnabled = 1;

byte alarmMinutes = 30;
byte alarmHours = 6;
volatile byte alarmEnabled = false;

byte alarmTogglePressed = false;

enum displayModeValues
{
MODE_CLOCK_TIME,
MODE_CLOCK_TIME_SET_HOUR,
MODE_CLOCK_TIME_SET_MINUTE,
MODE_ALARM_TIME,
MODE_ALARM_TIME_SET_HOUR,
MODE_ALARM_TIME_SET_MINUTE
};

byte displayMode = MODE_CLOCK_TIME;

//--------------------------------------------------------------------------------------------------
void setup()
{
Timer1.initialize();
MultiFunctionShield MFS;
MFS.begin();

// MFS.userInterrupt = clockISR;
MFS.initialize(&Timer1);

MFS.blinkDisplay(DIGIT_ALL);
MFS.beep(500);
}

void loop()
{
// put your main code here, to run repeatedly:
//MultiFunctionShield MFS;
byte btn = MFS.getButton();

switch (displayMode)
{
case MODE_CLOCK_TIME:
displayTime(clockHours, clockMinutes);

    if (btn == BUTTON_2_PRESSED)
    {
      MFS.beep(0);  // cancel the alarm.
      displayMode = MODE_ALARM_TIME;
    }
    else if (btn == BUTTON_1_LONG_PRESSED)
    {
      MFS.blinkDisplay(DIGIT_ALL, OFF);
      MFS.blinkDisplay(DIGIT_1 | DIGIT_2);
      displayMode = MODE_CLOCK_TIME_SET_HOUR;
      clockEnabled = false;
      clockMilliSeconds = 0;
      clockSeconds = 0;
    }
    else if (btn == BUTTON_3_LONG_PRESSED && !alarmTogglePressed)
    {
      alarmTogglePressed = true;
      alarmEnabled = !alarmEnabled;
      MFS.writeLeds(LED_1, alarmEnabled);
    }
    else if (btn == BUTTON_3_LONG_RELEASE)
    {
      alarmTogglePressed = false;
    }
    break;
    
case MODE_CLOCK_TIME_SET_HOUR:
    if (btn == BUTTON_1_PRESSED)
    {
      MFS.blinkDisplay(DIGIT_1 | DIGIT_2, OFF);
      MFS.blinkDisplay(DIGIT_3 | DIGIT_4);
      displayMode = MODE_CLOCK_TIME_SET_MINUTE;
    }
    else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)
    {
      clockHours++;
      if (clockHours >= 24)
      {
        clockHours = 0;
      }
      displayTime(clockHours, clockMinutes);
    }
    break;
    
case MODE_CLOCK_TIME_SET_MINUTE:
    if (btn == BUTTON_1_PRESSED)
    {
      MFS.blinkDisplay(DIGIT_3 | DIGIT_4, OFF);
      displayMode = MODE_CLOCK_TIME;
      clockEnabled = true;
    }
    else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)
    {
      clockMinutes++;
      if (clockMinutes >= 60)
      {
        clockMinutes = 0;
      }
      displayTime(clockHours, clockMinutes);
    }
    break;
    
case MODE_ALARM_TIME:
    displayTime(alarmHours, alarmMinutes);

    if (btn == BUTTON_2_SHORT_RELEASE || btn == BUTTON_2_LONG_RELEASE)
    {
      displayMode = MODE_CLOCK_TIME;
    }
    else if (btn == BUTTON_1_LONG_PRESSED)
    {
      MFS.blinkDisplay(DIGIT_ALL, OFF);
      MFS.blinkDisplay(DIGIT_1 | DIGIT_2);
      displayMode = MODE_ALARM_TIME_SET_HOUR;
      alarmEnabled = false;
    }
    break;
    
case MODE_ALARM_TIME_SET_HOUR:
    if (btn == BUTTON_1_PRESSED)
    {
      MFS.blinkDisplay(DIGIT_1 | DIGIT_2, OFF);
      MFS.blinkDisplay(DIGIT_3 | DIGIT_4);
      displayMode = MODE_ALARM_TIME_SET_MINUTE;
    }
    else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)
    {
      alarmHours++;
      if (alarmHours >= 24)
      {
        alarmHours = 0;
      }
      displayTime(alarmHours, alarmMinutes);
    }
    break;
    
case MODE_ALARM_TIME_SET_MINUTE:
    if (btn == BUTTON_1_PRESSED)
    {
      MFS.blinkDisplay(DIGIT_3 | DIGIT_4, OFF);
      displayMode = MODE_CLOCK_TIME;
      alarmEnabled = true;
      MFS.writeLeds(LED_1, ON);
    }
    else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)
    {
      alarmMinutes++;
      if (alarmMinutes >= 60)
      {
        alarmMinutes = 0;
      }
      displayTime(alarmHours, alarmMinutes);
    }
    break;      

}
}

void displayTime (byte hours, byte minutes)
{
char time[5];

sprintf(time, "%03d", (hours * 100) + minutes);
//MFS.write(time, 1);
}

//--------------------------------------------------------------------------------------------------
void clockISR ()
{
// Perform ripple count for all time components.
if (clockEnabled)
{
clockMilliSeconds++;
if (clockMilliSeconds >= 1000)
{
clockMilliSeconds = 0;

  clockSeconds++;
  if (clockSeconds >= 60)
  {
    clockSeconds = 0;
    
    clockMinutes++;
    if (clockMinutes >= 60)
    {
      clockMinutes = 0;
      
      clockHours++;
      if (clockHours >= 24)
      {
        clockHours = 0;
      }
    }
         
    // If current time coincides with alarm time, and alarm is enabled, engage the alarm.
    if (alarmEnabled && (clockMinutes == alarmMinutes) && (clockHours == alarmHours))
    {
      MFS.beep(
                10,  // on period
                 5,  // off period
                 4,  // number of cycles
               100,  // number of loop cycles
                50   // delay between loop cycles
               );
    }
  }
}

}
}

Arduino: 1.8.16 (Windows Store 1.8.51.0) (Windows 10), Board: "Arduino Uno"

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino: In function 'void setup()':

_24_hr_Alarm_Clock:46:7: error: 'class MultiFunctionShield' has no member named 'initialize'

MFS.initialize(&Timer1);

   ^~~~~~~~~~

_24_hr_Alarm_Clock:48:7: error: 'class MultiFunctionShield' has no member named 'blinkDisplay'; did you mean 'Display'?

MFS.blinkDisplay(DIGIT_ALL);

   ^~~~~~~~~~~~

   Display

_24_hr_Alarm_Clock:48:20: error: 'DIGIT_ALL' was not declared in this scope

MFS.blinkDisplay(DIGIT_ALL);

                ^~~~~~~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:48:20: note: suggested alternative: 'SKIP_ALL'

MFS.blinkDisplay(DIGIT_ALL);

                ^~~~~~~~~

                SKIP_ALL

_24_hr_Alarm_Clock:49:7: error: 'class MultiFunctionShield' has no member named 'beep'

MFS.beep(500);

   ^~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino: In function 'void loop()':

_24_hr_Alarm_Clock:57:14: error: 'MFS' was not declared in this scope

byte btn = MFS.getButton();

          ^~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:57:14: note: suggested alternative: 'MISO'

byte btn = MFS.getButton();

          ^~~

          MISO

_24_hr_Alarm_Clock:64:20: error: 'BUTTON_2_PRESSED' was not declared in this scope

     if (btn == BUTTON_2_PRESSED)

                ^~~~~~~~~~~~~~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:64:20: note: suggested alternative: 'BUTTON_2_PIN'

     if (btn == BUTTON_2_PRESSED)

                ^~~~~~~~~~~~~~~~

                BUTTON_2_PIN

_24_hr_Alarm_Clock:69:25: error: 'BUTTON_1_LONG_PRESSED' was not declared in this scope

     else if (btn == BUTTON_1_LONG_PRESSED)

                     ^~~~~~~~~~~~~~~~~~~~~

_24_hr_Alarm_Clock:71:28: error: 'DIGIT_ALL' was not declared in this scope

       MFS.blinkDisplay(DIGIT_ALL, OFF);

                        ^~~~~~~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:71:28: note: suggested alternative: 'SKIP_ALL'

       MFS.blinkDisplay(DIGIT_ALL, OFF);

                        ^~~~~~~~~

                        SKIP_ALL

_24_hr_Alarm_Clock:71:39: error: 'OFF' was not declared in this scope

       MFS.blinkDisplay(DIGIT_ALL, OFF);

                                   ^~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:71:39: note: suggested alternative: '_FFS'

       MFS.blinkDisplay(DIGIT_ALL, OFF);

                                   ^~~

                                   _FFS

_24_hr_Alarm_Clock:72:28: error: 'DIGIT_1' was not declared in this scope

       MFS.blinkDisplay(DIGIT_1 | DIGIT_2);

                        ^~~~~~~

_24_hr_Alarm_Clock:72:38: error: 'DIGIT_2' was not declared in this scope

       MFS.blinkDisplay(DIGIT_1 | DIGIT_2);

                                  ^~~~~~~

_24_hr_Alarm_Clock:78:25: error: 'BUTTON_3_LONG_PRESSED' was not declared in this scope

     else if (btn == BUTTON_3_LONG_PRESSED && !alarmTogglePressed)

                     ^~~~~~~~~~~~~~~~~~~~~

_24_hr_Alarm_Clock:82:25: error: 'LED_1' was not declared in this scope

       MFS.writeLeds(LED_1, alarmEnabled);

                     ^~~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:82:25: note: suggested alternative: 'EEDR1'

       MFS.writeLeds(LED_1, alarmEnabled);

                     ^~~~~

                     EEDR1

_24_hr_Alarm_Clock:84:25: error: 'BUTTON_3_LONG_RELEASE' was not declared in this scope

     else if (btn == BUTTON_3_LONG_RELEASE)

                     ^~~~~~~~~~~~~~~~~~~~~

_24_hr_Alarm_Clock:91:20: error: 'BUTTON_1_PRESSED' was not declared in this scope

     if (btn == BUTTON_1_PRESSED)

                ^~~~~~~~~~~~~~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:91:20: note: suggested alternative: 'BUTTON_1_PIN'

     if (btn == BUTTON_1_PRESSED)

                ^~~~~~~~~~~~~~~~

                BUTTON_1_PIN

_24_hr_Alarm_Clock:93:28: error: 'DIGIT_1' was not declared in this scope

       MFS.blinkDisplay(DIGIT_1 | DIGIT_2, OFF);

                        ^~~~~~~

_24_hr_Alarm_Clock:93:38: error: 'DIGIT_2' was not declared in this scope

       MFS.blinkDisplay(DIGIT_1 | DIGIT_2, OFF);

                                  ^~~~~~~

_24_hr_Alarm_Clock:93:47: error: 'OFF' was not declared in this scope

       MFS.blinkDisplay(DIGIT_1 | DIGIT_2, OFF);

                                           ^~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:93:47: note: suggested alternative: '_FFS'

       MFS.blinkDisplay(DIGIT_1 | DIGIT_2, OFF);

                                           ^~~

                                           _FFS

_24_hr_Alarm_Clock:94:28: error: 'DIGIT_3' was not declared in this scope

       MFS.blinkDisplay(DIGIT_3 | DIGIT_4);

                        ^~~~~~~

_24_hr_Alarm_Clock:94:38: error: 'DIGIT_4' was not declared in this scope

       MFS.blinkDisplay(DIGIT_3 | DIGIT_4);

                                  ^~~~~~~

_24_hr_Alarm_Clock:97:25: error: 'BUTTON_3_PRESSED' was not declared in this scope

     else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)

                     ^~~~~~~~~~~~~~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:97:25: note: suggested alternative: 'BUTTON_3_PIN'

     else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)

                     ^~~~~~~~~~~~~~~~

                     BUTTON_3_PIN

_24_hr_Alarm_Clock:97:52: error: 'BUTTON_3_LONG_PRESSED' was not declared in this scope

     else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)

                                                ^~~~~~~~~~~~~~~~~~~~~

_24_hr_Alarm_Clock:109:20: error: 'BUTTON_1_PRESSED' was not declared in this scope

     if (btn == BUTTON_1_PRESSED)

                ^~~~~~~~~~~~~~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:109:20: note: suggested alternative: 'BUTTON_1_PIN'

     if (btn == BUTTON_1_PRESSED)

                ^~~~~~~~~~~~~~~~

                BUTTON_1_PIN

_24_hr_Alarm_Clock:111:28: error: 'DIGIT_3' was not declared in this scope

       MFS.blinkDisplay(DIGIT_3 | DIGIT_4, OFF);

                        ^~~~~~~

_24_hr_Alarm_Clock:111:38: error: 'DIGIT_4' was not declared in this scope

       MFS.blinkDisplay(DIGIT_3 | DIGIT_4, OFF);

                                  ^~~~~~~

_24_hr_Alarm_Clock:111:47: error: 'OFF' was not declared in this scope

       MFS.blinkDisplay(DIGIT_3 | DIGIT_4, OFF);

                                           ^~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:111:47: note: suggested alternative: '_FFS'

       MFS.blinkDisplay(DIGIT_3 | DIGIT_4, OFF);

                                           ^~~

                                           _FFS

_24_hr_Alarm_Clock:115:25: error: 'BUTTON_3_PRESSED' was not declared in this scope

     else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)

                     ^~~~~~~~~~~~~~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:115:25: note: suggested alternative: 'BUTTON_3_PIN'

     else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)

                     ^~~~~~~~~~~~~~~~

                     BUTTON_3_PIN

_24_hr_Alarm_Clock:115:52: error: 'BUTTON_3_LONG_PRESSED' was not declared in this scope

     else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)

                                                ^~~~~~~~~~~~~~~~~~~~~

_24_hr_Alarm_Clock:129:20: error: 'BUTTON_2_SHORT_RELEASE' was not declared in this scope

     if (btn == BUTTON_2_SHORT_RELEASE || btn == BUTTON_2_LONG_RELEASE)

                ^~~~~~~~~~~~~~~~~~~~~~

_24_hr_Alarm_Clock:129:53: error: 'BUTTON_2_LONG_RELEASE' was not declared in this scope

     if (btn == BUTTON_2_SHORT_RELEASE || btn == BUTTON_2_LONG_RELEASE)

                                                 ^~~~~~~~~~~~~~~~~~~~~

_24_hr_Alarm_Clock:133:25: error: 'BUTTON_1_LONG_PRESSED' was not declared in this scope

     else if (btn == BUTTON_1_LONG_PRESSED)

                     ^~~~~~~~~~~~~~~~~~~~~

_24_hr_Alarm_Clock:135:28: error: 'DIGIT_ALL' was not declared in this scope

       MFS.blinkDisplay(DIGIT_ALL, OFF);

                        ^~~~~~~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:135:28: note: suggested alternative: 'SKIP_ALL'

       MFS.blinkDisplay(DIGIT_ALL, OFF);

                        ^~~~~~~~~

                        SKIP_ALL

_24_hr_Alarm_Clock:135:39: error: 'OFF' was not declared in this scope

       MFS.blinkDisplay(DIGIT_ALL, OFF);

                                   ^~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:135:39: note: suggested alternative: '_FFS'

       MFS.blinkDisplay(DIGIT_ALL, OFF);

                                   ^~~

                                   _FFS

_24_hr_Alarm_Clock:136:28: error: 'DIGIT_1' was not declared in this scope

       MFS.blinkDisplay(DIGIT_1 | DIGIT_2);

                        ^~~~~~~

_24_hr_Alarm_Clock:136:38: error: 'DIGIT_2' was not declared in this scope

       MFS.blinkDisplay(DIGIT_1 | DIGIT_2);

                                  ^~~~~~~

_24_hr_Alarm_Clock:143:20: error: 'BUTTON_1_PRESSED' was not declared in this scope

     if (btn == BUTTON_1_PRESSED)

                ^~~~~~~~~~~~~~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:143:20: note: suggested alternative: 'BUTTON_1_PIN'

     if (btn == BUTTON_1_PRESSED)

                ^~~~~~~~~~~~~~~~

                BUTTON_1_PIN

_24_hr_Alarm_Clock:145:28: error: 'DIGIT_1' was not declared in this scope

       MFS.blinkDisplay(DIGIT_1 | DIGIT_2, OFF);

                        ^~~~~~~

_24_hr_Alarm_Clock:145:38: error: 'DIGIT_2' was not declared in this scope

       MFS.blinkDisplay(DIGIT_1 | DIGIT_2, OFF);

                                  ^~~~~~~

_24_hr_Alarm_Clock:145:47: error: 'OFF' was not declared in this scope

       MFS.blinkDisplay(DIGIT_1 | DIGIT_2, OFF);

                                           ^~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:145:47: note: suggested alternative: '_FFS'

       MFS.blinkDisplay(DIGIT_1 | DIGIT_2, OFF);

                                           ^~~

                                           _FFS

_24_hr_Alarm_Clock:146:28: error: 'DIGIT_3' was not declared in this scope

       MFS.blinkDisplay(DIGIT_3 | DIGIT_4);

                        ^~~~~~~

_24_hr_Alarm_Clock:146:38: error: 'DIGIT_4' was not declared in this scope

       MFS.blinkDisplay(DIGIT_3 | DIGIT_4);

                                  ^~~~~~~

_24_hr_Alarm_Clock:149:25: error: 'BUTTON_3_PRESSED' was not declared in this scope

     else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)

                     ^~~~~~~~~~~~~~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:149:25: note: suggested alternative: 'BUTTON_3_PIN'

     else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)

                     ^~~~~~~~~~~~~~~~

                     BUTTON_3_PIN

_24_hr_Alarm_Clock:149:52: error: 'BUTTON_3_LONG_PRESSED' was not declared in this scope

     else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)

                                                ^~~~~~~~~~~~~~~~~~~~~

_24_hr_Alarm_Clock:161:20: error: 'BUTTON_1_PRESSED' was not declared in this scope

     if (btn == BUTTON_1_PRESSED)

                ^~~~~~~~~~~~~~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:161:20: note: suggested alternative: 'BUTTON_1_PIN'

     if (btn == BUTTON_1_PRESSED)

                ^~~~~~~~~~~~~~~~

                BUTTON_1_PIN

_24_hr_Alarm_Clock:163:28: error: 'DIGIT_3' was not declared in this scope

       MFS.blinkDisplay(DIGIT_3 | DIGIT_4, OFF);

                        ^~~~~~~

_24_hr_Alarm_Clock:163:38: error: 'DIGIT_4' was not declared in this scope

       MFS.blinkDisplay(DIGIT_3 | DIGIT_4, OFF);

                                  ^~~~~~~

_24_hr_Alarm_Clock:163:47: error: 'OFF' was not declared in this scope

       MFS.blinkDisplay(DIGIT_3 | DIGIT_4, OFF);

                                           ^~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:163:47: note: suggested alternative: '_FFS'

       MFS.blinkDisplay(DIGIT_3 | DIGIT_4, OFF);

                                           ^~~

                                           _FFS

_24_hr_Alarm_Clock:166:25: error: 'LED_1' was not declared in this scope

       MFS.writeLeds(LED_1, ON);

                     ^~~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:166:25: note: suggested alternative: 'EEDR1'

       MFS.writeLeds(LED_1, ON);

                     ^~~~~

                     EEDR1

_24_hr_Alarm_Clock:166:32: error: 'ON' was not declared in this scope

       MFS.writeLeds(LED_1, ON);

                            ^~

_24_hr_Alarm_Clock:168:25: error: 'BUTTON_3_PRESSED' was not declared in this scope

     else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)

                     ^~~~~~~~~~~~~~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:168:25: note: suggested alternative: 'BUTTON_3_PIN'

     else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)

                     ^~~~~~~~~~~~~~~~

                     BUTTON_3_PIN

_24_hr_Alarm_Clock:168:52: error: 'BUTTON_3_LONG_PRESSED' was not declared in this scope

     else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)

                                                ^~~~~~~~~~~~~~~~~~~~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino: In function 'void clockISR()':

_24_hr_Alarm_Clock:221:11: error: 'MFS' was not declared in this scope

       MFS.beep(

       ^~~

C:\Users\Barrie\AppData\Arduino sketches\Multifunction shield\Hackatronics-Using-Arduino-Multi-function-Shield\Hackatronics - Using Arduino Multi-function Shield\03 Applications_24_hr_Alarm_Clock_24_hr_Alarm_Clock.ino:221:11: note: suggested alternative: 'MISO'

       MFS.beep(

       ^~~

       MISO

exit status 1

'class MultiFunctionShield' has no member named 'initialize'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Please edit your post, select all code and click the </> button to apply code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code.

I doubt it is a replacement; just somebody else writing a similar library.

MultiFuncShield.h can still be found at Arduino Multi-function Shield Projects - Hackatronics after a bit of googling. I installed version 1.3, took the Arduino 24 Hour Alarm Clock from
Learning to code with the Arduino Part 3 and it compiles; you might need an older version if your original code relies on the TimeOne library.

Instructions for installing v1.3

  1. Download https://files.cohesivecomputing.co.uk/MultiFuncShield-Library-1_3.zip
  2. Extract
  3. Navigate to the directory where_it_was_extracted\MultiFuncShield-Library-1_3\MultiFuncShield-Library-1_3; it contains the directory MultiFuncShield-Library.
  4. Copy the directory MultiFuncShield-Library and paste it in the Arduino Libraries directory (on my system, C:\Users\sterretje\Documents\Arduino\libraries)

Hi,
If the newer library you are having problems with has examples, it is work worth loading them and checking the variable/functions they use.

Tom... :smiley: :+1: :coffee: :australia:

Also use the "code" tags to show error or serial monitor output.

I tried pressing the <> key with the code highlighted and it was replaced by <. What am I doing wrong?

It's a button, not a key

`/_24_Alarm_Clock

#include <TimerOne.h>
#include <Wire.h>
#include <MultiFunctionShield.h>

/*
  button 1  : hold to set time or alarm
  button 2  : press to view alarm time or cancel alarm if in progress
  button 3  : increment hour / minute when setting (alarm) time. Hold to toggle alarm setting.
  
  LED1  : on = alarm enabled
*/

volatile unsigned int clockMilliSeconds = 0;
volatile byte clockSeconds = 0;
volatile byte clockMinutes = 0;
volatile byte clockHours = 12;
volatile byte clockEnabled = 1;

byte alarmMinutes = 30;
byte alarmHours = 6;
volatile byte alarmEnabled = false;

byte alarmTogglePressed = false;


enum displayModeValues
{
  MODE_CLOCK_TIME,
  MODE_CLOCK_TIME_SET_HOUR,
  MODE_CLOCK_TIME_SET_MINUTE,
  MODE_ALARM_TIME,
  MODE_ALARM_TIME_SET_HOUR,
  MODE_ALARM_TIME_SET_MINUTE
};

byte displayMode = MODE_CLOCK_TIME;

//--------------------------------------------------------------------------------------------------
void setup()
{
  Timer1.initialize();
  MultiFunctionShield MFS;
  MFS.begin();
  
//  MFS.userInterrupt = clockISR;
  MFS.initialize(&Timer1);
  
  MFS.blinkDisplay(DIGIT_ALL);
  MFS.beep(500);
}


void loop()
{
  // put your main code here, to run repeatedly:
  //MultiFunctionShield MFS;
  byte btn = MFS.getButton();
  
  switch (displayMode)
  {
    case MODE_CLOCK_TIME:
        displayTime(clockHours, clockMinutes);
        
        if (btn == BUTTON_2_PRESSED)
        {
          MFS.beep(0);  // cancel the alarm.
          displayMode = MODE_ALARM_TIME;
        }
        else if (btn == BUTTON_1_LONG_PRESSED)
        {
          MFS.blinkDisplay(DIGIT_ALL, OFF);
          MFS.blinkDisplay(DIGIT_1 | DIGIT_2);
          displayMode = MODE_CLOCK_TIME_SET_HOUR;
          clockEnabled = false;
          clockMilliSeconds = 0;
          clockSeconds = 0;
        }
        else if (btn == BUTTON_3_LONG_PRESSED && !alarmTogglePressed)
        {
          alarmTogglePressed = true;
          alarmEnabled = !alarmEnabled;
          MFS.writeLeds(LED_1, alarmEnabled);
        }
        else if (btn == BUTTON_3_LONG_RELEASE)
        {
          alarmTogglePressed = false;
        }
        break;
        
    case MODE_CLOCK_TIME_SET_HOUR:
        if (btn == BUTTON_1_PRESSED)
        {
          MFS.blinkDisplay(DIGIT_1 | DIGIT_2, OFF);
          MFS.blinkDisplay(DIGIT_3 | DIGIT_4);
          displayMode = MODE_CLOCK_TIME_SET_MINUTE;
        }
        else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)
        {
          clockHours++;
          if (clockHours >= 24)
          {
            clockHours = 0;
          }
          displayTime(clockHours, clockMinutes);
        }
        break;
        
    case MODE_CLOCK_TIME_SET_MINUTE:
        if (btn == BUTTON_1_PRESSED)
        {
          MFS.blinkDisplay(DIGIT_3 | DIGIT_4, OFF);
          displayMode = MODE_CLOCK_TIME;
          clockEnabled = true;
        }
        else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)
        {
          clockMinutes++;
          if (clockMinutes >= 60)
          {
            clockMinutes = 0;
          }
          displayTime(clockHours, clockMinutes);
        }
        break;
        
    case MODE_ALARM_TIME:
        displayTime(alarmHours, alarmMinutes);

        if (btn == BUTTON_2_SHORT_RELEASE || btn == BUTTON_2_LONG_RELEASE)
        {
          displayMode = MODE_CLOCK_TIME;
        }
        else if (btn == BUTTON_1_LONG_PRESSED)
        {
          MFS.blinkDisplay(DIGIT_ALL, OFF);
          MFS.blinkDisplay(DIGIT_1 | DIGIT_2);
          displayMode = MODE_ALARM_TIME_SET_HOUR;
          alarmEnabled = false;
        }
        break;
        
    case MODE_ALARM_TIME_SET_HOUR:
        if (btn == BUTTON_1_PRESSED)
        {
          MFS.blinkDisplay(DIGIT_1 | DIGIT_2, OFF);
          MFS.blinkDisplay(DIGIT_3 | DIGIT_4);
          displayMode = MODE_ALARM_TIME_SET_MINUTE;
        }
        else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)
        {
          alarmHours++;
          if (alarmHours >= 24)
          {
            alarmHours = 0;
          }
          displayTime(alarmHours, alarmMinutes);
        }
        break;
        
    case MODE_ALARM_TIME_SET_MINUTE:
        if (btn == BUTTON_1_PRESSED)
        {
          MFS.blinkDisplay(DIGIT_3 | DIGIT_4, OFF);
          displayMode = MODE_CLOCK_TIME;
          alarmEnabled = true;
          MFS.writeLeds(LED_1, ON);
        }
        else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)
        {
          alarmMinutes++;
          if (alarmMinutes >= 60)
          {
            alarmMinutes = 0;
          }
          displayTime(alarmHours, alarmMinutes);
        }
        break;      
  }
}


void displayTime (byte hours, byte minutes)
{
  char time[5];
  
  sprintf(time, "%03d", (hours * 100) + minutes);
  //MFS.write(time, 1);
}

//--------------------------------------------------------------------------------------------------
void clockISR ()
{
  // Perform ripple count for all time components.
  if (clockEnabled)
  {
    clockMilliSeconds++;
    if (clockMilliSeconds >= 1000)
    {
      clockMilliSeconds = 0;
      
      clockSeconds++;
      if (clockSeconds >= 60)
      {
        clockSeconds = 0;
        
        clockMinutes++;
        if (clockMinutes >= 60)
        {
          clockMinutes = 0;
          
          clockHours++;
          if (clockHours >= 24)
          {
            clockHours = 0;
          }
        }
             
        // If current time coincides with alarm time, and alarm is enabled, engage the alarm.
        if (alarmEnabled && (clockMinutes == alarmMinutes) && (clockHours == alarmHours))
        {
          MFS.beep(
                    10,  // on period
                     5,  // off period
                     4,  // number of cycles
                   100,  // number of loop cycles
                    50   // delay between loop cycles
                   );
        }
      }
    }
  }
}`Preformatted text`
1 Like

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