Book Image

Internet of Things Programming with JavaScript

Book Image

Internet of Things Programming with JavaScript

Overview of this book

The Internet of Things is taking the tech world by storm, and JavaScript is at its helm. This book will get you to grips with this exciting new technology. Where do Node.js, HTML5 and Windows 10 IoT Core come in with JavaScript and IoT? Why Raspberry Pi Zero rather than Arduino? How do you configure and build an IoT network from scratch? All your IoT JavaScript questions are answered in this book.
Table of Contents (15 chapters)
Internet of Things Programming with JavaScript
Credits
About the Author
www.packtpub.com
Customer Feedback
Preface

Controlling the door lock with a keypad


In the following image, we see a keypad with a lock. This section can be merged along with the last project. This device can be controlled from your Raspberry Pi Zero or your Arduino board:

 Code to access using the keypad

You can now either copy the code inside a file called Project_keyboard_Access_Control.ino, or just get the complete code from the folder for this project using the Arduino IDE:

void captura() 
{ 
  tecla = customKeypad.getKey(); 

  if (tecla) 
  { 
    digito = digito + 1; 
    if(tecla==35){tecla=0;digito=0;valorf=0;lcd.setCursor(0,0);lcd.print(valorf);
      lcd.print("          ");}          
    if(tecla==48){tecla=0;} 
    if(tecla==42){tecla=0;digito=0;valor = valorf;} 

   if(digito==1){valorf1 = tecla; valorf=valorf1;lcd.setCursor(0,0);
       lcd.print(valorf);lcd.print("          ");}  
     if(digito==2){valorf2 = tecla+(valorf1*10);valorf=valorf2;lcd...