Madrona RAD input output pin syntax
July 7, 2008
How do we make input and output pin declarations simple and straightforward? The first pass used options to trigger pin behavior. In the following example, setting a min and max sets up a servo, and the latch option sets up a button:
1 class InOutDemo < ArduinoSketch 2 3 input_pin 6, :as => :button_one, :latch => :off 4 output_pin 7, :as => :my_servo, :min => 700, :max => 2200 5
After working through this, the notion of a device option seems like a better choice:
1 class InOutDemo < ArduinoSketch 2 3 input_pin 6, :as => :button_one, :device => :button 4 output_pin 7, :as => :my_servo, :device => :servo 5 output_pin 8, :as => :my_lcd, :device => :sf_lcd 6
Declaring a device will setup default settings for that device. For example, the servo will default to a min and max of 544 and 2400. For LCD screens, the default serial rate and driver is setup.