more G-Labs products

Author Topic: RaspberrySharp from Ruby and Python  (Read 2488 times)

April 03, 2014, 05:40:50 PM
Read 2488 times

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
To program GPIO/SPI/I2C from HG also Python and Ruby can be used.
Here some examples:

Python
Code: [Select]
# Add reference to RaspberrySharp libraries
import clr
clr.AddReference("Raspberry.IO.GeneralPurpose")
from Raspberry.IO.GeneralPurpose import ConnectorPin
from Raspberry.IO.GeneralPurpose import OutputPinConfiguration
from Raspberry.IO.GeneralPurpose import PinMapping
from Raspberry.IO.GeneralPurpose import GpioConnection

# Create a connection to led connected to P1Pin15
led1 = OutputPinConfiguration(PinMapping.ToProcessor(ConnectorPin.P1Pin15))
connection = GpioConnection(led1)

# Make the led blink
connection.Blink(led1)

Ruby
Code: [Select]
# Add reference to RaspberrySharp libraries
require 'Raspberry.IO.GeneralPurpose.dll'
connector_pin = Raspberry::IO::GeneralPurpose::ConnectorPin
pin_mapping = Raspberry::IO::GeneralPurpose::PinMapping
output_pin_configuration = Raspberry::IO::GeneralPurpose::OutputPinConfiguration
gpio_connection = Raspberry::IO::GeneralPurpose::GpioConnection

# Create a connection to led connected to P1Pin15
pin15 = pin_mapping.ToProcessor(connector_pin.P1Pin15)
led1 = output_pin_configuration.new(pin15)
connection = gpio_connection.new(led1)

# Make the led blink
connection.Blink(led1)

For further documentation about RaspberrySharp-IO library see https://github.com/raspberry-sharp/raspberry-sharp-io/wiki .

g.
« Last Edit: April 05, 2014, 03:59:33 AM by Gene »


There are no comments for this topic. Do you want to be the first?