João Costa @JD557@blog.joaocosta.eu Follow

Portuguese software engineer at Kevel.

My instance is running on a small server so please #nobot

Web

https://www.joaocosta.eu/

GitHub

https://github.com/JD557

Twitter

https://twitter.com/JD557

Itch.io

https://jd557.itch.io

  • Notes
  • Articles 6
  • Followers 46
  • Following 59
João Costa's avatar
João Costa
@JD557@blog.joaocosta.eu

Got some Scala bindings for WiringPi thanks to SN-Bindgen (plus some manual adjustments)

https://gist.github.com/JD557/c81ad69f7506c70a5c26e9ddec24db27

Took me quite some time to get things to work... but at least I got a blinking LED today 😅 :

import wiringpi.all.*

println("Starting")
wiringPiSetup()

val led = 25

pinMode(led, OUTPUT)

while(true) {
  println("ON")
  digitalWrite(led, HIGH)
  Thread.sleep(1000)
  println("OFF")
  digitalWrite(led, LOW)
  Thread.sleep(1000)
}

I do need to figure out how to cross compile before I try something more complex... Scala Native compilation on a Raspberry Pi 3 B is SLOW! 😬

WiringPi bindings for Scala Gist
GIF
  • permalink
  • interact from your instance
  • 21 days ago
  • 1 like
  • 1 reply
Likes
@kubukoz@mstdn.party
João Costa's avatar
João Costa
@JD557@blog.joaocosta.eu

in reply to this object

One stupid reason why this took so long. Somehow when connecting the LED, not only did I read the pinout wrong (transposed), but I also had a off-by-one pin connection.

This connected the ground to another ground (the Raspberry Pi has a bunch of those) but the output pin was connected to the 5V output.

And dumb me, instead of figuring out the obvious, assumed that "if the LED is on, the circuit is fine" and spent a bunch of time trying to figure out why the pins were defaulting to HIGH and why I couldn't set them to LOW 😂

Raspberry Pi pinout pointing out the pins I wanted to connect (9 and 37) and the ones I connected (4 and 34)
  • permalink
  • 20 days ago
Powered by microblog.pub 2.0.0+dev (source code) and the ActivityPub protocol. Admin.