9.11 Arduino Addons

9.11.1 addon

: retval = addon (ar, addonname)
: retval = addon (ar, addonname, varargs)

Create an addon object using the addon named class.

Inputs

ar - connected arduino object

addonname - the name of the addon to create. The addon name can be a user addon or an inbuilt addon, however must appear in the listArduinoLibraries output and have been programmed onto the arduino.

varargs - optional values that will be provided verbatim to the the addon class constructor.

Outputs

retval - cell array of string library names.

See also: arduino, arduinosetup, listArduinoLibraries.

9.11.2 arduinoioaddons.EEPRomAddon.EEPRom

: arduinoioaddons.EEPRomAddon.EEPRom

EEPROM addon for arduino

Allows read and write of uint8 data to the onboard arduino EEPROM.

Example

Assuming eeprom addon has been programmed into the Arduino:

 a = arduino ();
 e = addon (a, "eepromaddon/eeprom");
 write (e, 0, uint8("hello world"));
 str = uint8( read(e, 0, 11) )
 

See also: addon.

Properties

length - Size of the EEPROM.

Methods

: eeprom = EEPRom ()

Constructor to create EEPROM device.

Outputs

eeprom - created EEPROM device.

: erase ()

Erase all values in EEPROM (Effectively setting the 0xFF)

: write (address, uintdata)

Write data to EEPROM at the provided address.

Inputs

address - start address to write data to, should be an integer between 0 and the size of the EEPROM.

uintdata a value or array of uint8 data to write to EEPROM.

: data = read (address)
: data = read (address, count)

Read data from starting address of EEPROM.

Inputs

address - start address to read data from, should be an integer between 0 and the size of the EEPROM.

count - Number of uint8 values to read from the EEPROM (default is 1)

Outputs

data a value or array of uint8 data read from the EEPROM.

9.11.3 arduinoioaddons.ExampleAddon.Echo

: arduinoioaddons.ExampleAddon.Echo

Basic Example matlab/octave code to illustrate creating a user addon.

See also: addon.

Properties

Parent - the parent arduino object.

Pins - the pins allocated the addon.

Methods

: obj = Echo(arObj)

Constructor to create Echo addon

Inputs

arObj - the arduino parent object

Outputs

obj - created Echo object

: response = shout(text)

Send text to arduino and receive back the echoed reply

Inputs

text - text to send to arduino

Outputs

response - response from the arduino, which should be the same as the input text.

9.11.4 arduinoioaddons.ExampleLCD.LCD

: arduinoioaddons.LCDAddon.LCD

Basic Example octave addon for LCD

Allows basic manipulation of an LCD as a illustration of using the addon functionality.

Example

Assuming the arduino has been programmed with the lcd addon:

 a = arduino();
 lcd = addon(a, "examplelcd/lcd", "d8", "d9", "d4", "d5", "d6", "d7")
 clearLCD(lcd);
 printLCD(lcd, "Hello");
 # go to next line
 gotoLCD(lcd, 0, 1);
 printLCD(lcd, "World");
 

See also: addon.

Properties

Pins - the pins allocated the LCD display.

Methods

: lcd = LCD(arObj, rs, enable, d0, d1, d2, d3)

Constructor to create LCD device

Inputs

arObj - the arduino parent object

rs - the pin to use for the rs line.

enable - the pin to use for the enable line.

d0 - the pin to use for the d0 line.

d1 - the pin to use for the d1 line.

d2 - the pin to use for the d2 line.

d3 - the pin to use for the d3 line.

Outputs

lcd - created LCD object

: freeLCD()

Free the LCD

Should be called before discarding the LCD

Inputs

None.

Outputs

None.

: clearLCD()

Clear the LCD display and set the cursor position to the home position.

Inputs

None.

Outputs

None.

: printLCD(text)

Display text on LCD starting at the current cursor position.

Inputs

text - text to display on LCD

Outputs

None.

: gotoLCD(col, row)

Set the cursor position to row, col

Inputs

col - 0 indexed LCD column to position to.

row - 0 indexed LCD row to position to.

Outputs

None.

9.11.5 arduinoioaddons.RTCAddon.DS1307

: arduinoioaddons.RTCAddon.DS1307

DS1307 addon

See also: addon.

Properties

Parent - the parent arduino object.

Pins - the pins allocated the addon.

Methods

: obj = DS1307(arObj)
: obj = DS1307(arObj, propertyname, propertyvalue ....)

Constructor to create DS1307 addon

Inputs

arObj - the arduino parent object

propertyname, propertyvalue - optional property name, value pairs. Current known properties are:

address

I2C address of the DS1307 (default 0x68)

Outputs

obj - created DS1307 object

Example

 
 a = arduino()
 rtc = addon(a, "rtcaddon/ds1307")
 
 
: date = clock(dsObj)
: clock(dsObj, date)

Get/set the DS1307 clock

Inputs

dsObj - the ds1307 object

date - a date vector in same format as datevec and clock

Outputs

date - a date vector in same format as datevec and clock

Example

 
 a = arduino()
 rtc = addon(a, "rtcaddon/ds1307")
 # get and display rtc time as a date string
 datestr(rtc.clock)
 
 

See also: datevec.

: ctrl = control(dsObj)
: control(dsObj, ctrl)

Get/set the DS1307 clock

Inputs

dsObj - the ds1307 object

ctrl - a structure containing the control bit fields.

Outputs

ctrl - a structure containing the control bit fields.

Control structure fields are: Current properties are:

out

Out bit in the control register

sqwe

Square wave enable bit in control register

rs

The combined RS0, RS1 value

: YN = isstarted(dsObj)

Get whether the RTC clock is currently counting time

Inputs

dsObj - the ds1307 object

Outputs

YN - returns true if the RTC is counting

See also: start, stop.

: start(dsObj)

Start the RTC counting

Inputs

dsObj - the ds1307 object

Outputs

None

See also: datevec.

: stop(dsObj)

Stop the RTC counting

Inputs

dsObj - the ds1307 object

Outputs

None

See also: datevec.

9.11.6 arduinoioaddons.SimpleStepper.SimpleStepper

: arduinoioaddons.SimpleStepper

Stepper class for stepper control using ULN2003 and compatible drivers

Properties

Id

Id of the stepper (Read only)

Speed

Number of steps to do per second.

Status

Status of stepper (Read only). 0 = not moving, 1 = moving, 2 = rotating

Parent

the Arduino parent (read only)

Pins

the pins used for the stepper (read only)

Methods

: obj = SimpleStepper(aObj, pin1, pin2, pin3, pin4)
: obj = SimpleStepper(aObj, pin1, pin2, pin3, pin4, pin5)

Constructor to create a stepper object

Inputs

aObj - The arduino

pin1 - The first pin of the controller

pin2 - The second pin of the controller

pin3 - The third pin of the controller

pin4 - The fourth pin of the controller

pin5 - The fifth pin of the controller

Outputs

s - a simplestepper object

Example

 
 a = arduino()
 # create stepper object
 s = addon(a, "simplestepper/simplestepper", "d2", "d3", "d4", "d5")
 # start rotating left
 s.rotate(-1);
 
 

See also: addon.

: move(sObj, steps)

Move the motor the specified number of steps using the configured Speed.

Inputs

sObj - the stepper object

steps - the number of steps to move. steps less than 0 will be moving left.

Outputs

None

See also: rotate.

: rotate(sObj, dir)

Start steppermotor moving in the specified direction using the configured Speed.

Inputs

sObj - the stepper object

dir - Direction to move. -1 = left, 0 = stop, 1 = right.

Outputs

None

See also: move.

: release(sObj)

Release this stepper motor

Inputs

sObj - the stepper object

Outputs

None

9.11.7 arduinoioaddons.adafruit.dcmotorv2

: arduinoioaddons.adafruit.dcmotorv2

DC Motor class for dc motor control on the adafruit motor shield

See also: arduinoioaddons.adafruit.motorshieldv2.

Properties

Speed - The speed value set for the motor

Parent - The parent shield for object (read only)

MotorNumber - The motor number (read only) values 1-4

IsRunning - boolean for if the motor is started (read only)

Methods

: obj = dcmotorv2(mObj, mnum)
: obj = dcmotorv2(mObj, mnum, propertyname, propertyvalue ....)

Constructor to create dcmotor object

Inputs

mObj - the motor shield object

mnum - The motor number (1 - 4)

propertyname, propertyvalue - Optional property name/value pairs to pass to motor object.

Current known properties are:

Speed

Initial speed (default 0). Should be a value between -1 and 1.

Outputs

s - a dcmotorv2 object

Example

 
 a = arduino()
 ms = addon(a, "adafruit/motorshieldv2")
 mtr = dcmotor(ms, 1)
 
 
: start(dcObj)

Start the motor moving in previously set speed/direction

Inputs

dcObj - the dcmotor object

Outputs

None

See also: adafruit.motorshieldv2.

: stop(dcObj)

Stop the motor moving

Inputs

dcObj - the dcmotor object

Outputs

None

See also: adafruit.motorshieldv2.

9.11.8 arduinoioaddons.adafruit.motorshieldv2

: arduinoioaddons.adafruit.motorshieldv2

Adafruit motor shield addon

See also: addon.

Properties

Parent - the parent arduino object.

Pins - the pins allocated the addon.

I2CAddress - the i2c address used for accessing this shield.

PWMFrequency - the set PWM frequency for this shield.

Methods

: obj = motorshieldv2(arObj)
: obj = motorshieldv2(arObj, propertyname, propertyvalue ....)

Constructor to create motorshieldv2 addon object

Inputs

arObj - the arduino parent object

propertyname, propertyvalue - optional property name, value pairs. Current known properties are:

address

I2C address of the motor shield (default 0x60)

pwmfrequency

PWM Frequency to set on shield (default 1600)

Outputs

obj - created motorshieldv2 object

Example

 
 a = arduino()
 mtr = addon(a, "adafruit/motorshieldv2")
 
 
: s = servo(mObj, mtrnum)
: s = servo(mObj, mtrnum, propertyname, propertyvalue ...)

Create a servo object

Inputs

mObj - the motor shield object

mtrnum - The servo motor number, where 1 is servo on pin "d10" and 2 is a servo on pin "d9"

propertyname, propertyvalue - Optional property name/value pairs to pass to servo object.

Properties are the same as the base servo object.

Outputs

s - a servo object

Example

 
 a = arduino()
 ms = addon(a, "adafruit/motorshieldv2")
 # get servo 1 (servo on pin D10)
 s = ms.servo(1)
 
 

The function if the equivalent of calling the arduino.servo with the D9 or D10 pin has the input pin.

See also: servo.

: s = stepper(mObj, mtrnum, stepsperrev)
: s = stepper(mObj, mtrnum, stepsperrev, propertyname, propertyvalue ...)

Create a stepper motor object

Inputs

mObj - the motor shield object

mtrnum - The stepper motor number (1 or 2)

stepsperrev - Number of steps per revolution.

propertyname, propertyvalue - Optional property name/value pairs to pass to stepper object.

Outputs

s - a stepper object

: s = dcmotor(mObj, mtrnum)
: s = dcmotor(mObj, mtrnum, propertyname, propertyvalue ...)

Create a dcmotor motor object

Inputs

mObj - the motor shield object

mtrnum - The motor number (1 - 4)

propertyname, propertyvalue - Optional property name/value pairs to pass to motor object.

Outputs

s - a dcmotorv2 object

9.11.9 arduinoioaddons.adafruit.stepper

: arduinoioaddons.adafruit.stepper

Stepper class for stepper control on the adafruit motor shield

See also: arduinoioaddons.adafruit.motorshieldv2.

Properties

RPM

The rpm value set for the stepper motor

StepType

the StepType for the stepper (string) which can be "single", "double", "interleave" or "microstep"

StepsPerRevolution

the StepsPerRevoluion for the stepper (read only)

MotorNumber

the motor number for the stepper (read only) value will be 1 or 2.

Parent

the parent shield of this stepper (read only)

Methods

: obj = stepper(mObj, mnum, stepsperrev)
: obj = stepper(mObj, mnum, stepsperrev, propertyname, propertyvalue ....)

Constructor to create dcmotor object

Inputs

mObj - the motor shield object

mnum - The motor number (1 or 2)

stepsperrev - Number of steps per revolution.

propertyname, propertyvalue - Optional property name/value pairs to pass to motor object.

Current known properties are:

RPM

the RPM for the stepper (revolutions per minute)

StepType

the StepType for the stepper (string) which can be "single", "double", "interleave" or "microstep"

Outputs

s - a stepper object

Example

 
 a = arduino()
 ms = addon(a, "adafruit/motorshieldv2")
 mtr = stepper(ms, 1, 200)
 
 
: move(sObj, steps)

Move the motor moving in the specified steps using the configured RPM.

Inputs

sObj - the stepper object

Outputs

None

See also: adafruit.motorshieldv2.

: release(sObj)

Release this motor

Inputs

sObj - the stepper object

Outputs

None

See also: adafruit.motorshieldv2.


Next: Arduino Sensors, Previous: Arduino Ultrasonic Functions, Up: Function Reference   [Contents][Index]