Using Capacitive touch switch

I have an 230 volts AC fan regulator which i want to convert to a digital switch. I’m currently using a capacitive touch switch for the “UP” and “DOWN” buttons.

I wired the touch switch I/O pin straight to arduino pins with a 10k grounding resistor.

When I connect all the components, the touch switch works for few seconds and the keeps going “HIGH” by itself.

Please I need help figuring whats wrong with the code.

Below is the code.

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

/*** PINS ***/
const int Rx = 0;   //digital pin 2
const int Tx = 3;
const int status_led = 6;
const int up_button = 7;   //increase speed
const int down_button = 8;    //decrease speed
const int relay_1 = 9;
const int relay_2 = 10;
const int relay_3 = 11;
const int ssd_A = A0;
const int ssd_B = 13;
const int ssd_C = A2;
const int ssd_D = A1;
const int ssd_E = A3;
const int ssd_F = A4;
const int ssd_G = A5;

//variables
uint16_t Rcode;
int current_speed;

//constants
const int no_of_transmissions = 1;

void setup()
{
  Serial.begin(9600);

  /*** INITIALIZE VARIABLES ***/
  mySwitch.enableReceive(Rx);
  mySwitch.enableTransmit(Tx);

  pinMode(up_button, INPUT);
  pinMode(down_button, INPUT);

  pinMode(relay_1, OUTPUT);
  pinMode(relay_2, OUTPUT);
  pinMode(relay_3, OUTPUT);
  pinMode(status_led, OUTPUT);
  pinMode(ssd_A, OUTPUT);
  pinMode(ssd_B, OUTPUT);
  pinMode(ssd_C, OUTPUT);
  pinMode(ssd_D, OUTPUT);
  pinMode(ssd_E, OUTPUT);
  pinMode(ssd_F, OUTPUT);
  pinMode(ssd_G, OUTPUT);

  digitalWrite(status_led, HIGH);
  current_speed = 0;

  set_speed(0);
}

void loop()
{
  if (mySwitch.available())
  {
    Rcode = mySwitch.getReceivedValue();
    mySwitch.resetAvailable();
    Serial.print("Received code = ");
    Serial.println(Rcode);

    switch (Rcode)
    {
      //for parlor fan
      case 114 :    //OFF
        {
          set_speed(0);
          break;
        }
      case 115:   //speed 1
        {
          set_speed(1);
          break;
        }
      case 116:   //speed 2
        {
          set_speed(2);
          break;
        }
      case 117:   //speed 3
        {
          set_speed(3);
          break;
        }
    }
  }

  if (digitalRead(up_button) == HIGH && digitalRead(down_button) == LOW)   //increase speed
  {
    if ((current_speed + 1) <= 3)
      current_speed++;
    else
      current_speed = 0;

    set_speed(current_speed);
  }

  if (digitalRead(up_button) == LOW && digitalRead(down_button) == HIGH)   //decrease speed
  {
    if ((current_speed - 1) >= 0)
      current_speed--;
    else
      current_speed = 3;

    set_speed(current_speed);
  }
}

void set_speed(int number)
{
  if (number >= 0 && number <= 3)
  {
    int display_array[] = {0, 0, 0, 0, 0, 0, 0};
    int speed_array[] = {0, 0, 0};

    switch (number)
    {
      case 0:
        display_array[0] = 1;
        display_array[1] = 1;
        display_array[2] = 1;
        display_array[3] = 1;
        display_array[4] = 1;
        display_array[5] = 1;
        display_array[6] = 0;

        speed_array[0] = 0;
        speed_array[1] = 0;
        speed_array[2] = 0;

        current_speed = 0;
        sendCode(114);
        break;

      case 1:
        display_array[0] = 0;
        display_array[1] = 1;
        display_array[2] = 1;
        display_array[3] = 0;
        display_array[4] = 0;
        display_array[5] = 0;
        display_array[6] = 0;

        speed_array[0] = 1;
        speed_array[1] = 0;
        speed_array[2] = 0;

        current_speed = 1;
        sendCode(115);
        break;

      case 2:
        display_array[0] = 1;
        display_array[1] = 1;
        display_array[2] = 0;
        display_array[3] = 1;
        display_array[4] = 1;
        display_array[5] = 0;
        display_array[6] = 1;

        speed_array[0] = 0;
        speed_array[1] = 1;
        speed_array[2] = 0;

        current_speed = 2;
        sendCode(116);
        break;

      case 3:
        display_array[0] = 1;
        display_array[1] = 1;
        display_array[2] = 1;
        display_array[3] = 1;
        display_array[4] = 0;
        display_array[5] = 0;
        display_array[6] = 1;

        speed_array[0] = 0;
        speed_array[1] = 0;
        speed_array[2] = 1;

        current_speed = 3;
        sendCode(117);
        break;
    }

    digitalWrite(ssd_A, display_array[0]);
    digitalWrite(ssd_B, display_array[1]);
    digitalWrite(ssd_C, display_array[2]);
    digitalWrite(ssd_D, display_array[3]);
    digitalWrite(ssd_E, display_array[4]);
    digitalWrite(ssd_F, display_array[5]);
    digitalWrite(ssd_G, display_array[6]);

    digitalWrite(relay_1, speed_array[0]);
    delay(100);
    digitalWrite(relay_2, speed_array[1]);
    delay(100);
    digitalWrite(relay_3, speed_array[2]);
  }
}

void sendCode(uint16_t code)
{
  Serial.print("Sent code = ");
  Serial.println(code);

  sendMultiple(Encode(code), no_of_transmissions);
  Serial.println("Data Sent");
}

void sendMultiple(uint16_t msg, int transmissions)
{
  if (transmissions >= 1)
  {
    for (int i = 0; i < transmissions; i++)
    {
      mySwitch.send(msg, 24);
      delay(100);
    }
  }
}
const int Rx = 0;   //digital pin 2
const int Tx = 3;

Either the comment or the code is flawed. Which is it?

  Serial.begin(9600);

You can't be using pin 0 for hardware serial AND the RCSwitch instance, at the same time.

RCSwitch receiver uses interrupt, and interrupt 0 is digital pin 2

JVT:
RCSwitch receiver uses interrupt, and interrupt 0 is digital pin 2

Then your comment should make it clear that that is not a pin number. Yeah, I know you don't have one. You should.

Or, you should use Int in the name, to indicate that it is an interrupt number, and Pin in the name of the Tx variable, to indicate that it IS a pin number.

So now, can you help me figure out what's wrong

JVT:
So now, can you help me figure out what's wrong

Without seeing a schematic? Probably not.

When I connect all the components, the touch switch works for few seconds and the keeps going "HIGH" by itself.

I'm not sure what this means. "HIGH", as used that way, is a string, and the switch state is never a string. It's a value, HIGH or LOW.

When describing the problem, using the same names and types as in the code makes understanding the problem easier.

So, what is really happening?

Below are both pictures of the touch switch, the arduino circuit and a proteus 8 simulation. The push buttons in the simulation represents the touch switch.