Skip to content

Instantly share code, notes, and snippets.

@giljr
Created September 9, 2018 01:36
Show Gist options
  • Save giljr/6cd0ab8aaa35b4693f240cdfb80b10f4 to your computer and use it in GitHub Desktop.
Save giljr/6cd0ab8aaa35b4693f240cdfb80b10f4 to your computer and use it in GitHub Desktop.
/* Project Ardu_Serie # 45
Working w/ MultiFile Sketch - Part IV - Atmega328p IC - Arduino MC
Ino File: _45_working_w_MultiFile_Sketch_04.ino
*/
#include <LiquidCrystal.h>
#include <DFR_LCD_Keypad.h> //Sample using https://www.dfrobot.com library
// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// initialise the keypad
DFR_LCD_Keypad keypad(A0, &lcd);
#include "HC_SR04.h" // Warning: this headers should come after the lcd boot
#include "PIR.h"
#include "TMP36.h"
// define the key used by the panel and buttons
int key;
void setup()
{
lcd.begin(16, 2); // start the library
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Push the buttons"); // print a simple message
HC.HC_Setup(11, 12);
PIR.PIR_Setup(13, 2, HIGH);
TMP36.TMP36_Setup(1);
}
void loop()
{
PIR.PIR_Loop();
lcd.setCursor(0, 1); // move to the begining of the second line
key = keypad.read_key(); // read the buttons
// print the key selection to the LCD
switch (key) // depending on which button was pushed, we perform an action
{
case KEY_RIGHT:
{
PIR.PIR_Display();
break;
}
case KEY_LEFT:
{
HC.HC_Loop();
HC.HC_Display();
break;
}
case KEY_DOWN:
{
TMP36.TMP36_Loop();
TMP36.TMP36_Display();
break;
}
case KEY_SELECT:
{
lcd.print("Thank you!I'm J3");
break;
}
case KEY_NONE:
{
lcd.print(" ");
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment