Skip to content

Instantly share code, notes, and snippets.

@jesselang
Created August 22, 2019 14:48
Show Gist options
  • Save jesselang/acae8cebfafba51bef3810089541112d to your computer and use it in GitHub Desktop.
Save jesselang/acae8cebfafba51bef3810089541112d to your computer and use it in GitHub Desktop.
Playing around with https://play.tinygo.org
package main
import (
"machine"
"time"
)
const pattern = "... ––– ..."
const interval = time.Second / 3
func space() {
led.Low()
time.Sleep(interval)
}
func dot() {
led.High()
time.Sleep(interval)
led.Low()
time.Sleep(interval)
}
func dash() {
led.High()
time.Sleep(interval * 3)
led.Low()
time.Sleep(interval)
}
var (
// Patrick approves
signals = map[rune]func(){
' ': space,
'.': dot,
'-': dash,
'–': dash,
}
)
const led = machine.LED
func main() {
println("Hello, TinyGo")
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
for _, v := range pattern {
println(string(v))
signals[v]()
}
led.Low()
time.Sleep(interval)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment