Go Down

Topic: Run 2 i2r devices on a Deamilanove similtaneously? (Read 646 times) previous topic - next topic

alfiesty

I thinking of a project where I'll need a Wifi shield and a LCD shield both running together. Is this possible and if so, how?

Jim
8000ft above the average


alfiesty

8000ft above the average

Aeturnalus

I2C is designed for chaining - just connect both devices to the SDA and SCK lines, and make sure they have nonconflicting addresses.

alfiesty


I2C is designed for chaining - just connect both devices to the SDA and SCK lines, and make sure they have nonconflicting addresses.


Thanks for the reply! How does the Arduino specify the device address? I assume that means I could stack I2C shields by just giving them different addresses.

Jim
8000ft above the average

CrossRoads

The wiring.h library is used for I2C. Your program will contain the device address and the data you are sending it.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

Here's the correct thing to call out, I was a little off:
Code: [Select]

#include <Wire.h>  // bring in Wire Library

//Then you can set up some addresses to use, these are for MAX6953 for example:

//  I2C device address is 1 0 1   A3 A2 A1 A0  with AD1, AD0 both low
#define COMMAND_ADDRESS (0x50);
#define CONFIG_ADDRESS (0x04);
#define INTENSITY10_ADDRESS (0x01);
#define INTENSITY32_ADDRESS (0x02);
#define SCANLIMIT_ADDRESS (0x03);
#define DIGIT0_ADDRESS (0x60);
#define DIGIT1_ADDRESS (0x61);
#define DIGIT2_ADDRESS (0x62);
#define DIGIT3_ADDRESS (0x63);


and send a command,  I did this in Setup to get ready for Loop:
Code: [Select]

void setup() {
  // start up I2C, uses Analog 5 for Clock, Analog 4 for data
  Wire.begin(); // nothing in () because we are the master
/*  Need this stuff now??  Try with & without, Wire.h & Wire.begin might do it for you:

  // define stuff to use for ShiftOut
  // SCL, SDA, BLINK

  //set pins to output so you can control the shift register
  pinMode(Blink, INPUT); // Blink
  pinMode(clockPin, OUTPUT); // SCL
  pinMode(dataPin, OUTPUT);  // SDA
*/

  //  Send config register address
 
  Wire.beginTransmission(address);
  Wire.send(COMMAND_ADDRESS);
  Wire.send(CONFIG_ADDRESS);

  //  Connect to device and the byte
  Wire.send(0x01);  //  low byte

  Wire.endTransmission();


Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up