Git Product home page Git Product logo

arduino-maya's Introduction

Arduino-Maya communication suite

Software to make an Arduino board and a Maya session communicate.
This can be particularly useful to create custom input devices.
It is programmed in Python and Arduino language. It uses pySerial (https://github.com/pyserial/pyserial).
See it working on my twitter and on my July 2017 reel.

Directory structure

This repository contains:

  • A Maya Python API/PyMEL plugin (src/maya)
  • A Python script to read the serial stream incoming from Arduino and feed it to Maya via socket connection (src/driver)
  • An Arduino test firmware (src/arduino)

How to use this

What do you need

  • An Arduino board. I've used an UNO v3. Other boards are ok. Just watch out for interrupt mappings
  • Three potentiometers. I recommend sliders. But the choice is yours
  • Jumper wires
  • pySerial (https://github.com/pyserial/pyserial)
  • Maya. I've used the 2017 v3 Student Edition. Not too old versions are fine too

Quick Start

  1. Follow this circuit diagram to make the connections:
    Circuit diagram
  2. Flash the Arduino sketch src/arduino/firmware.ino to your board.
  3. Put the src/maya-plugin/arduinomaya.py plugin into the Maya plug-ins folder.
  4. Load the arduinomaya.py plugin within a Maya session.
  5. Start the src/driver/serial2maya.py script.
  6. Connect the three available channels using the GUI that can be brought up with the arduinoGUI command.
  7. Enjoy.

How does this works

Here an approximate system diagram:
System diagram
The data flow is pretty simple. The potentiometers generate analog signals. The Arduino board converts them with its ADC and sends them through serial connection to the computer where Maya is running. Here the signals are translated into Maya commands and are feeded to the Maya session through its commandPort socket. Finally, Maya must understand them and modify the current scene.

To make this work, three software pieces are needed: the Arduino firmware, the "Serial to Maya" driver, and a Maya plugin. Here the details for each piece.

1: The firmware

The provided Arduino firmware reads the three analog signals that comes into A0,A1, and A2 ports. Every ~30ms it puts the delta value for each port in to the Serial outgoing stream.

2: The "bridge" program

It is a Python script that uses the pySerial lib for Arduino to PC serial communication and the socket module to send messages to Maya. It runs an endless loop that launches the MEL command defined in the Maya plugin.

3: The Maya plugin

The plugin adds four commands. Usually the user should invoke only arduinoGUI.

  • arduinoGUI: Brings up the GUI.
  • arduinoConnectAttribute <channel> <object> <attribute>: This connects the channel to the attribute of the given object. The attribute must be a float attribute. Example: arduinoConnectAttribute 0 pCube1 rotateX this connects the first channel (or potentiometer if you are using the firmware provided here) to the attribute rotateX of the pCube1 object.
  • arduinoConnectTime <channel>: This connects channel to the time slider.
  • arduinoUpdateChannel <channel> <delta>: Adds delta to the attribute connected to channel.

arduino-maya's People

Contributors

giuliom95 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.