This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
hello , I'm new with arduino and I was trying to a project for mine! it was about connecting two arduino with i2c , keypad connected to master and lcd connected to slave! but after hours of working on it (was testing it in proteus), I managed to solve (some how ) it but the real issue is that LCD keep trping "black rectangles"(char 255) when i'm AFK and i tried to put if to remove that its keep typing empty characters. it keeps typing till i click on a button then it type that number and again type that stuff right after that. like this image
can you help me??
master code is :
#include <Keypad.h>
#include <Keypad_I2C.h>
#include<Wire.h> //Library for I2C Communication functions
char data;
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad
Keypad mykeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup()
{
Serial.begin(9600);
Wire.begin();
}
void loop()
{
unsigned char customkey = mykeypad.getKey();
Wire.beginTransmission(4);
if(customkey >= 0){
Wire.write(customkey);
}
Wire.endTransmission();
delay(50);
}
and slave is :
#include <Wire.h>
#include<LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); //Define LCD Module Pins (RS,EN,D4,D5,D6,D7)
void setup()
{
Serial.begin(9600);
Wire.begin(4);
Wire.onReceive(receiveEvent);
lcd.begin(16, 2);
lcd.print(0);
}
void receiveEvent(int numbytes)
{
}
void loop(){
char num = Wire.read();
if (num!=char(255)){
lcd.print(num);
}
delay(30);
}
Subreddit
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnprogra...