Hi everyone!
I'm new to Arduino and having trouble adding 4X4 keypad to the project. Basically, I do not have enough pins in the Arduino to connect the Keypad. Also, I'm having trouble editing the code to met the required task. The keypad is to turn on the project or turning it off. Attached is the schematic and the code for the project. Can someone help me editing it?
Thanks!
#include <LiquidCrystal.h> // connected to the output pin of MQ-X int mqx_analogPin = A0; int redLed = 7; int greenLed = 6; int buzzer = 9; // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup(){ // set up the LCD's number of columns and rows: lcd.begin(16, 2); pinMode(redLed, OUTPUT); pinMode(greenLed, OUTPUT); pinMode(buzzer, OUTPUT); // Print a message to the LCD. lcd.print("Smoke Sensor"); } void loop() { //initiallize float variable to store value from sensor (analog value from A0) float mqx_value = analogRead(mqx_analogPin); //set the curser starting address of LCD where we want to print sensor value lcd.setCursor(0, 1); //print sensor value on lcd lcd.print(mqx_value); // buzer thereshhold you can set it according to the sensitivity if(mqx_value > 400) { digitalWrite(redLed, HIGH); digitalWrite(greenLed, LOW); //buzzer on tone(buzzer, 1000); } else { digitalWrite(redLed, LOW); digitalWrite(greenLed, HIGH); //buzzer off noTone(buzzer); } //Just here to slow down the output. delay(1000); }