Arduino control Eeprom by IIC method of using device address in Arduino
參考:
1.https://www.arduino.cc/
2.https://www.arduino.cc/reference/en/
3.https://www.arduino.cc/en/Reference/Wire
4.https://www.arduino.cc/en/Reference/WireRead
5.https://www.arduino.cc/en/Reference/WireWrite
6.https://github.com/settings/installations
?
寫入方法:
void??writeway(int address , int val)
{
? Wire.beginTransmission(0x50); // transmit to device #44 (0x2c)??? // eeprom device address 0x50
?????????????????????????????? // device address is specified in datasheet
?Wire.write(address);
? Wire.write(val); ? ? ? ? ? ? // sends value byte ?
? Wire.endTransmission(); ? ? // stop transmitting
? val++; ? ? ? ?// increment value
? if(val == 64) // if reached 64th position (max)
? {
? ? val = 0; ? ?// start over from lowest value
? }
? delay(5);
}
?
讀取方法:
?
int readway (int address)
{
?Wire.beginTransmission(0x50); // transmit to device #44 (0x2c)??? // eeprom device address 0x50 ?????????????????????????????? // device address is specified in datasheet
?Wire.write(address);???????? // sends value byte ?
?Wire.endTransmission(); ? ? // stop transmitting
? Wire.requestFrom(2, 6); ? ?// request 6 bytes from slave device #2
? while(Wire.available()) ? ?// slave may send less than requested
? {
? //? char c = Wire.read(); ? ?// receive a byte as character
?// ? Serial.print(c); ? ? ? ? // print the character
? }
return Wire.read();
}
?
轉載于:https://www.cnblogs.com/MCSFX/p/10830824.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的Arduino control Eeprom by IIC method of using device address in Arduino的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: shell脚本基本命令1
- 下一篇: Java IO流之字符缓冲流