Go Down

Topic: HaikuVM - A Java VM for ARDUINO and other micros. (Read 925 times) previous topic - next topic

genom2

The Arduino IDE is build with JAVA!
Processing is based on JAVA!
But what about programming an Arduino in JAVA?

I'm thinking about something like this JAVA program to let the Arduino LED blink:
Code: [Select]

package processing.examples._01_Basics;

import static processing.hardware.arduino.cores.arduino.Arduino.*;

/**
* Haikufy like this:
*   cd C:\arduino-1.0.5\libraries
*   C:\haikuVM\bin\haiku -v --Config arduinoIDE C:\haikuVM\examples\src\main\java\processing\examples\_01_Basics\Blink.java
* Then use your Arduino IDE to upload the generated sketch.
*
*/
public class Blink {
    // The status LED of the ARDUINO will blink.

    static byte ledPin = 13;            // LED connected to digital pin 13

    public static void setup() {
        pinMode(ledPin, OUTPUT);        // sets the digital pin as output
    }

    public static void loop()           // run over and over again
    {
        digitalWrite(ledPin, HIGH);     // sets the LED on
        delay(1000);                    // waits for a second
        digitalWrite(ledPin, LOW);      // sets the LED off
        delay(1000);                    // waits for a second
    }
}

This program should be compiled and flashed, to finally run on an Arduino.

Well, this can be done with HaikuVM (see http://haiku-vm.sourceforge.net/)!
It's new, it's free and it's open source. And because its JAVA, you have Threads, a garbage collector and other nice JAVA stuff for free.

HaikuVM integrates with the Arduino IDE. Every time when you haikufy a JAVA program (like e.g. 'Blink.java' see above) it creates or renews an arduino library called HaikuVM in your arduino libraries directory. In addition, it generates an example sketch called HaikuVM for this library. With your Arduino IDE navigate to this sketch, load and upload it. The LED will blink.

Try other examples given in 'C:\haikuVM\examples\src\main\java\processing\examples\' and have fun!

Go Up