| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

Arduino_Osc

Page history last edited by Bjoern Hartmann 11 years, 9 months ago

 

 

 

ARDUINO_OSC is a firmware for Arduino to send and receive OpenSoundControl messages.

It is written entirely in the Arduino environment and can easily edited/compiled/uploaded by Arduino users. 

 

Inspired by Firmata, ARDUINO_OSC offers the following functionality:

  • Digital and analog input pin value changes are sent from Arduino to a PC
  • Digital and PWM output pins can be controlled at runtime with messages from a PC
  • Digital pins can be toggled between input and output at runtime with messages from a PC
  • Reporting of digital and analog input messages can be controlled at runtime with messages from a PC

 

Download latest release:

arduino_osc_0005.pde (2008-12-02)

Change log:

* BUG FIX: Analog input now reports 8 bits, not just 6 bits

* CHANGE IN BEHAVIOR: when pins are switched to output, they are held low by default (was: high)

* BUG FIX: when PWM messages are received, pins are internally switched to output to avoid extraneous input events from being reported.

 

Earlier releases:

arduino_osc_0004.pde (2008-11-22)

This version has been tested with: Arduino Diecimila hardware; Arduino 0011 on OS X, Arduino 0012 on Win XP.

 

This project is under Mercurial revision control. View history at bitbucket/bjoern/arduino_osc.

 

You can test ARDUINO_OSC using a Pd patch on pd_OSCserial.

 

Details (copied from the pde file):

/**************************************************************
* ARDUINO_OSC 0005
*
* Firmware to send OSC messages from an Arduino board to a PC
* and to receive OSC messages sent from the PC.
*
* Right now, only messages with a single integer argument
* are supported in either direction.
*
* Uses the following serial OSC format:
* 0xBE MSG_LENGTH OSC_MESSAGE CHECKSUM
* ---- ---------- ---/.../--  --------
* 1b   1byte      4*n bytes   1byte
*
* PROTOCOL DETAILS
* Digital pins 2..12 and analog inputs 0..5 are supported.
* PWM output on PWM-capable digital pins is supported as well.
* Below, the notation [2..12] means: any number from 2 to 12.
* The notation [0|1] means: either 0 or 1.
* Pin numbers are always part of the OSC address. 
* The single integer argument for each OSC message
* represents either HIGH/LOW, or an 8bit analog value.
*
* PC->ARDUINO MESSAGE FORMAT
* /pinmode/[2..12]  [0|1] - set a pin to input or output mode
*
* /report/adc [0|1]    - turn all analog pin reporting on/off (Default: off)
* /report/adc/[0..5] [0|1]  - set analog pin reporting for one pin on/off
* /report/in [0|1]     - turn digital pin reporting on/off (default: on)
*
* /out/5 [0|1]         - set a digital pin to [low|high]
* /pwm/10 [0..255]     - set duty on a pwm-enabled pin 
* 
* ARDUINO->PC PROTOCOL 
* /in/[2..12] [0|1]    - a digital input pin changed to [high|low]
* /adc/[0..5] [0..255] - analog input value changed to [0..255]
* NOTE: input pins use pull-up resistors and are HIGH by default.
* Therefore, 0 means HIGH, 1 means LOW (pulled to ground). 
* Output pins are low by default.
*
* EXAMPLES: PC->ARDUINO 
* /pinmode/5 0         - set pin 5 to INPUT
* /pinmode/9 1         - set pin 9 to OUTPUT
* /out/9 0             - set pin 9 to LOW
* /out/12 1            - set pin 12 to HIGH
* /pwm/10 255          - set PWM duty on pin 10 to 255 (100%)
* /report/in 1         - turn digital input pin reporting on
* /report/adc/4 0      - turn reporting of analog input 4 off
*
* EXAMPLES: ARDUINO->PC
* /in/4 1              - digital input pin 4 pulled to ground
* /adc/2 128           - analog input pin2 read 128 (=2.5V)
* 
* DEFAULT STARTUP CONFIGURATION
*   - Pins 2-12 are all set to input, digital reporting enabled
*     (change variable reportDigital to False to disable by default)
*   - Analog reporting is disabled 
*     (change variable reportAnalog to 0xFF to enable by default)
*
* NOTES:
*   - Pins 0,1,13 cannot be used
*   - Resolution on analog in and out is 8 bit.
*   - Not all pins can be used for /pwm output. see arduino documentation
*   - So far, not much error checking for bounds done
*   - 115200 serial rate results in some read errors on Arduino.
*     38400 is recommended.
* 
* MIT License:
* Copyright (c) 2008 Bjoern Hartmann, Stanford HCI Group
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* bjoern@cs.stanford.edu 12/02/2008
**************************************************************/

 

TO DO:

Test & publish version 0006.

 

Backstory:

Back in the avr-gcc days, I wrote a firmware to send and receive OSC messages on the Arduino. Unfortunately, since this firmware used non-Arduino libraries, it had to be flashed manually using uisp/avrdude, putting it out of reach of most Arduino users. Also, pin assignment was static and all pins always reported, creating some bottlenecks.

I picked this thread back up in October 2008, writing a number of preliminary versions that first only offered output, then expanded to hardwired input addresses as well: arduino_osc_prelims.zip

Comments (0)

You don't have permission to comment on this page.