Hello everyone,
I am new to Arduino and programing in general and was wondering if I could receive some help on this project I was assigned. Essentially I have to make a part counter that is activated with an IR sensor. The part I am having trouble with is getting parts of my code to activate after other parts are being ran. I currently do not have an Arduino on hand, as it is on its way shipping but I am using the tinkerCAD simulator.
I want it so that after I hit the '' button on the 4x4 keypad, that it will make it so I can input a number next to the 'Fab Cell #' . I currently have two separate blocks of code that work great individually but I want it so that inputting a number will ONLY work if you first press the '' button first.
Thanks anyone for the help, I am very excited to code Arduino.
Here is my code, sorry for any incorrect formatting this is my first post:
#include <Keypad.h> //libraries
#include <Adafruit_LiquidCrystal.h>
static int count = 00; //variable used as first number
Adafruit_LiquidCrystal lcd_1(0);
const byte ROWS = 4;
const byte COLS = 4;
int del = 350;
int fabLoc = 11; // tells the location of the fabrication #
int partLoc = 7;// tells the location of the part #
char hexaKeys [ROWS][COLS] ={
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup()
{
Serial.begin(9600);
lcd_1.begin(16, 2);
lcd_1.print("Fab Cell #");
lcd_1.setCursor(0,1);
lcd_1.print("Part #");
lcd_1.setCursor(partLoc,1);
lcd_1.print("0");
}
void loop(){
char customKey = customKeypad.getKey();
if (customKey=='*'){ // this is the block of code that I want to run first that will allow all the other blocks to run after this is completed
lcd_1.setCursor(fabLoc,0);
lcd_1.print(" ");
lcd_1.setCursor(fabLoc,0);
lcd_1.blink();
}
if (customKey=='1'){
lcd_1.setCursor(fabLoc,0);
lcd_1.noBlink();
delay(del);
lcd_1.print('1');
Serial.println('1');
delay(100);
}
if (customKey=='2'){
lcd_1.setCursor(fabLoc,0);
lcd_1.noBlink();
delay(del);
lcd_1.print('2');
Serial.println('2');
delay(100);
}
if (customKey=='3'){
lcd_1.setCursor(fabLoc,0);
lcd_1.noBlink();
delay(del);
lcd_1.print('3');
Serial.println('3');
delay(100);
}
if (customKey=='4'){
lcd_1.setCursor(fabLoc,0);
lcd_1.noBlink();
delay(del);
lcd_1.print('4');
Serial.println('4');
delay(100);
}
if (customKey=='5'){
lcd_1.setCursor(fabLoc,0);
lcd_1.noBlink();
delay(del);
lcd_1.print('5');
Serial.println('5');
delay(100);
}
if (customKey=='6'){
lcd_1.setCursor(fabLoc,0);
lcd_1.noBlink();
delay(del);
lcd_1.print('6');
Serial.println('6');
delay(100);
}
if (customKey=='7'){
lcd_1.setCursor(fabLoc,0);
lcd_1.noBlink();
delay(del);
lcd_1.print('7');
Serial.println('7');
delay(100);
}
if (customKey=='8'){
lcd_1.setCursor(fabLoc,0);
lcd_1.noBlink();
delay(del);
lcd_1.print('8');
Serial.println('8');
delay(100);
}
if (customKey=='9'){
lcd_1.setCursor(fabLoc,0);
lcd_1.noBlink();
delay(del);
lcd_1.print('9');
Serial.println('9');
delay(100);
}
if (customKey=='0'){
lcd_1.setCursor(fabLoc,0);
lcd_1.noBlink();
delay(del);
lcd_1.print('0');
Serial.println('0');
delay(100);
}
}
