Skip to content

Commit

Permalink
set direction before writing
Browse files Browse the repository at this point in the history
  • Loading branch information
ranjib committed Dec 24, 2024
1 parent 285e5de commit 073965d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hal/digital_pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func (p *digitalPin) Read() (int, error) {
}

func (p *digitalPin) Write(value int) error {
if err := p.SetDirection(true); err != nil {
return err
}
out, err := gpiocdev.RequestLine(rpiGpioChip, p.pin, gpiocdev.AsOutput(value, 0))
if err != nil {
defer out.Close()
Expand Down

0 comments on commit 073965d

Please sign in to comment.