oDIO1RW Object

Back to top of page Description:
 

preliminary information

A Hardware Object that reads the state of a switch and controls the state of an LED using a single I/O line.  The switch can be configured as a push button or a toggle button and the LED can be set to steady on, stead off or 3 different patterns of blinking.

 The following table lists the size and availability of the oDIO1RW Object.
 ObjectSizeDescriptionA1A2B1B2C1
oDIO1RW3 BytesProvides a 1 line digital I/O that continuously reads and writes.xx
Back to top of page Operation:
 An oButton Object works like an oDio1 Object that continuously cycles between being an Digital Input which reads a push-button style switch and being a Digital Output which controls an LED.  In order for both the LED and the push button to be connected to the same I/O line, they Must be connected to the I/O line through a resister as indicated by the wiring diagram at the end of this page.

When operating as a Digital Input, the State property is set depending on the state of a connected push button and the InvertIn and Mode properties.  If the Mode property is set to 0, then the push button is treated as a regular push button where pressed is on, and released is off.  If the Mode property is 1, then the push button is treated as a toggle switch where pressed once is on and pressed a second time is off.  If the InvertIn property is set to 1, then the logic behind the State property is reversed as follows: If the Mode property is set to 0, then pressed is off, and released is on and if the Mode property is 1, then released once is on and released a second time is off.  In any of these situations, changing from an off state to an on state sets the State property to 1 and changing from an on state to an off state clears the State property to 0.  Note that the State property is only modified when the push button physically changed state.  This allows the application program to set the State property directly thereby emulating the the push button being physically pressed or released.

When operating as a Digital Output, the State property is used to specify whether or not the LED is on.  If State is 1, then the LED is turned on and if State is 0, then the LED is turned off.  The Style property changed the appearance of the LED when it is on.  If Style is set to 0, then the LED glows continuously.  If Style is 1, then the LED blinks once a second.  If Style is 2, then the LED blinks 4 times a second. And if Style is 3, then the LED blinks twice at four times a second and then remains off for 1/2 a second then repeats.

The LED can optionally be disconnected from the push button state and be controlled by a different value.  By setting the Option property to 1, the ValueO Property is used to specify whether or not the LED is on.  This option can be used in combination with a virtual circuit utilizing other objects such as the oRepeat Object to create Buttons with custom functionality.

Back to top of page Properties:
 preliminary information

The following table lists the properties of the oDIO1RW Object:

Property

Description

State
A value that indicates the current state of the input.
Object Class: oLogic Value Range: 0 - 1
Data Type: Numeric Default Value: 0
preliminary information
ValueO
Optional output value. Used when the Option property is set to 1.
Object Class: oLogic Value Range: 0 - 1
Data Type: Numeric Default Value: 0
preliminary information
IsOn
A value that indicates if the button is in the ON position.
Object Class: oProperty Value Range: 0 - 1
Data Type: Numeric (Read-Only) Default Value: 0
preliminary information
IsOff
A value that indicates if the button is in the OFF position.
Object Class: oProperty Value Range: 0 - 1
Data Type: Numeric (Read-Only) Default Value: 0
preliminary information
IOLine
A value that specifies which I/O Line is connected to the switch and the LED.
Object Class: oIOLine Value Range: 0 - 31
Data Type: Numeric Default Value: 0
Some I/O Lines have special purposes.  Be sure to see oIOLine help file for details.
InvertIn
A value that selects if the input is considered ON when the I/O Line is grounded or at 5 volts.
Object Class: oSelect0to1 Value Range: 0 - 1
Data Type: Numeric Default Value: 0
preliminary information
Mode
A value that selects if the input is treated as a push-button or a toggle-switch.
Object Class: oSelect0to1 Value Range: 0 - 1
Data Type: Numeric Default Value: 0
preliminary information
Option
A value that selects if the output is set based on the State or ValueO property.
Object Class: oSelect0to1 Value Range: 0 - 1
Data Type: Numeric Default Value: 0
preliminary information
Blink
A value that selects if and how the output blinks.
Object Class: oSelect0to3 Value Range: 0 - 3
Data Type: Numeric Default Value: 0
preliminary information
Address
Returns a pointer to the address of the oCounter Object instance.
Object Class: oAddress Value Range: 0 - 127
Data Type:Pointer (Read Only) Default Value: Address of Object

Back to top of page Connections:
The actual values of the two resistors are based on the power requirements of the LED that is used in the circuit. Note that both resistors need to be the same value.
Back to top of page Examples:
 In the following example, the oButton Object is used to read a switch and control and LED on I/O line 7.
Dim A As New oButton

Sub Main()
  A.IOLine = 7
End Sub                          

Back to top of page Related Items:

 The following table lists objects that use the oDIO1RW Object.
 ObjectDescriptionA1A2B1B2C1
oButtonReads the position of a switch and controls an LED light.xx
oLEDBControls an LED light.xx
 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oDIO1Provides a 1 line digital I/O.xxxxx
oRepeatProvides a repeat function.xxx
Back to top of page Version History and Bug List:
 Firmware Ver B2: Introduced.

Bugs: No known bugs.


ooPIC Compiler Ver 6.0 (c) Copyright 1997 - 2007 Savage Innovations, LLC.