
Enables interaction with Johnny-Five library using JavaScript wrappers, facilitating Arduino component control such as LED, Servo, and Button, for hobby projects with Node.js compatibility.
For a hobby project with my Arduino, i tried to use Johnny-Five. Because i wanted to use Kotlin, i created some KotlinJs wrapper.
The wrappers are not 100% complete, because i can't test all components. These are some components that i tried:
When you have ideas for improvements, please write a GitHub issue.
Prepare your Board
You need to install StandardFirmataPlus firmware to your board.
Check the johnny-five documentation for more information
Here is the instruction for Arduino:
Create a new KotlinJS Project with NodeJs
kotlin {
js(IR) {
binaries.executable()
nodejs {}
}
sourceSets {
val jsMain by getting {
dependencies {
implementation("de.jensklingenberg.kotlin-wrappers:johnny-five:0.8.3")
}
}
}
}
}You also need to add this to your build.gradle.kts, otherwise you will get compile errors: "Error: Could not locate the bindings file"
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin> {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().ignoreScripts = false
}fun main() {
val LED_BUILTIN = 13
val board = Board()
board.onReady {
println("READY")
val led = Led(LED_BUILTIN)
led.blink()
onExit {
println("EXIT")
led.off()
}
}
}./gradlew buildUse Node to run the compiled code:
node ./build/compileSync/js/main/productionExecutable/kotlin/demoYou should see something like this in your terminal:
For a hobby project with my Arduino, i tried to use Johnny-Five. Because i wanted to use Kotlin, i created some KotlinJs wrapper.
The wrappers are not 100% complete, because i can't test all components. These are some components that i tried:
When you have ideas for improvements, please write a GitHub issue.
Prepare your Board
You need to install StandardFirmataPlus firmware to your board.
Check the johnny-five documentation for more information
Here is the instruction for Arduino:
Create a new KotlinJS Project with NodeJs
kotlin {
js(IR) {
binaries.executable()
nodejs {}
}
sourceSets {
val jsMain by getting {
dependencies {
implementation("de.jensklingenberg.kotlin-wrappers:johnny-five:0.8.3")
}
}
}
}
}You also need to add this to your build.gradle.kts, otherwise you will get compile errors: "Error: Could not locate the bindings file"
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin> {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().ignoreScripts = false
}fun main() {
val LED_BUILTIN = 13
val board = Board()
board.onReady {
println("READY")
val led = Led(LED_BUILTIN)
led.blink()
onExit {
println("EXIT")
led.off()
}
}
}./gradlew buildUse Node to run the compiled code:
node ./build/compileSync/js/main/productionExecutable/kotlin/demoYou should see something like this in your terminal: