Your first program
The "hello world" of hardware is a blinking light. In Runeweave it takes three nodes and two wires.
┌─────────────┐ ┌─────────────┐ ┌──────────────────┐
│ clock │ │ flip-flop │ │ digital-write │
│ IVAL 0.25 │ TICK ─┤► TGL MEM ├──────►│ SIG PORT D13 │
└─────────────┘ └─────────────┘ └──────────────────┘
sdp/time/clocksends a pulse on TICK every IVAL seconds. Set IVAL to0.25.sdp/logic/flip-flopflips its MEM output between on and off each time its TGL input gets a pulse.sdp/gpio/digital-writedrives the pin in PORT to the value of SIG. Set PORT to the pin your light is on.
Wire TICK to TGL, and MEM to SIG. Every quarter of a second the clock ticks, the flip-flop flips and the light follows: it blinks twice a second.
On disk
Saved, this patch is a short text file, patches/main/patch.rwp. You never have to edit it by hand, but it shows there's no magic: one line per node and one per wire.
{"format":1}
{"kind":"node","id":"clock","type":"sdp/time/clock","at":[0,0],"pins":{"IVAL":{"value":"0.25"}}}
{"kind":"node","id":"flip","type":"sdp/logic/flip-flop","at":[2,1]}
{"kind":"node","id":"led","type":"sdp/gpio/digital-write","at":[4,2],"pins":{"PORT":{"value":"D13"}}}
{"kind":"link","id":"link-0","from":{"node":"clock","pin":"TICK"},"to":{"node":"flip","pin":"TGL"}}
{"kind":"link","id":"link-1","from":{"node":"flip","pin":"MEM"},"to":{"node":"led","pin":"SIG"}}
Try next
- Replace the clock with
sdp/gpio/digital-readon a button pin andsdp/logic/pulse-on-true, so the light toggles each time you press. - Add
sdp/logic/notbetween the flip-flop and the light, and see the blink invert.