Skip to content

This Gem is a collection of ruby classes made to easily control common components on the Raspberry Pi.

License

Notifications You must be signed in to change notification settings

kochka/ruby_rpi_components

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raspberry Pi Components

This Gem is a collection of ruby classes made to easily control common components on the Raspberry Pi. Many examples on how to use them are available in the example directory.

Currently available components are :

  • Led & RGB Led
  • LCD with or without I2C interface
  • Push button
  • Rotary encoder
  • Shift register
  • BME280 & BMP280 (temperature, humidity and atmospheric pressure sensor)
  • HY-SRF05 & HY-SRF04 (Ultrasonic sensor)

Some quick examples

Before using components, you should do :

RpiComponents::setup

Make a Led blink or plusate asynchronously :

led = RpiComponents::Led.new(11)
led.blink :fast
sleep 5 # Some processing there
led.pulse :slow
sleep 5 # Some processing there
led.off

Display a message on a Lcd using I2C bus :

lcd = RpiComponents::LcdI2c.new(0x3f)
lcd.message 'Hello'
lcd.message 'World', 2

Display data from a BME280 sensor :

bme280 = RpiComponents::Bme280.new(0x76)
puts "Temperature: #{'%.2f' % bme280.temp} °C"
puts "Humidity: #{'%.2f' % bme280.humidity} %"
puts "Temperature: #{'%.2f' % bme280.pressure} hPa"

Display distance from an object using a HY-SRF05 ultrasonic distance sensor :

distance_sensor = RpiComponents::Hysrf05.new(29, 31)
puts "Distance: #{'%.2f' % distance_sensor.accurate_measure} cm"

Dependencies

About

This Gem is a collection of ruby classes made to easily control common components on the Raspberry Pi.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages