From b72638de53bd48a41f2b1b7ceb01b8fa75ae4ebd Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Wed, 27 Nov 2013 14:15:40 -0800 Subject: [PATCH] Literate CoffeeScript version of raspi_blink example --- examples/raspi_blink/raspi_blink.litcoffee | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/raspi_blink/raspi_blink.litcoffee diff --git a/examples/raspi_blink/raspi_blink.litcoffee b/examples/raspi_blink/raspi_blink.litcoffee new file mode 100644 index 0000000..f444abb --- /dev/null +++ b/examples/raspi_blink/raspi_blink.litcoffee @@ -0,0 +1,30 @@ +# Raspberry Pi - Blink + +For this example, we're going to connect to a Raspberry Pi and make the LED on +pin 11 blink on a 1-second interval. Before we start, make sure you've got the +`cylon-raspi` module installed. + +First, let's make sure to load the Cylon module: + + Cylon = require '../..' + +After we've got that done, we can start defining our robot: + + Cylon.robot + +We'll have a singular connection to a Raspberry Pi, using the +previously-mentioned `cylon-raspi` module. We'll also have one device, the LED +on pin 11. + + connection: { name: 'raspi', adaptor: 'raspi' } + device: { name: 'led', driver: 'led', pin: 11 } + +Those are all the components for our robot, so next we'll define the work. All +we're going to do for this example is tell the LED to toggle every second. + + work: (my) -> + every 1.second(), -> my.led.toggle() + +And with all those pieces in place, we can tell the robot to get started: + + .start()