Created
November 6, 2012 23:44
-
-
Save edy555/4028517 to your computer and use it in GitHub Desktop.
LED blink with FT232RL bitbang mode and ruby
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
require 'rubygems' | |
require 'ftdi' | |
ctx = Ftdi::Context.new | |
begin | |
ctx.usb_open(0x0403, 0x6001) | |
begin | |
ctx.set_bitmode(0xff, :bitbang) | |
100.times do | |
ctx.write_data [0xff] | |
sleep 0.5 | |
ctx.write_data [0x00] | |
sleep 0.5 | |
end | |
ensure | |
ctx.set_bitmode(0xff, :reset) | |
ctx.usb_close | |
end | |
rescue Ftdi::Error => e | |
$stderr.puts e.to_s | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setup
$ brew install libftdi
$ gem install libftdi-ruby
Before running
$ sudo kextunload /System/Library/Extensions/FTDIUSBSerialDriver.kext
Run
$ ruby blink.rb