Created
October 13, 2020 05:34
-
-
Save treastrain/002e6156e1bc3415efc2bbcea6db0404 to your computer and use it in GitHub Desktop.
Raspberry Pi 4 Model B (ARM 64) + Swift 5.3 で Lチカ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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