OLED-Button Mapping

This projects aims to show real time update, showing what keypad button you pressed on the OLED display.

COMPONENTS AND SUPPLIES

4x4 Keypad

1

OLED Display

1

InventrKits HERO

The HERO is a derivative of “Arduino UNO R3 Reference design” we just changed up a few things to make it our own. If you’re curious about what goes into our HERO board we published the open-source hardware files on our GitHub.

1

Male to Female Wire

12

ABOUT THIS PROJECT

This is the first part of the 4×4 Whack-A-Mole where I believe most people can make use of. There 4×4 set of frame boxes, representing every buttons in the 4×4 keypad array. When you press a button on the keypad, a box frame in the OLED that is representing the position of the button you pressed will be a solid box.

SCHEMATICS

COMMENTS

Leave a Reply

Your email address will not be published. Required fields are marked *

#include “U8glib.h” #include <Keypad.h> U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI //CONSTANTS const byte ROWS = 4; const byte COLS = 4; // GLOBALS char customKey; // instantiate customKey var char buttons[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] = {10, 11, 12, 13}; Keypad customKeypad = Keypad(makeKeymap(buttons), rowPins, colPins, ROWS, COLS); void setup(void) { // flip screen, if required // u8g.setRot180(); // assign default color value u8g.setColorIndex(1); // pixel on Serial.begin(9600); pinMode(8, OUTPUT); u8g.firstPage(); do{ drawBlank(); } while ( u8g.nextPage() ); } void loop(void) { customKey = customKeypad.getKey(); if(customKey) { Serial.print(customKey); switch(customKey) { case '1': drawDisplayBox(0,0); break; case '2': drawDisplayBox(15,0); break; case '3': drawDisplayBox(30,0); break; case 'A': drawDisplayBox(45,0); break; case '4': drawDisplayBox(0,15); break; case '5': drawDisplayBox(15,15); break; case '6': drawDisplayBox(30,15); break; case 'B': drawDisplayBox(45, 15); break; case '7': drawDisplayBox(0,30); break; case '8': drawDisplayBox(15,30); break; case '9': drawDisplayBox(30,30); break; case 'C': drawDisplayBox(45, 30); break; case '*': drawDisplayBox(0,45); break; case '0': drawDisplayBox(15,45); break; case '#': drawDisplayBox(30,45); break; case 'D': drawDisplayBox(45, 45); break; } } } void drawDisplayBox(uint8_t x, uint8_t y) { u8g.firstPage(); do{ drawDefault(x,y); } while ( u8g.nextPage() ); } void drawDefault(int X, int Y) { // graphic commands to redraw the complete screen should be placed here for (int posX = 0; posX < 4; posX++) { for (int posY = 0; posY < 4; posY++) { int xVal = posX*15; int yVal = posY*15; if (X == xVal && Y == yVal) { u8g.drawBox(xVal,yVal,8,8); } else { u8g.drawFrame(posX*15,posY*15,8,8); } } } } void drawBlank() { // graphic commands to redraw the complete screen should be placed here for (int posX = 0; posX < 4; posX++) { for (int posY = 0; posY < 4; posY++) { int xVal = posX*15; int yVal = posY*15; u8g.drawFrame(posX*15,posY*15,8,8); } } }
PROJECT AUTHOR
Leave a comment
TEAM MEMBERS
Belrey

programming

TABLE OF CONTENTS
Leave a comment
Share on whatsapp
Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on pinterest
Share on email

SIMILAR PROJECTS YOU MIGHT LIKE

I cascaded four SN74HC595 shift registers to control 32 LEDs on 4 registers using 3 wires. I am adding a I2C 20×4 LCD screen to display the register and led values. I might add a standard 16×2 LCD screen to show up it is done.
A simple light meter. It’s not calibrated to any meaningful scale, but the digital readout shows a higher number the brighter is the light falling on the photoresistor.