CCCPaste

multipleButtonConfig

/********* Pleasedontcode.com **********

  Pleasedontcode thanks you for automatic code generation! Enjoy your code!

  - Terms and Conditions:
  You have a non-exclusive, revocable, worldwide, royalty-free license
  for personal and commercial use. Attribution is optional; modifications
  are allowed, but you're responsible for code maintenance. We're not
  liable for any loss or damage. For full terms,
  please visit pleasedontcode.com/termsandconditions.

  - Project: multipleButtonConfig
  - Source Code compiled for: Arduino Uno
  - Source Code created on: 2023-12-03 16:14:24
  - Source Code generated by: Francesco Alessandro

********* Pleasedontcode.com **********/

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
  /* crea un array di 33 elementi relativo allo stato */
  /* di ogni pulsante. I pulsanti button_x_PushButton */
  /* sono utilizzati per salvare lo stato. */
/****** SYSTEM REQUIREMENT 2 *****/
  /* Se rotarySwitch_Position0 è attivo allora salva i */
  /* pulsanti negli elementi da 0 a 10 dell'array. Se */
  /* rotarySwitch_Position1 è attivo salva i pulsanti */
  /* negli elementi da 11 a 21. Se */
  /* rotarySwitch_Position2 è attivo salva gli elementi */
  /* da 22 a 33. */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include 
#include 

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);

/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t button_0_PushButton_PIN_D2 = 2;
const uint8_t button_1_PushButton_PIN_D3 = 3;
const uint8_t button_2_PushButton_PIN_D4 = 4;
const uint8_t button_3_PushButton_PIN_D5 = 5;
const uint8_t button_4_PushButton_PIN_D6 = 6;
const uint8_t button_5_PushButton_PIN_D7 = 7;
const uint8_t button_6_PushButton_PIN_D8 = 8;
const uint8_t button_7_PushButton_PIN_D9 = 9;
const uint8_t button_8_PushButton_PIN_D10 = 10;
const uint8_t button_9_PushButton_PIN_D11 = 11;
const uint8_t button_10_PushButton_PIN_D12 = 12;
const uint8_t rotarySwitch_Position0_PIN_D13 = 13;
const uint8_t rotarySwitch_Position1_PIN_A0 = A0;
const uint8_t rotarySwitch_Position2_PIN_A1 = A1;

/****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/
EasyButton button_0(button_0_PushButton_PIN_D2);
EasyButton button_1(button_1_PushButton_PIN_D3);
EasyButton button_2(button_2_PushButton_PIN_D4);
EasyButton button_3(button_3_PushButton_PIN_D5);
EasyButton button_4(button_4_PushButton_PIN_D6);
EasyButton button_5(button_5_PushButton_PIN_D7);
EasyButton button_6(button_6_PushButton_PIN_D8);
EasyButton button_7(button_7_PushButton_PIN_D9);
EasyButton button_8(button_8_PushButton_PIN_D10);
EasyButton button_9(button_9_PushButton_PIN_D11);
EasyButton button_10(button_10_PushButton_PIN_D12);
EasyButton rotarySwitch_Position0(rotarySwitch_Position0_PIN_D13);
EasyButton rotarySwitch_Position1(rotarySwitch_Position1_PIN_A0);
EasyButton rotarySwitch_Position2(rotarySwitch_Position2_PIN_A1);


/****** SYSTEM REQUIREMENT 2 *****/
uint8_t buttonStates[33]; // Array to store button states

void setup()
{
  pinMode(button_0_PushButton_PIN_D2, INPUT_PULLUP);
  pinMode(button_1_PushButton_PIN_D3, INPUT_PULLUP);
  pinMode(button_2_PushButton_PIN_D4, INPUT_PULLUP);
  pinMode(button_3_PushButton_PIN_D5, INPUT_PULLUP);
  pinMode(button_4_PushButton_PIN_D6, INPUT_PULLUP);
  pinMode(button_5_PushButton_PIN_D7, INPUT_PULLUP);
  pinMode(button_6_PushButton_PIN_D8, INPUT_PULLUP);
  pinMode(button_7_PushButton_PIN_D9, INPUT_PULLUP);
  pinMode(button_8_PushButton_PIN_D10, INPUT_PULLUP);
  pinMode(button_9_PushButton_PIN_D11, INPUT_PULLUP);
  pinMode(button_10_PushButton_PIN_D12, INPUT_PULLUP);
  pinMode(rotarySwitch_Position0_PIN_D13, INPUT_PULLUP);
  pinMode(rotarySwitch_Position1_PIN_A0, INPUT_PULLUP);
  pinMode(rotarySwitch_Position2_PIN_A1, INPUT_PULLUP);

  // Set initial button states to HIGH (released)
  for (int i = 0; i < 33; i++)
  {
    buttonStates[i] = HIGH;
  }

  // Initialization code goes here
}

void loop()
{
  // Main code goes here

  // Handle button states based on the requirements
  if (rotarySwitch_Position0.read() == LOW)
  {
    buttonStates[0] = button_0.read();
    buttonStates[1] = button_1.read();
    buttonStates[2] = button_2.read();
    buttonStates[3] = button_3.read();
    buttonStates[4] = button_4.read();
    buttonStates[5] = button_5.read();
    buttonStates[6] = button_6.read();
    buttonStates[7] = button_7.read();
    buttonStates[8] = button_8.read();
    buttonStates[9] = button_9.read();
    buttonStates[10] = button_10.read();
  }
  else if (rotarySwitch_Position1.read() == LOW)
  {
    buttonStates[11] = button_0.read();
    buttonStates[12] = button_1.read();
    buttonStates[13] = button_2.read();
    buttonStates[14] = button_3.read();
    buttonStates[15] = button_4.read();
    buttonStates[16] = button_5.read();
    buttonStates[17] = button_6.read();
    buttonStates[18] = button_7.read();
    buttonStates[19] = button_8.read();
    buttonStates[20] = button_9.read();
    buttonStates[21] = button_10.read();    
  }
  else if (rotarySwitch_Position2.read() == LOW)
  {
    buttonStates[22] = button_0.read();
    buttonStates[23] = button_1.read();
    buttonStates[24] = button_2.read();
    buttonStates[25] = button_3.read();
    buttonStates[26] = button_4.read();
    buttonStates[27] = button_5.read();
    buttonStates[28] = button_6.read();
    buttonStates[29] = button_7.read();
    buttonStates[30] = button_8.read();
    buttonStates[31] = button_9.read();
    buttonStates[32] = button_10.read();   
  }
}