Created
September 9, 2018 01:36
-
-
Save giljr/6cd0ab8aaa35b4693f240cdfb80b10f4 to your computer and use it in GitHub Desktop.
https://medium.com/jungletronics/arduino-multi-file-sketch-583a7833162c Arduino Multi File Sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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