LPCXpresso55S69_MRuby/README.md

36 lines
934 B
Markdown
Raw Permalink Normal View History

# WIP
## Implemented features:
```ruby
# Initialization: Takes a hash with configuration.
led_red = Machine::GPIO.new(38, {mode: Machine::GPIO::OUTPUT_OD, init: Machine::GPIO::ON})
led_blue = Machine::GPIO.new(36, {mode: Machine::GPIO::OUTPUT_OD, init: Machine::GPIO::ON})
led_green = Machine::GPIO.new(39, {mode: Machine::GPIO::OUTPUT_OD, init: Machine::GPIO::ON})
```
```ruby
led_red.value # Get LED pin input value
led_red.value = Machine::GPIO::OFF # Turn on the LED (Level is reversed)
led_red.off # Same as above
led_red.on # Turn off the LED (Level is reversed)
led_red.toggle # Toggle output
```
```ruby
ana_bg = Machine::ADC.new(52) # BandGap
ana_bg.value
```
```ruby
1000.times do |_|
puts "[#{Time.now}] BandGap voltage: #{'%.2f' % (ana_bg.value.to_f / 1000.0)}mV"
led_red.toggle
usleep(100 * 1000)
end
2023-04-12 16:54:45 +00:00
```
```ruby
pwm_blue = Machine::PWM.new(18)
pwm_blue.duty = 65535
pwm_blue.duty # Get duty cycle
```