Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

Using I2C with arduino

3 posters

Go down  Message [Page 1 of 1]

1Using I2C with arduino Empty Using I2C with arduino Sun Oct 11, 2020 4:10 am

N3w11



Hello, I recently started using the simulator and I wanted to know if the i2c of the arduino can be used. I wanted to use the arduino's i2c to control HD44780. This is possible? I saw that there is a logic controller that converts from i2c to parallel, but I did not know how to implement it with the display.

2Using I2C with arduino Empty Ardiono with IC2 for LCD display Sun Oct 11, 2020 11:08 am

MD Harrington



Hi yes this is perfectly possible

You need a PCF8574 available from Texas instruments

RS, CPC .  Arrow electronics  components  or similar will  supply this    then use the LCD in 4 bit mode only

 You cant use  the  full 8 bit capability   of the  aforementioned IC since you need  lines RS , EN  and back light  amounting to 7 bits

You can how ever use this  with LCD in 4 Bit Mode

Interfacing PCF8574 with Arduino

Since the job of the PCF8574 Module is to expand the IO capabilities of a microcontroller, we can use it with our Arduino UNO board to increase the digital IO count to 21. The IO Port pins of the Module can be used as either input or output

The following is a simple block diagram of interfacing PCF8574 with a microcontroller where two of the IO Port pins are configured as inputs, one pin is to drive an LED and the remaining pins acts as control pins (outputs) for several external peripherals.

First, we have to figure out the I2C bus slave address of the PCF8574 Module. Use the following code to calculate the address of the Module This is done through A0 , A1 and A2 by grounding pins to select your address

PCF8574 example with Arduino


Code:

#include <Wire.h>

void setup()
{
Wire.begin();

Serial.begin(9600);
while (!Serial);
}

void loop()
{
byte error, address;
int I2CDevices;

Serial.println(“Scanning for I2C Devices…”);

I2CDevices = 0;
for (address = 1; address < 127; address++ )
{
Wire.beginTransmission(address);
error = Wire.endTransmission();

if (error == 0)
{
Serial.print(“I2C device found at address 0x”);
if (address < 16)
Serial.print(“0″);
Serial.print(address, HEX);
Serial.println(” !”);

I2CDevices++;
}
else if (error == 4)
{
Serial.print(“Unknown error at address 0x”);
if (address < 16)
Serial.print(“0”);
Serial.println(address, HEX);
}
}
if (I2CDevices == 0)
Serial.println(“No I2C devices found\n”);
else
Serial.println(“****\n”);

delay(5000);
}

 

Next you need to write to ports of the PCF8574

This would be your approach to this solution and then you need to go and obviously look at your commands for the arduino and substitue into your I2C commands for in your code

See below for example code

Code:

#include <Wire.h>

void setup()
{
Wire.begin();
}

void loop()
{

Wire.beginTransmission(0x20);
Wire.write(0xAA);
Wire.endTransmission();
delay(1000);
Wire.beginTransmission(PCF8574_ADDR);
Wire.write(0x55);
Wire.endTransmission();
delay(1000);
}

Images for basic interface


I trust that answers your question



Last edited by MD Harrington on Sun Oct 11, 2020 11:28 am; edited 1 time in total (Reason for editing : Include example code and images)

N3w11 likes this post

3Using I2C with arduino Empty Re: Using I2C with arduino Mon Oct 12, 2020 6:57 am

arcachofo

arcachofo

Hi.

There is an example that shows how to connect:
File_exploer->Examples->Arduino->software_i2c_lcd

This example is using a sofware I2C library.
To use hardware I2C you should get the proper library and connect SDA to Arduino A4 and SCL to Arduino A5.

N3w11 likes this post

4Using I2C with arduino Empty Re: Using I2C with arduino Mon Oct 12, 2020 8:46 pm

N3w11



Great thank you very much! The same day I published it, I solved it by looking at a schematic on the internet. Very useful about the examples, I did not know that the program already included them!

MD Harrington likes this post

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum