Sign in:

How close is the Cubelets API to Arduino?

Home Forums Cubelets Programming Forum How close is the Cubelets API to Arduino?

This topic contains 3 replies, has 2 voices, and was last updated by  Gian Pablo Villamil 8 months, 1 week ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #5807

    Gian Pablo Villamil
    Participant

    In programming Cubelets, I’ve noticed a lot of similarity to the Arduino libraries/API, but there seem to be some differences.

    In particular the setup() and loop() constructs are similar, but it seems like some of the Arduino functions are missing. I’m not surprised to see the I/O missing, since Cubelets basically need to manipulate only the block_value. However, some of the other stuff might be helpful, such as the millis() timer and other things.

    Is there a comprehensive mapping of how the Arduino vs Cubelets APIs compare?

    #5808

    Eric Lundby
    Keymaster

    There are definitely similarities between the Cubelets and Arduino structure and API as you’ve pointed out. However, Arduino and Cubelets use different micro-controllers, compilers and bootloaders.

    I do like the idea of adding in millis() to the API. If you have other suggestions for additions/modifications to the API please let us know.

    We don’t currently have official documentation comparing the Arduino vs Cubelets APIs at this time.
    But to give a quick comparison, if you look at the Arduino Reference:

    Cubelets API supports:

    • All of the Structure column
    • All of the Variables column with the exception of HIGH | LOW, INPUT | OUTPUT | INPUT_PULLUP, and LED_BUILTIN.
    • From the Functions column, you can get the Math and Trigonometry sections by including math.h: #include <math.h>
    #5809

    Gian Pablo Villamil
    Participant

    Great, that is super helpful!

    My main interest in millis() is in being able to write non-blocking code that includes delays, eg. slowly blink or pulse an LED but still monitor changes in input and react immediately.

    Another use is to be able to easily measure changes in input over time, and use that to drive behavior. For example, a distance sensor might react differently if it is approached slowly vs quickly.

    Possibly the interrupt handling stuff might be useful too, for the same reason.

    #10044

    Gian Pablo Villamil
    Participant

    Has there been any change on this? In particular, is millis() available in the Cubelets API? I want to write some code that introduces delays in signal I/O but I would want to make it non-blocking.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.