Created
October 3, 2011 19:07
-
-
Save fbrosser/1259939 to your computer and use it in GitHub Desktop.
First attempt at Ruby for Arduino
This file contains hidden or 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
# @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