I have one Project with OLED and Keypad.If I Press any Number in Keypad it show Correspondin
7displayprob.ino (9.2 KB)
g Value to the all 6 OLED Screen.It s All fine till 5 th Display.
6 th only Continuous Showing All Correspond Value assign With Keypad.\
in previous i Assigned Predefine Value for EachUse code tags to format code for the forum
`
#include <SPI.h>
#include <Wire.h>
#include <Keypad.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
const byte numRows= 4; //number of rows on the keypad
const byte numCols= 4; //number of columns on the keypad
char keymap[numRows][numCols]=
{
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
static const unsigned char PROGMEM logo16_glcd_bmp[] = { B00000000, B11000000, B00000001, B11000000, B00000001, B11000000, B00000011, B11100000, B11110011, B11100000, B11111110, B11111000, B01111110, B11111111, B00110011, B10011111, B00011111, B11111100, B00001101, B01110000, B00011011, B10100000, B00111111, B11100000, B00111111, B11110000, B01111100, B11110000, B01110000, B01110000, B00000000, B00110000 };
#if (SSD1306_LCDHEIGHT != 64)
//#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
char keypressed;
byte rowPins[numRows] = {9,8,7,6}; //Rows 0 to 3
byte colPins[numCols]= {5,4,3,2}; //Columns 0 to 3
//initializes an instance of the Keypad class
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);
int val = 0;
int val1;
int val2;
int val3;
int val4;
int val5;
int val6;
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display1(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
Adafruit_SSD1306 display2(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
Adafruit_SSD1306 display3(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
Adafruit_SSD1306 display4(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
Adafruit_SSD1306 display5(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
Adafruit_SSD1306 display6(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// for each TCA9548A, add an entry with its address
const uint8_t TCA_ADDRESSES[] = {
0x70,
0x71,
0x73
};
const uint8_t TCA_COUNT = sizeof(TCA_ADDRESSES) / sizeof(TCA_ADDRESSES[0]);
void tcaselect(uint8_t tca, uint8_t channel) {
if (tca >= TCA_COUNT) return;
if (channel > 7) return;
// loop over all TCA's
for (uint8_t i = 0; i < TCA_COUNT; i++) {
Wire.beginTransmission(TCA_ADDRESSES[i]);
if (i == tca) {
// set output channel for selected TCA
Wire.write(1 << channel);
} else {
// for others, turn off all channels
Wire.write(0);
}
Wire.endTransmission();
}
}
void setup() {
Serial.begin(9600);
Wire.begin();
Serial.begin(9600);
while (!Serial);
Serial.println("Multiple TCA9548A Example.");
Serial.print("Total number of TCA's = ");
Serial.println(TCA_COUNT);
for (uint8_t i = 0; i < TCA_COUNT; i++) {
Serial.print(i);
Serial.print(" : 0x");
Serial.println(TCA_ADDRESSES[i], 16);
}
// Init OLED display on bus number 1 (display 1)
tcaselect(0, 0);
if (!display1.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;)
;
}
// Clear the buffer
display1.clearDisplay();
// Init OLED display on bus number 2
tcaselect(0, 1);
if (!display2.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;)
;
}
// Clear the buffer
display2.clearDisplay();
// Init OLED display on bus number 3
tcaselect(0, 2);
if (!display3.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;)
;
}
// Clear the buffer
display3.clearDisplay();
// Init OLED display on bus number 4
tcaselect(0, 3);
if (!display4.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;)
;
}
// Clear the buffer
display4.clearDisplay();
// Init OLED display on bus number 4
tcaselect(0, 4);
if (!display5.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;)
;
}
// Clear the buffer
display5.clearDisplay();
// Init OLED display on bus number 4
tcaselect(0, 5);
if (!display6.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;)
;
}
// Clear the buffer
display6.clearDisplay();
tcaselect(0, 0);
display1.setTextSize(8);
display1.setTextColor(WHITE);
display1.setCursor(28, 8);
// Display static text
display1.println("vj");
Serial.print(val1);
display1.display();
display1.println("\n");
// Write to OLED on bus number 3
tcaselect(0, 1);
display2.setTextSize(8);
display2.setTextColor(WHITE);
display2.setCursor(28, 8);
// Display static text
display2.println("Vj");
Serial.print(val2);
display2.display();
display2.println("\n");
// Write to OLED on bus number 4
tcaselect(0, 2);
display3.setTextSize(8);
display3.setTextColor(WHITE);
display3.setCursor(28, 8);
// Display static text
display3.println("vj");
Serial.print(val3);
display3.display();
display3.println("\n");
// Write to OLED on bus number 5
tcaselect(0, 3);
display4.setTextSize(8);
display4.setTextColor(WHITE);
display4.setCursor(28, 8);
// Display static text
display4.println("vj");
Serial.print(val4);
display4.display();
display4.println("\n");
// Write to OLED on bus number 5
tcaselect(0, 4);
display5.setTextSize(8);
display5.setTextColor(WHITE);
display5.setCursor(28, 8);
// Display static text
display5.println("vj");
Serial.print(val5);
display5.display();
display5.println("\n");
// Write to OLED on bus number 5
tcaselect(0, 5);
display6.setTextSize(8);
display6.setTextColor(WHITE);
display6.setCursor(28, 8);
// Display static text
display6.println("vj");
Serial.print(val6);
display6.display();
display6.println("\n");
}
void loop()
{
while (1)
{
String s;
Serial.println("vijay");
char keypressed = myKeypad.getKey();
Serial.println(keypressed);
if (keypressed != NO_KEY)
{
if (keypressed == '0')
{
Serial.println(keypressed);
val1 = 1;
val2 = 2;
val3 = 3;
val4 = 23;
val5 = 4;
val6 = 5;
}
else if (keypressed == '1')
{
Serial.println(keypressed);
val1 = 6;
val2 = 7;
val3 = 8;
val4 = 45;
val5 = 9;
val6 = 10;
}
else if (keypressed == '2')
{
Serial.println(keypressed);
val1 = 10;
val2 = 12;
val3 = 13;
val4 = 23;
val5 = 14;
val6 = 15;
}
}
break;
}
display1.setTextSize(1);
display1.setTextColor(WHITE);
display1.setCursor(10, 0);
display1.clearDisplay();
display1.println("");
printText();
display1.display();
display2.setTextSize(1);
display2.setTextColor(WHITE);
display2.setCursor(10, 0);
display2.clearDisplay();
display2.println("");
printText();
display2.display();
display3.setTextSize(1);
display3.setTextColor(WHITE);
display3.setCursor(10, 0);
dis`Use code tags to format code for the forum`play3.clearDisplay();
display3.println("");
printText();
display3.display();
display4.setTextSize(1);
display4.setTextColor(WHITE);
display4.setCursor(10, 0);
display4.clearDisplay();
display4.println("");
printText();
display4.display();
display5.setTextSize(1);
display5.setTextColor(WHITE);
display5.setCursor(10, 0);
display5.clearDisplay();
display5.println("");
printText();
display5.display();
display6.setTextSize(1);
display6.setTextColor(WHITE);
display6.setCursor(10, 0);
display6.clearDisplay();
display6.println("");
printText();
display6.display();
}
void printText(void)
{
tcaselect(0, 0);
display1.setTextSize(8);
display1.setTextColor(WHITE);
display1.setCursor(28, 8);
// Display static text
display1.println(val1);
Serial.print(val1);
display1.display();
display1.println("\n");
// Write to OLED on bus number 3
tcaselect(0, 1);
display2.setTextSize(8);
display2.setTextColor(WHITE);
display2.setCursor(28, 8);
// Display static text
display2.println(val2);
Serial.print(val2);
display2.display();
display2.println("\n");
// Write to OLED on bus number 2
tcaselect(0, 2);
display3.setTextSize(8);
display3.setTextColor(WHITE);
display3.setCursor(28, 8);
// Display static text
display3.println(val3);
Serial.print(val3);
display3.display();
display3.println("\n");
// Write to OLED on bus number 2
tcaselect(0, 3);
display4.setTextSize(8);
display4.setTextColor(WHITE);
display4.setCursor(28, 8);
// Display static text
display4.println(val4);
Serial.print(val4);
display4.display();
display4.println("\n");
// Write to OLED on bus number 2
tcaselect(0, 4);
display5.setTextSize(8);
display5.setTextColor(WHITE);
display5.setCursor(28, 8);
// Display static text
display5.println(val5);
Serial.print(val5);
display5.display();
display5.println("\n");
tcaselect(0, 5);
display6.setTextSize(8);
display6.setTextColor(WHITE);
display6.setCursor(28, 8);
// Display static text
display6.println(val6);
Serial.print(val6);
display6.display();
display6.println("\n");
}
`