Skip to content

Instantly share code, notes, and snippets.

@fbrosser
Created October 3, 2011 19:07
Show Gist options
  • Save fbrosser/1259939 to your computer and use it in GitHub Desktop.
Save fbrosser/1259939 to your computer and use it in GitHub Desktop.
First attempt at Ruby for Arduino
# @auth Fredrik Brosser
# @time 2011-10-03 20:17
#
# First attempt at ruby for Arduino
#
class RduinoSketch < ArduinoSketch
# Pin definitions
output_pin 7, :as => :led
input_pin 7, :as => :btn, :device => :button
@s_adr = "FFFF, unsigned short"
@hello_string = "Roger Roger"
# Setup routine runs once at system startup
def setup
# Enable serial com
serial_begin
end
# Loop routine runs continuously
def loop
# Blink LED
blink led, 500
# If button pressed
if btn.read_input
# Print to serial terminal
sayHello(@hello_string)
# Sleep
delay 1000
end
# sayHello routine prints argument string
# to serial terminal
def sayHello(str)
serial_println str
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment