How to display keypad on Blynk LCD?

Hi Blynkers!

I need help for my project. i really dont know how to start, but i need to know how to display output from keypad to lcd on blynk.

I use a randomseed function on arduino to create a password, then how can i link the generated code to with the keypad to unlock something?

Get it working without Blynk, so that whatever you want to appear on the LCD widget is appearing in the serial monitor, then add-in the Blynk bit.

Pete.

Hi Blynkers!

Need help on my project. Now im working on IOT parking project.

The avaibility of the parking can be diplay on blynk using LED while led on the parking slot will be light green or red. Then we can book the parking which available using a button widget. When push the button, led on parking slot change to blue and servo will turn to close the parking, and a code will generate as a passcode to enter the parking.

My problem is, i dont know how to do keypad part which will be the input for the code.
How to diplay pressbutton on keypad to blynk lcd?
Then how to make sure the code press = to passcode generated?

This is my test code. But still when i press the keypad, the number show is going crazy. just random number display on the lcd.


#define BLYNK_PRINT Serial

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <Servo.h>
#include <Keypad.h>

#define EspSerial Serial2
#define ESP8266_BAUD 115200

char auth[] = "token";
char ssid[] = "myssid";
char pass[] = "mypass";

#define Password_Lenght 5

char Data[Password_Lenght]; // 4 is the number of chars it can hold + the null char = 5
char Master[Password_Lenght] = "randomNumber"; 
byte data_count = 0, master_count = 0;
//bool Pass_is_good;
char customKey;
bool book = true;

//int key [4];
//int masterKey [4];
//int flag= 0;
int pos=0;


ESP8266 wifi(&EspSerial);

int servopin=37;
const int LED_r =53;
const int LED_g =52;
const int LED_b =51;
//int reset=40;

long randomNumber;
const int IRsensorpin = 41;
int IRsensor = HIGH;
//int LED_r = HIGH;
//int LED_g = HIGH;
//int LED_b = HIGH;



WidgetLCD lcd(V3);
WidgetLED led1(V1);
WidgetLED led2(V2);
Servo servo;


const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};

byte rowPins[ROWS] = 
{2,3,4,5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = 
{10,9,8}; //connect to the column pinouts of the keypad

Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS); //initialize an instance of class NewKeypad 




void setup()
{
  //digitalWrite (reset, HIGH);
 // pinMode(reset, OUTPUT);
  pinMode(servopin, OUTPUT);  // declare LED as output
  pinMode (LED_r, OUTPUT);
  pinMode (LED_g, OUTPUT);
  pinMode (LED_b, OUTPUT);
  pinMode(IRsensorpin, INPUT);
  servo.attach(servopin);
  //LED_r = digitalRead(LED_rpin);
  //LED_g = digitalRead(LED_gpin);
  //LED_b = digitalRead(LED_bpin);

 

  Serial.begin(9600);
  
  EspSerial.begin(ESP8266_BAUD);                       
  delay(10);

  randomSeed( analogRead(A0));

  Blynk.begin(auth, wifi, ssid, pass);

}

void loop()

{
  p1slot();

  digitalWrite(IRsensor, HIGH);
  
  keypad1 ();
  Blynk.run(); 
}



void p1slot()
{
  Blynk.run();
  IRsensor = digitalRead(IRsensorpin);
  if( IRsensor == LOW)
  {
    led1.on();
    //Serial.println("Stop something is ahead!!");
    digitalWrite(LED_r, LOW);
    digitalWrite(LED_g, HIGH);
   // digitalWrite(LED_b, HIGH);
  }
 else //if ( IRsensor == HIGH)
  {
    led1.off();
    //Serial.println("Path is clear");
    digitalWrite(LED_g, LOW);
    digitalWrite(LED_r, HIGH);
    //digitalWrite(LED_b, HIGH);  
  }
delay(200); 
}

void keypad1 ()
{
  Blynk.run();
  
  if (book == 0)
  {
    customKey = customKeypad.getKey();

    if (customKey == '#')

    {
      lcd.clear();
      ServoClose();
      lcd.print(0,0, "  Door is close");
      delay(3000);
      book = 1;
    }
  }

  else Open();
}

void clearData()
{
  while (data_count != 0)
  { // This can be used for any array size,
    Data[data_count--] = 0; //clear array for new data
  }
  return;
}

void ServoOpen()
{
  for (pos = 180; pos >= 0; pos -= 5) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    servo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

void ServoClose()
{
  for (pos = 0; pos <= 180; pos += 5) { // goes from 180 degrees to 0 degrees
    servo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

void Open()
{
  //lcd.setCursor(0, 0);
  lcd.print( 0, 0, " Enter Password");
  
  customKey = customKeypad.getKey();
  if (customKey) // makes sure a key is actually pressed, equal to (customKey != NO_KEY)
  {
    Data[data_count] = customKey; // store char into data array
   // lcd.setCursor(data_count, 1); // move cursor to show each new char
    lcd.print(data_count, 1, Data[data_count]); // print char at said cursor
    data_count++; // increment data array by 1 to store new char, also keep track of the number of chars entered
  }

  if (data_count == Password_Lenght - 1) // if the array index is equal to the number of expected chars, compare data to master
  {
    if (!strcmp(Data, Master)) // equal to (strcmp(Data, Master) == 0)
    {
      lcd.clear();
      ServoOpen();
      lcd.print( 0, 0, "  Door is Open");
      book = 0;
    }
    else
    {
      lcd.clear();
      lcd.print( 0, 0, "  Wrong Password");
      delay(1000);
      book = 1;
    }
    clearData();
  }
}
  
    
  BLYNK_WRITE(V10)
{
  if (param.asInt()==1)
  {
    ServoOpen();
    digitalWrite(LED_b, LOW);
    //digitalWrite(LED_g, HIGH);
    //digitalWrite(LED_r, HIGH);

    int randomNumber = random(1000,9999);
    Serial.print("The Number is = ");
    Serial.println(randomNumber);
    Blynk.notify(randomNumber);
    delay(1000); 
   // keypad1 ();
    //book = 1; 
    
  }
  else
  {
    ServoClose();
    digitalWrite(LED_b, HIGH);
  }
  
}

I’ve merged this back into your original thread, and deleted the other thread that you commenced on the subject.
Please keep your discussion on this topic within one thread.

Pete.