int tiempo =200;
int pin;
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] =
{
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {13, 12, 11, 10}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {9, 8, 7, 6 }; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
//////////
void setup() {
Serial.begin(9600);
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("BIENVENIDOS");
lcd.setCursor(0,1);
lcd.print("CODIGO DE LUCES de Abraham ");
delay(2000);
lcd.clear();
for (pin=2;pin<=5;pin++)
{
pinMode(pin,OUTPUT);
}
}
void secuencia_0 ()
{
for(pin=2;pin<=5;pin++)
{
digitalWrite(pin, HIGH);
delay(tiempo);
digitalWrite(pin, LOW);
delay(tiempo);
}
for (int i = 0; i< 3; i++ )
{
digitalWrite(13,HIGH);
lcd.setCursor(0,0);
lcd.print("secuencia 0");
}
}
///////
void secuencia_1 ()
{
for(pin=5;pin>=2;pin--)
{
digitalWrite(pin, HIGH);
delay(tiempo);
digitalWrite(pin, LOW);
delay(tiempo);
}
{
digitalWrite(13,LOW);
lcd.setCursor(0,0);
lcd.print("secuencia 1");
}
}
///////
void secuencia_2()
{
for(pin=4;pin>=3;pin--)
{
digitalWrite(pin, HIGH);
delay(500 );
digitalWrite(pin, LOW);
delay(500);
}
{
digitalWrite(13, HIGH);
lcd.setCursor(0,0);
lcd.print("secuencia 2");
}
}
/////////////////////////
void secuencia_3()
{
for(pin=3;pin<=4;pin++)
{
digitalWrite(pin, HIGH);
delay(300);
digitalWrite(pin, LOW);
delay(300 );
}
{
digitalWrite(pin, LOW);
lcd.setCursor(0,0);
lcd.print("secuencia 3");
}
}
/////////////////////////////////
void loop()
{
char key =keypad.getKey();
if (key)
{
Serial.println(key);
}
if (key == '0')
{
secuencia_0();
}
if (key == '1')
{
secuencia_1();
}
if (key== '2')
{
secuencia_2();
}
if(key=='3')
{
secuencia_3();
}
}
//////////