Coming soon - Get a detailed view of why an account is flagged as spam!
view details

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.

1
I2C arduino problem
Post Body

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);
}

Author
Account Strength
100%
Account Age
6 years
Verified Email
Yes
Verified Flair
No
Total Karma
35,352
Link Karma
18,276
Comment Karma
15,689
Profile updated: 2 days ago
Posts updated: 7 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago