You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Swift version 5.10.1 (swift-5.10.1-RELEASE)
Target: aarch64-unknown-linux-gnu
Installed from swiftARM as binary
Description
A KY-038 sound sensor's digital output (triggered when a threshold is reached) is connected to GPIO pin 23. The board can run with 3.3-5V supply. I am running it at 5V without pull-up resistors.
I have cobbled this code from several sources. It executes without error but none of the closures are triggered.
import Foundation
import SwiftyGPIO
letgpios=SwiftyGPIO.GPIOs(for:.RaspberryPi3)vargp=gpios[.P23]!
gp.direction =.IN
gp.bounceTime = 0.5
gp.onRaising{
gpio inprint("Transition to 1, current value:"+ String(gpio.value))}
gp.onFalling{
gpio inprint("Transition to 0, current value:"+ String(gpio.value))}
gp.onChange{
gpio in
gpio.clearListeners()print("The value changed, current value:"+ String(gpio.value))}RunLoop.main.run()
If I replace the RunLoop.main.run() with:
while true {print("GPIO.value=\(gp.value)")}
Then I can see the value changing from 0 to 1 appropriately. I have tried changing .pull but this has no effect.
The text was updated successfully, but these errors were encountered:
Board Type
RaspberryPi3 Model B
Operating System
Ubuntu 24.04.1 LTS
Swift Version
Swift version 5.10.1 (swift-5.10.1-RELEASE)
Target: aarch64-unknown-linux-gnu
Installed from swiftARM as binary
Description
A KY-038 sound sensor's digital output (triggered when a threshold is reached) is connected to GPIO pin 23. The board can run with 3.3-5V supply. I am running it at 5V without pull-up resistors.
I have cobbled this code from several sources. It executes without error but none of the closures are triggered.
If I replace the
RunLoop.main.run()
with:Then I can see the value changing from 0 to 1 appropriately. I have tried changing
.pull
but this has no effect.The text was updated successfully, but these errors were encountered: