OK
I have spent hours on this, and for whatever reason, I am incapable of getting my arduino uno to talk to my TI launchpad, which would tell me that it is compatible with I2C but at this point I don't know. Is there some specific jumper combination required to get the launchpad (the large one with far more pins) to co-operate? I am pretty new to this and could really use some help. I plan on using a arduino remote thing to control a MSP430 which has enough GPIO to run a sainsmart 16 relay board. This is going to be over roughly 30 feet of cable, so if anyone has a better solution for my project that would be greatly appreciated. I might end up buying a couple arduinos if this doesn't work but I would rather not. Code as is follows.
Master:
#include <Wire.h>
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600);
}
void loop()
{
Wire.beginTransmission(5);
Wire.write('H');
delay(500);
Wire.write('L');
Wire.endTransmission();
Serial.println("trying");
delay(500);
}
Slave:
#include <Wire.h>
void setup()
{
Wire.begin(5);
Wire.onReceive(receiveEvent);
pinMode(P1_0, OUTPUT);
digitalWrite(P1_0, LOW);
}
void loop()
{
}
void receiveEvent(int howmany){
while(Wire.available()){
char c = Wire.read();
if(c=='H'){
digitalWrite(P1_0, HIGH);
}
else if(c=='L'){
digitalWrite(P1_0, LOW);
}
}
}
TheCupcakeisalie:
OK
I have spent hours on this, and for whatever reason, I am incapable of getting my arduino uno to talk to my TI launchpad, which would tell me that it is compatible with I2C but at this point I don't know. Is there some specific jumper combination required to get the launchpad (the large one with far more pins) to co-operate? I am pretty new to this and could really use some help. I plan on using a arduino remote thing to control a MSP430 which has enough GPIO to run a sainsmart 16 relay board. This is going to be over roughly 30 feet of cable, so if anyone has a better solution for my project that would be greatly appreciated. I might end up buying a couple arduinos if this doesn't work but I would rather not. Code as is follows.
Master:
#include <Wire.h>
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600);
}
void loop()
{
Wire.beginTransmission(5);
Wire.write('H');
delay(500);
Wire.write('L');
Wire.endTransmission();
Serial.println("trying");
delay(500);
}
Your master code is faulty. The Wire library works on blocks of data. Nothing is actually send out the I2C bus until the Wire.endTransmission() is called. the beginTransmission(), write() just build a block of data that is send during the call to endTransmission().
to achieve what you wanted try:
void loop()
{
Wire.beginTransmission(5);
Wire.write('H');
Wire.endtransmission();
Serial.println(" Trying High ");
delay(500);
Wire.beginTransmission(5);
Wire.write('L');
Wire.endTransmission();
Serial.println("trying Low");
delay(500);
}
Chuck.