Try this:
Dim bc As ByteConverter
Dim msb As Int = Bit.ShiftRight(eeaddress, 8)
Dim lsb As Int = Bit.And(eeaddress, 0xff)
Dim data() As Byte = bc.IntsToBytes(Array As Int(msb, lsb))
wire.WriteTo(address, data)
hi
thanks for your reply
i change my code to this code , but not any data to log:
Dim bc As ByteConverter
Private wire As WireMaster
Dim eeprom_Adress As Int = 0x50
Dim Memory_Adress As UInt =1
Dim msb As Int = Bit.ShiftRight(Memory_Adress, 8)
Dim lsb As Int = Bit.And(Memory_Adress, 0xff)
Dim data() As Byte = bc.IntsToBytes(Array As Int(msb, lsb))
wire.WriteTo(eeprom_Adress, data)
Dim data1() As Byte="A"
wire.WriteTo(eeprom_Adress, data1)
Delay(500)
Dim msb As Int = Bit.ShiftRight(Memory_Adress, 8)
Dim lsb As Int = Bit.And(Memory_Adress, 0xff)
Dim data() As Byte = bc.IntsToBytes(Array As Int(msb, lsb))
wire.WriteTo(eeprom_Adress, data)
Dim b() As Byte = wire.RequestFrom(eeprom_Adress, 1)
Log("data on address 1 : ",b)
in arduino IDE , this code is work fine for me (return 65 ) :
#include <Wire.h>
#define eeprom 0x50 //defines the base address of the EEPROM
void setup(void){
Wire.begin();
Serial.begin(9600);
Serial.println("write");
writeEEPROM(eeprom, 1, 'A');
delay(5);
Serial.print(readEEPROM(eeprom, 1), DEC);
}
void loop(){}
void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte data ) {
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 8)); //writes the MSB
Wire.write((int)(eeaddress & 0xFF)); //writes the LSB
Wire.write(data);
Wire.endTransmission();
}
byte readEEPROM(int deviceaddress, unsigned int eeaddress ) {
byte rdata = 0xFF;
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 8)); //writes the MSB
Wire.write((int)(eeaddress & 0xFF)); //writes the LSB
Wire.endTransmission();
Wire.requestFrom(deviceaddress,1);
if (Wire.available())
rdata = Wire.read();
return rdata;
}