i2c with the Leostick

A shrunk down Leonardo-compatible board, thumb drive sized with native USB support. [Product info]
pvyParts
Posts:1
Joined:Tue May 15, 2012 1:53 am
i2c with the Leostick

Post by pvyParts » Tue Jun 12, 2012 12:10 pm

****

after writing this i remmebered that the leo has a different processor as such has different pinouts :)

changed to
LEO > UNO
+5v > +5v
GND > GND
D2 > A4
D3 > A5

and it worked straight away :)

******
Hey guys, been lurking here for a while :D but not needed to post as yet.

i have been trying to make the LeoStick run as a slave i2c device to no avail

i had a project that is working on 2 UNO's but want to use the leos cause they are smaller and have a RGB LED ( cause i can )

i was having trouble making it work so i loaded up the 2wire example
and it still doesn't work i.

is there anything special with these devices to make it work?
i have gone right back to this to make sure it was not something stupid...

Connections like so.
LEO > UNO
+5v > +5v
GND > GND
A4 > A4
A5 > A5

UNO is connected to USB for com monitoring + power

Master device code (Arduino Uno)

Code: Select all

#include <Wire.h>

void setup()
{
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
}

void loop()
{
  Wire.requestFrom(2, 6);    // request 6 bytes from slave device #2
  Serial.print("start ");         // print the character

  while(Wire.available())    // slave may send less than requested
  { 
    char c = Wire.read(); // receive a byte as character
    Serial.println(c);         // print the character
  }

  delay(500);
}
slave device (Leo Stick)

Code: Select all

#include <Wire.h>

void setup()
{
  Wire.begin(2);                // join i2c bus with address #2
  Wire.onRequest(requestEvent); // register event
}

void loop()
{
  delay(100);
}

// function that executes whenever data is requested by master
// this function is registered as an event, see setup()
void requestEvent()
{
  Wire.write("hello "); // respond with message of 6 bytes
                       // as expected by master
}
so nothing special.
hopefullly something simple :D

Thanks in advance.

Post Reply