Created
December 4, 2016 06:56
-
-
Save honeniq/708b46ad3577c4fd2fb3786067dff3c5 to your computer and use it in GitHub Desktop.
I2C device address scannner for GR-CITRUS.
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
#!mruby | |
@Usb = Serial.new(0, 115200) | |
@Dev = I2c.new(1) # SDA=>pin0, SCL=>pin1 | |
@Address = 0x00 # Register address to read. | |
@Usb.println("I2C Scanner") | |
(1..127).each do |i| | |
r = @Dev.read(i, @Address) | |
@Usb.println(i.to_s(16) + ' ' + r.to_s(16)) if r != 255 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment