http://chiselapp.com/user/schelte/repository/piio%|%piio%|% by [Schelte Bron] is a library for accessing a couple of the I/O possibilities of the [Raspberry Pi]. The library supports both http://en.wikipedia.org/wiki/GPIO%|%gpio%|% and http://en.wikipedia.org/wiki/I2c%|%i2c%|%. [dzach] 2016-9-5 Looks interesting. I have compiled the library for a Raspberry Pi 3, but have not been able to produce positive results. What is the naming convention for the pins? There seem to exist a number of them. E.g. if I want to use physical pin 11 (pin number on the connector) as an output, should I say: piio function 11 output piio output 11 1 in order to turn on pin#11 ? Could you please post a simple "Hello world" example (e.g. blink)? Thanks! [crshults] 2016-10-01 Take a look at the note on this page: http://elinux.org/RPi_GPIO_Code_Samples "Note: For Raspberry Pi 2, change BCM2708_PERI_BASE to 0x3F000000 for the code to work." [dzach] Thanks for the link! [sbron] 2017-02-05 The library uses the GPIO pin numbering. That way you can also address pins that are not on P1, like P5. It also resolves issues with pins that have changed between hardware revisions, like P1 pin 3 and 5. The image below shows the mapping. So P1 pin 11 is GPIO 17. [http://raspi.tv/wp-content/uploads/2014/07/Raspberry-Pi-GPIO-pinouts-1024x703.png] (Image by http://raspi.tv/2014/rpi-gpio-quick-reference-updated-for-raspberry-pi-b%|%RasPi.TV%|%) ------ A very simple blink example might look like this (LED + resistor connected between P1 pin 39 and 40): ====== package require piio piio function 21 output proc blink {{state 1}} { piio output 21 $state after 500 [list blink [expr {!$state}]] } blink vwait forever ====== ------ [crshults] 2017-02-02 In gpio.c, change "/dev/mem" to "/dev/gpiomem" and you can use the library as a non super user. Your user just has to be in the gpio group. [sbron] 2017-02-05 The latest version will use /dev/gpiomem if available, and fall back to /dev/mem if not. [vh] 2017-03-30 Thanks to a morse code script elsewhere in this wiki, here is a morse code blinky example. ====== # A tcl script to flash morse code on an LED on a Raspberry Pi 3 B+ # 30 March 2017 # Wiring setup: 5mm diameter LED in series with a 330 ohm resistor wired from gpio16 (pin36) to ground (pin34) # morse-code code from: http://wiki.tcl.tk/3371 # turn "on" a gpio pin which has previously been set to output mode proc flash {gpio n} { piio output $gpio 1 pause $n piio output $gpio 0 pause 1 } # A simple pause while running the event loop, in terms of basic time units proc pause n { global t after [expr {$t * $n}] set ok 1 vwait ok } set MORSE_CODE { "!" "---." "\"" ".-..-." "$" "...-..-" "'" ".----." "(" "-.--." ")" "-.--.-" "+" ".-.-." "," "--..--" "-" "-....-" "." ".-.-.-" "/" "-..-." ":" "---..." ";" "-.-.-." "=" "-...-" "?" "..--.." "@" ".--.-." "[" "-.--." "]" "-.--.-" "_" "..--.-" "0" "-----" "1" ".----" "2" "..---" "3" "...--" "4" "....-" "5" "....." "6" "-...." "7" "--..." "8" "---.." "9" "----." "A" ".-" "B" "-..." "C" "-.-." "D" "-.." "E" "." "F" "..-." "G" "--." "H" "...." "I" ".." "J" ".---" "K" "-.-" "L" ".-.." "M" "--" "N" "-." "O" "---" "P" ".--." "Q" "--.-" "R" ".-." "S" "..." "T" "-" "U" "..-" "V" "...-" "W" ".--" "X" "-..-" "Y" "-.--" "Z" "--.." } # The code to translate text to morse code and play it proc morse {gpio str wpm} { global t MORSE_CODE set t [expr {1200 / $wpm}] # Backslash and space are special cases in various ways set map {"\\" {} " " {[pause 4]}} # Append each item in the code to the map, with an inter-letter pause after foreach {from to} $MORSE_CODE {lappend map $from "$to\[pause 3\]"} # Convert to dots and dashes set s [string map $map [string toupper $str]] puts "Morse string: $s" # Play the dots and dashes by substituting commands for them (dash displays for 4 times longer than a dot) # Pauses between flashes has relative length 1 (same length as a dot flash), pause at end of letter = 4 ,pause between words=8 puts "commands to be executed:[string map { "." "[flash $gpio 1]" "-" "[flash $gpio 4]" } $s]" subst [string map { "." "[flash $gpio 1]" "-" "[flash $gpio 4]" } $s] return } # This script requires the piio package (http://chiselapp.com/user/schelte/repository/piio/wiki?name=piio) # You will have to download and follow the instructions to compile before using this package package require piio # prepare the gpio for output set gpio 16 piio function $gpio output set words_per_minute 5 # Translate a text message to morse code flashes morse $gpio "Hello World" $words_per_minute ====== ------ <>Hardware