maiodrop.blogg.se

Arduino wire library
Arduino  wire library






arduino wire library

If value received is 3 blink LED for 400 msįirst, let's look at the master. If value received is 0 blink LED for 200 ms X = Wire.read() // read one character from the I2C Attach a function to trigger when something is received. Start the I2C Bus as Slave on address 9 If (x > 5) x = 0 // `reset x once it gets 6Īnd here is the slave code that interprets the characters sent from the master: // Include the required Wire library for I2C#include Wire.endTransmission() // stop transmitting Wire.beginTransmission(9) // transmit to device #9 First, let's take a look at the master code: // Include the required Wire library for I2C#include / Experiment of PCF8574 IO expander // Name:- M.The following code is split in two parts: the master code and the slave code, which run on two different Arduinos. The project is successfully simulated by using the Proteus.

arduino wire library

Upper nibble is configured as output and connected with 4 LEDs. Lower nibble is configured as inputs, and connected with 4 way dip switch. Lower nibble of Group 2 IO expander is read and displayed at upper nibble of the same IO expander. The binary counter is incremented by every 300 mS and writes it to the Group 1 IO expander, where LEDs are connected and configured as digital output pins.

arduino wire library arduino wire library

The included Wire library allows to communicate to the I2C/TWI bus of Arduino. Commonly used to select the operating modes of an electronic device for specific situations.Ī 4 way DIP switch is connected to the lower nibble of PCF8574 Group2 device IO pins through 10K ohm pullup resistors.Īnd 4 LEDs are connected to the upper nibble of PCF8574 Group2 device IO pins through 330 ohm current limiting resistors. The 8 LED’s are connected to the PCF8574 Group1 device IO pins through 330 ohm current limiting resistors.ĭIP switches are manual electrical switches arranged and packed in Dual Inline Package. The least significant bit of address is used for Write (0) or Read (1) operation selection.Įight PCF8574 can be connected to the I2C bus, with hardwire address selection on each device. The Address range of PCF8574 is 0x20 to 0x27 (7 bit address mode). The device features an 8-bit quasi-bidirectional I/O port (P0–P7), including latched outputs with high current drive capability for directly driving LEDs.Įach quasi-bidirectional I/O can be used as an input or output without the use of a data-direction control signal. The PCF8574 device provides general-purpose remote I/O expansion. I2C data pin (SDA) is connected to ADC4 and clock pin (SCL) is connected to ADC5. PCF8574 is the Input / Output (I/O) expander, which will be connected to the Arduino I2C bus.








Arduino  wire library