You are free to use this code for your own projects
IntroductionThe calculator is a simple yet challenging project for beginners. The code, the connection diagram as well as the simulation results are shared in this project. You can always tinker with the code and the working simulation of the Calculator project online.
Connection diagramThe complete code is provided in the link below
Summary of the project- Display setup
/* Display */
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
- Keypad setup
/* Keypad setup */
const byte KEYPAD_ROWS = 4;
const byte KEYPAD_COLS = 4;
byte rowPins[KEYPAD_ROWS] = {5, 4, 3, 2};
byte colPins[KEYPAD_COLS] = {A3, A2, A1, A0};
char keys[KEYPAD_ROWS][KEYPAD_COLS] = {
{'1', '2', '3', '+'},
{'4', '5', '6', '-'},
{'7', '8', '9', '*'},
{'.', '0', '=', '/'}
};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, KEYPAD_ROWS, KEYPAD_COLS);
- Show welcome screen
void showSpalshScreen() {
lcd.print("GoodArduinoCode");
lcd.setCursor(3, 1);
String message = "Calculator";
for (byte i = 0; i < message.length(); i++) {
lcd.print(message[i]);
delay(50);
}
delay(500);
}
- Blink the cursor (without using the delay function!)
void updateCursor() {
if (millis() / 250 % 2 == 0 ) {
lcd.cursor();
} else {
lcd.noCursor();
}
}
- SETUP() function
- showSplashScreen() function to display welcome message
- lcd.clear() function clears the display
- lcd.cursor() function brings the cursor
- lcd.setCursor() function sets the location of the cursor
void setup() {
Serial.begin(115200);
lcd.begin(16, 2);
showSpalshScreen();
lcd.clear();
lcd.cursor();
lcd.setCursor(1, 0);
}
I would leave from here to allow you to find out the rest of the code by yourself. Please leave a comment here or on the Discord channel if you have any questions or suggestions. I will be glad to help you. Finally, here is the link small video of the project in action
Share your interesting projects and browse through several curious projects from fellow developers and makers on Facebook Wokwi Group!
Stay Safe!
Don't stop learning!
#wokwiMakes
Comments