oLED Object

Main Index
Object List
Back to top of pageDescription:
 An oLED Object is a Hardware Object that uses a single digital I/O lines to control the brightness of an LED.

The brightness of the LED is controlled by a single value with a range of 0 to 15.  When this value is 0, the LED is off. When the value is a number from 1 to 15, the LED increases in brightness at a level indicated by the value.  The higher the value, the brighter the LED is. 

 The following table lists the size and availability of the oLED Object.
 ObjectSizeDescriptionA1A2B1B2C1
oLED4 BytesControls an LED light with brightness control.xxx
Back to top of pageOperation:
 An oLED Object controls the brightness of an LED by outputting a control signal on on the I/O line specified by the IOLine property.

The Brightness property controls how bright the LED is.  To control the brightness of an LED, an output control signal turns on and off at a frequency of about 550 Hz causing the LED to flash at a rate that is unperceivable to the eye.  The duration of the "on" portion of the control signal determines how bright the LED will be.  This duration is specified by the value of the Brightness property which is expressed as ratio of 15 where 0 is 0%, 7 is 50% and 15 is 100%.  That is to say that at 0, the "on" portion of the control signal is 0% of the time.  At 50%, the "on" portion of the control signal is 50% of the time and so on.

The Operate property specifies if the "on" portion of the control signal is generated.  When the Operate property is set to 1, the oLED Object starts generating and outputting the "on" portion at the duration specified by the Brightness property. When the Operate property is set to 0, the "on" portions are are discontinued and the specified I/O Line is set off.

The PWM property is an instance of the oPWML object which is created when the oLED object is.  Attributes of the LED's operation can be adjusted by directly manipulating the oPWML object. Note that doing so may change the way the LED behaves to something different than the way described in this document.  (see oPWML object for more detail on how the oPWML Object control the LED.)
Back to top of pageProperties:

The following table lists the properties of the oLED Object:

Property

Description

Brightness
A value that specifies the brightness level of the LED.
Object Class: oNib Value Range: 0 - 15
Data Type: Numeric Default Value: 0
BrightnessDescription
0The LED is off.
1 - 14

The LED is at a brightness level between off and full on.

15*

The LED is at full brightness.

Bug: A value of 15 does not work in firmware B1 to B2.  Fixed in C1.
IOLine
A value that specifies which I/O Line is used to control 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.
Operate
A value that selects if the LED is on or off.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe LED is off.
1cvOnThe LED is on.
PWM
The I/O function object used to control the LED.
Object Class: oPWML Value Range: 0 - 15
Data Type: Numeric Default Value: 0
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 pageExamples:
In the following examples, the oLED Object is used.
Visual Basic SyntaxC and Java Syntax
'This program causes an LED on I/O
'Line 7 to change brightness.

Dim A As New oLED

Sub Main()
  A.IOLine = 7
  A.Operate = cvTrue
  Do
    ooPIC.Delay = 20
    A.Brightness = A.Brightness + 1  
  Loop
End Sub 
//This program causes an LED on I/O
//Line 7 to change brightness.

oLED A = New oLED;

Void Main(Void){
  A.IOLine = 7;
  A.Operate = cvTrue;
  Do{
    ooPIC.Delay = 20;
    A.Brightness++;
  } While (1);
}
Basic Syntax 
'This program causes an LED on I/O
'Line 7 to change brightness.

A As oLED(7,,,cvOn)

Do
  ooPIC.Delay = 20
  A.Brightness = A.Brightness + 1  
Loop
 
Back to top of pageConnections:
The IOLine property specifies which I/O Line to connect.

Note that the LED is polarized. That is to say, it will not work if it is connected backwards. Make sure that you have attached the LED with the positive side (long prong) connecting to the I/O line and the negative side (short prong) connecting to the resistor.

To connect the LED in reverse, use the code "X.PWM.Invert = 1"

Back to top of pageRelated Items:
 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
o7SegControls a 7-Segment Display.x
o8barControls an 8-Segment Bar Display.x
oLED2Controls a Dual Color LED light with brightness control.xxx
oLEDBControls an LED light with blinking functions.xx
oLightControls a light.xxx
Back to top of pageVersion History and Bug List:
 Firmware Ver B1: Introduced.

Bugs: Firmware B1 to B2 a brightness level of 15 does not work.  Fixed in firmware C.1


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