BreadBoard | |
A led x1 | |
330 ohm resistor x1 | |
Male-Female jumper wires |
$ sudo npm install rpi-gpio
var gpio = require('rpi-gpio'); gpio.setup(3, gpio.DIR_OUT, write); function write() { gpio.write(3, true, function(err) { if (err) throw err; console.log('Written to pin'); }); }
and you should notice the LED on.$ sudo node ledOn.js
take note of the server address e.g. SystemServer running at http://192.168.1.???:8088$ sudo node n8.snapshot.js
What you'll see is a cycle of blinking 50 times with an interval of 50 ms. Congratulations!!| gpio pin delay count max off on | gpio := RPI gpio. pin := 3. delay := 50. count := 0. max := 50. off := [ [gpio write: pin value: 0 with: on] valueDeferred: delay ]. on := [ count > max ifTrue: [ gpio destroy. self print: 'Close pins...'. ] ifFalse: [ [ gpio write: pin value: 1 with: off. count := count + 1. ] valueDeferred: delay ] ]. gpio setup: pin direction: gpio dirOut with: on.