Skip to content

Instantly share code, notes, and snippets.

@honeniq
Created December 4, 2016 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save honeniq/708b46ad3577c4fd2fb3786067dff3c5 to your computer and use it in GitHub Desktop.
Save honeniq/708b46ad3577c4fd2fb3786067dff3c5 to your computer and use it in GitHub Desktop.
I2C device address scannner for GR-CITRUS.
#!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