#include <LiquidCrystal_I2C.h> 
LiquidCrystal_I2C lcd(0x27, 20,4);
//LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

const int TOUCH_SENSOR_PIN = 5; // Arduino pin connected to touch sensor's pin
const int TOUCH_SENSOR_TOUCH = 2; // Arduino pin connected to touch sensor's pin
const int BUZZER_PIN       = 4; // Arduino pin connected to Buzzer's pin

void setup() {
  Serial.begin(9600);               // initialize serial
  lcd.begin(20,4);       // inicializamos el LCD.
  pinMode(TOUCH_SENSOR_PIN, INPUT); // set arduino pin to input mode
  pinMode(TOUCH_SENSOR_TOUCH, INPUT); // set arduino pin to input mode
  pinMode(BUZZER_PIN, OUTPUT);      // set arduino pin to output mode
}

void loop() {
  
  int touchState = digitalRead(TOUCH_SENSOR_PIN); // read new state
  int touchState2 = digitalRead(TOUCH_SENSOR_TOUCH); // read new state
  //
  if (touchState == HIGH) {
    //Serial.println("The sensor is being touched");
    lcd.clear();
    lcd.print("buzzer");
    lcd.clear();
    digitalWrite(BUZZER_PIN, 1); // turn on Piezo Buzzer
    tone(BUZZER_PIN,800);
    delay(100);
    tone(BUZZER_PIN,600);
    delay(100);
    noTone(BUZZER_PIN);
  }
  else
  if (touchState == LOW) {
    //Serial.println("The sensor is untouched");
    digitalWrite(BUZZER_PIN, LOW);  // turn off Piezo Buzzer
  }

  if (touchState2 == HIGH) {
    //Serial.println("The sensor is being touched");
    lcd.clear();
    lcd.print("buzzer");
    lcd.clear();
    digitalWrite(BUZZER_PIN, 1); // turn on Piezo Buzzer
    tone(BUZZER_PIN,800);
    delay(100);
    tone(BUZZER_PIN,600);
    delay(100);
    noTone(BUZZER_PIN);
  }
  else
  if (touchState == LOW) {
    //Serial.println("The sensor is untouched");
    digitalWrite(BUZZER_PIN, LOW);  // turn off Piezo Buzzer
  }

}