|
| 1 | +Arduino Octave |
| 2 | +============== |
| 3 | +A class to control an Arduino board using the Firmata protocol. |
| 4 | +I kept most functions identical to Matlab's version for compatibility. |
| 5 | + |
| 6 | +The StandardFirmata.ino firmware needs to be loaded to your development board. |
| 7 | +Serial communication is the only form possible right now. |
| 8 | + |
| 9 | +Additional features will be added later. |
| 10 | +version 1.0.0 |
| 11 | + |
| 12 | +Table of Contents |
| 13 | +================= |
| 14 | +* [Initialization](#initialization) |
| 15 | + * [arduino](#arduinoport-board-voltage "arduino(Port, Board, Voltage)") |
| 16 | +* [General Commands](#general-commands) |
| 17 | + * [configurePin](#configurepinobj-pin-mode "configurePin(obj, pin, mode)") |
| 18 | + * [readDigitalPin](#readdigitalpinobj-pin "readDigitalPin(obj, pin)") |
| 19 | + * [writeDigitalPin](#writedigitalpinobj-pin-val "writeDigitalPin(obj, pin, val)") |
| 20 | + * [readVoltage](#readvoltageobj-pin "readVoltage(obj, pin)") |
| 21 | + |
| 22 | +Initialization |
| 23 | +============== |
| 24 | + |
| 25 | +arduino(Port, Board, Voltage) |
| 26 | +----------------------------- |
| 27 | +Starts the class. All parameters are optional, the serial port should be automatically found |
| 28 | +(only tested on Linux). Board is to keep compatibility with Matlab and to help determine the |
| 29 | +maximum voltage. Voltage is a way to manually set the maximum voltage (5V on Uno, 3.3 on ESP32, etc). |
| 30 | +Note that Voltage is not compatible with Matlab. |
| 31 | + |
| 32 | +Returns the arduino object (used for every other function). |
| 33 | + |
| 34 | +If this is run without a parenthese (;) at the end, it will display the |
| 35 | +serial port, board name (defaults to 'Uno'), all available digital and analog pins, |
| 36 | +and the max voltage value being used with voltage functions. |
| 37 | + |
| 38 | +General Commands |
| 39 | +================ |
| 40 | + |
| 41 | +configurePin(obj, pin, mode) |
| 42 | +---------------------------- |
| 43 | +If the `mode` is specified, this will set the desired pin to that mode. If not, it simply |
| 44 | +returns the mode already on the pin. |
| 45 | + |
| 46 | +| `Mode` | |
| 47 | +|------------------| |
| 48 | +| 'AnalogInput' | |
| 49 | +|'DigitalInput' | |
| 50 | +|'DigitalOutput' | |
| 51 | +| 'I2C' | |
| 52 | +| 'PWM' | |
| 53 | +| 'Servo' | |
| 54 | +| 'SPI' | |
| 55 | +| 'OneWire' | |
| 56 | +| 'Stepper' | |
| 57 | +| 'Encoder' | |
| 58 | +| 'Unset' | |
| 59 | + |
| 60 | +readDigitalPin(obj, pin) |
| 61 | +------------------------ |
| 62 | +Reads the value of a digital pin. This can also be used on analog pins. |
| 63 | +It will automatically set the pin mode if it is not 'DigitalInput' or 'Pullup'. |
| 64 | + |
| 65 | +Returns `[val,err]` where val is 1 or 0, err is 1 if an error occured during the process. |
| 66 | +Note that err is not compatible with Matlab. |
| 67 | + |
| 68 | +writeDigitalPin(obj, pin, val) |
| 69 | +------------------------------ |
| 70 | +Writes a value to a pin. This can also be used on analog pins. |
| 71 | +It will automatically set the pin mode if it is not 'DigitalOutput'. |
| 72 | + |
| 73 | + |
| 74 | +readVoltage(obj, pin) |
| 75 | +--------------------- |
| 76 | +Reads the voltage on an analog pin. It will automatically |
| 77 | +set the pin mode if it is not 'AnalogInput'. |
| 78 | + |
| 79 | +The output value will be scaled from 0-1023 to 0-5V. Note that this is an |
| 80 | +approximation, and the actual maximum voltage will not be 5V without a good |
| 81 | +power supply. |
| 82 | + |
| 83 | +Returns `[volt,value,err]` where volt is the approximate voltage, value is the |
| 84 | +raw value (0-1023), and err is 1 if an error occured during the process. |
| 85 | +Note that only volt is compatible with Matlab. |
0 commit comments