Skip to content

Instantly share code, notes, and snippets.

@treastrain
Created October 13, 2020 05:34
Show Gist options
  • Save treastrain/002e6156e1bc3415efc2bbcea6db0404 to your computer and use it in GitHub Desktop.
Save treastrain/002e6156e1bc3415efc2bbcea6db0404 to your computer and use it in GitHub Desktop.
Raspberry Pi 4 Model B (ARM 64) + Swift 5.3 で Lチカ
import Foundation
import SwiftyGPIO
print("Hello, happy world!")
let gpios = SwiftyGPIO.GPIOs(for: .RaspberryPi4)
let port_white = gpios[.P24]!
let port_red = gpios[.P22]!
let port_yellow = gpios[.P23]!
let port_green = gpios[.P27]!
let ports = [
port_white,
port_yellow,
port_red,
port_green,
]
for port in ports {
port.direction = .OUT
}
while true {
ports.forEach {
$0.value = 1
}
usleep(500000)
ports.forEach {
$0.value = 0
}
usleep(500000)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment