#include <Wire.h>
#define address 0x50
char va="as";
int val = 100;
byte data;
double lati1 =32.45678;
String lati = String(lati1);
String myString = "Hello World";
unsigned int len = myString.length() + 1;
void setup()
{
Wire.begin();
Serial.begin(9600);
delay(1000);
byte buff[len];
//WRITE!!!!*******************************
Wire.beginTransmission(address);
Wire.write(0x00); //First Word Address
Wire.write(0x00); //Second Word Address
myString.getBytes(buff, len);
for (int i = 0; i < len; i++)
{ Wire.write(buff[i]); //Write an 'A'
Serial.println(buff[i]);
}
delay(10);
Wire.endTransmission();
delay(10);
//READ!!!!*********************************
Wire.beginTransmission(address);
Wire.write(0x00); //First Word Address
Wire.write(0x00); //Second Word Address
Wire.endTransmission();
delay(10);
Wire.requestFrom(address, 1);
delay(10);
data = Wire.read();
Serial.write(data); //Read the data and print to Serial port
Serial.println();
delay(10);
}
void loop()
{
}
No comments:
Post a Comment