Arduino Interface Question

Yvonne Bowman's Avatar

Yvonne Bowman

08 Nov, 2017 03:09 PM

Hi Chris,

We're going to need to interface with Arduino through Firmata for our experiment's juice reward, and I have looked at the documentation and am still unsure how to put this into practice. How do I, from the MWorks side, interface with an Arduino board that has Firmata on it already?

Thank you,
Yvonne

  1. Support Staff 1 Posted by Christopher Sta... on 08 Nov, 2017 04:11 PM

    Christopher Stawarz's Avatar

    Hi Yvonne,

    How do I, from the MWorks side, interface with an Arduino board that has Firmata on it already?

    First, you need to add a Firmata device to your experiment. Then, for every input or output you want to use, you need to attach an appropriate channel to the device. The available channel types are

    When adding a channel, you need to specify the pin number you want to use. This will normally be the number printed next to the pin connector on the Arduino board (e.g. 7, A3). You also need to specify a variable for the "value" parameter. For input channels, the pin value will be stored in the variable. For output channels, the pin value will be read from the variable.

    I've attached a short example experiment that configures digital pin 13 as an output and toggles its state every second. (On an Arduino Uno, this pin is tied to the built-in LED, which should light up when the pin value is high.) Because the device declaration omits both the serial_port and bluetooth_local_name parameters, MWorks looks for a single connected serial device and, if it finds one, assumes it's the Firmata device. If you have multiple devices connected via serial-over-USB, or if you want to use a Firmata device connected via Bluetooth, you'll need to include one of those parameters.

    Hopefully this makes sense. If you have any questions, please let me know.

    Chris

  2. 2 Posted by Yvonne Bowman on 08 Nov, 2017 09:16 PM

    Yvonne Bowman's Avatar

    Hi Chris,

    This is great, thank you. I had another question about MWorks' Arduino
    integration. Does MWorks support servo commands? I couldn't find anything
    about it on the forums or documentation.

    Thanks,
    Yvonne

  3. Support Staff 3 Posted by Christopher Sta... on 08 Nov, 2017 09:21 PM

    Christopher Stawarz's Avatar

    Hi Yvonne,

    Does MWorks support servo commands?

    Not at present, but I can add support if you need it.

    Chris

  4. 4 Posted by Yvonne Bowman on 08 Nov, 2017 09:26 PM

    Yvonne Bowman's Avatar

    Hi Chris,

    That would be great. We want to use servo commands to integrate with some
    custom equipment built by our staff scientist, so that would be very
    helpful.

    Yvonne

  5. Support Staff 5 Posted by Christopher Sta... on 15 Nov, 2017 03:11 PM

    Christopher Stawarz's Avatar

    Hi Yvonne,

    As of the current nightly build, MWorks now supports servo control via the new Firmata Servo Channel. Usage is pretty straightforward (example). If you have any questions, please let me know.

    Chris

  6. Christopher Stawarz closed this discussion on 15 Dec, 2017 04:23 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac