Dear Sir,
I want to interface 3 more DAC chips for my current code with 3 more pins of arduino which are interfaced with I2C. I have used wire.h currently. How can i do 3 more? I mean how to change wire.h and which specific thing is to change for 3 more PCF8591 chips of DAC chip to be interfaced with 3 pins of arduino through 3 soft I2C communications.
Summarizing it, I need to understand i2c communication through soft pins and their code.
Thank you
#include "Wire.h"#define PCF8591 0x90 >> 1void setup(){
Wire.begin();
Serial.begin(9600);}int val=0;void loop(){if(Serial.available()){
val = Serial.read();}//for (int i=0; i<256; i++)//{
Wire.beginTransmission(PCF8591);// wake up PCF8591
Wire.write(0x40);// control byte - turn on DAC (binary 1000000)
Wire.write(val);// value to send to DAC
Wire.endTransmission();// end tranmission//val=val+1;//}/*for (int i=255; i>=0; --i){Wire.beginTransmission(PCF8591); // wake up PCF8591Wire.write(0x40); // control byte - turn on DAC (binary 1000000)Wire.write(i); // value to send to DACWire.endTransmission(); // end tranmission}*/}
The PCF8591 chip can be hardware addressable by three pins available for that purpose: A0, A1 and A2 ( two are enough for your need ). The question that come now is to know if these pins are connected to core processor at your board.
The PCF8591 chip can be hardware addressable by three pins available for that purpose: A0, A1 and A2 ( two are enough for your need ). The question that come now is to know if these pins are connected to core processor at your board.
The solution is to give the hardware address first by setting A0 A1 and A2 then converting that 8 bit binary to hex and then in programming code use that 0xHEX number to start communicating to that DAC chip.
(See data sheet of PCF 8591 for A0 A1 A2 and othe 5 bits of addresses).