Last active
March 9, 2016 10:37
-
-
Save yuma-m/395bd385ef37cf58087c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SRF02のアドレスを変更 | |
#include <Wire.h> | |
byte original_address = 224; // 変更前のアドレス: 0xE0 | |
byte new_address = 226; // 変更後のアドレス: 0xE2 | |
void setup() { | |
Wire.begin(); | |
Serial.begin(9600); | |
Serial.println("Change address begin ..."); | |
byte original_i2c_address = original_address >> 1; | |
Wire.beginTransmission(original_i2c_address); | |
Wire.write(0x00); | |
Wire.write(0xA0); | |
Wire.endTransmission(); | |
Wire.beginTransmission(original_i2c_address); | |
Wire.write(0x00); | |
Wire.write(0xAA); | |
Wire.endTransmission(); | |
Wire.beginTransmission(original_i2c_address); | |
Wire.write(0x00); | |
Wire.write(0xA5); | |
Wire.endTransmission(); | |
Wire.beginTransmission(original_i2c_address); | |
Wire.write(0x00); | |
Wire.write(new_address); | |
Wire.endTransmission(); | |
Serial.println("Change address finish!"); | |
} | |
void loop() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment