Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I program microcontrollers in Kotlin?

Is it possible somehow to program Arduino or ESP8266 microcontrollers on Kotlin? Same question about single-board computers (i.e. Raspberry Pi).

like image 380
Divelix Avatar asked Aug 10 '18 04:08

Divelix


People also ask

Can Kotlin be used as a programming language for microcontroller?

Microcontrollers are still computers. if python can be used in Raspberry. then Kotlin can also be used. First you need compile, JVM (Open source e.g OpenJDK) with that microcontroller toolchain.

Is Kotlin good for Android development?

Kotlin Programming Kotlin is a relatively new programming language developed by JetBrains for modern multiplatform applications. Nowadays, Kotlin is widely used for Android development instead of Java. It is because Kotlin is safe, concise, and fun to read and write.

How do I run Kotlin on my computer?

Assuming Java is installed on your computer, it's pretty easy to run Kotlin. Visit this page to run Java on your computer if you haven't already. You can use any popular Java IDE to run Kotlin. The most popular among them is IntelliJ IDEA (Community Edition).

Is there any way to compile Kotlin code for Arduino?

LLVM now has (since 8.0) an AVR backend, so you can compile Kotlin/Native source code for Arduino. You can check the development of the AVR target here. Thanks for contributing an answer to Stack Overflow!


3 Answers

Yes. Microcontrollers are still computers. if python can be used in Raspberry. then Kotlin can also be used.

First you need compile, JVM(Open source e.g OpenJDK) with that microcontroller toolchain. Then run the image in the microcontroller. Now create a kotlin file, compile it and run it with that JVM. Thats if the microcontroller runs on a kernel e.g linux

Make sure that microcontroller have enough memory.

like image 174
Declan Nnadozie Avatar answered Oct 19 '22 20:10

Declan Nnadozie


Situation was changed with the new player on the scene named Kotlin/native. Due to the support of LLVM, I think it is possible to compile to native from Kotlin to the desired devices.

like image 3
Karel Warchalowsky Avatar answered Oct 19 '22 21:10

Karel Warchalowsky


In this moment - no, kotlin use LLVM compiler. Even if microcontroller supports LLVM code, need adaptation for work with "inside components", like interupts, PWM, DAC, ADC, WatchDog and other stuff, and for any mc it adaptations will be unic.

like image 1
Андрей Кирьянцев Avatar answered Oct 19 '22 21:10

Андрей Кирьянцев