072 - Circular Display - Single LED Fade up & down

Summary: Illuminate ONE LED on the circular LED display to fade-up and fade-down. Speed = (BYTE2)

Syntax:

72 <BYTE2> <BYTE3 ><BYTE4> (decimal format)

Where:

BYTE2: Fade Speed (ms) (default is 100 if 0 is entered)

BYTE3: 0-7 = INDEX of LED to illuminate (e..g N=0, NE=1, E=2 etc.)

BYTE4: 0 = One Shot,

BYTE4: 255 = Continuous

Response from IRCF360:

No Response on serial port (unless command 10 was previously sent to IRCF360 to request an echo of each command)

Circular Display Feedback:

Designated LED will fade on and off once unless BYTE4=255

Description:

Will trigger one designate LED on the Circular LED display to fade up and down.

The variable FADE_SPEED needs to be set. Enter 0 for default speed of 100. This effects total time of the fade period. For example, if a value of 1 is entered, then there will be 2500us/BYTE2. for the first two fades. The 3rd fade will be half as long.

To obtain a pulsing 'heartbeat' effect enter 300 as BYTE2 (fade speed).

The command is used to enable the robot controller to give visual feedback for example:

    • Debugging

    • Indication of robot state

    • Visual Effect

    • Display of a particular mood or an expression of emotion within a game or swarm / flock (e.g. sleeping, eating, angry, dead)

Technical Features

The eye is very sensitive to difference in light intensity and sees the proportion of time when the LED is on and off over a fixed period of time, as changes of bright intensity. The proportion of the the time the LED is is on or off determines the brightness of the LED.

The fading UP or DOWN an LED is quite simple. Here is BASIC language routine that gives and indication of how the fade speed and duration can effect the speed of the fade routine. It will make and LED fade brighter and then dimmer. The fade_speed determines how quickly the LED is fading up or down by making bigger steps.

Logic for LED Fade Up & Down

FOR X = 1 To 2500 Step FADE_SPEED

OFF_TIME=2500 -X

ON_TIME = X

GOSUB LED_ON

NEXT

LED_ON:

HIGH B.3 ' Turn on a pin where LED is connected

PAUSE ON_TIME

LOW.B3 ' Turn off a pin where LED is connected

PAUSE OFF_TIME

RETURN

If you want all LEDs to fade up or down then try the following alternative command:

070 ALL LEDs FADE UP & DOWN

Example Code:

Arduino Code

IRCF360 - Arduino Sample Code - Command 72

Command 072 - Fade a specified LED fade up and down

This program sends a commnand to the IRCF360 to fade up and down. By entering a number

from 0-7 the respective LED starts fading up and down.

Byte 1 = 72 which triggers the command

Byte 2 = Speed of fading - Changing this value will change the speed 10 is a good value to start with

Byte 3 = Is the LED to fade O=North, 1=NE, 2=E, 3=SE, 4=S, 5=SW, 6=W, 7=W

Byte 4 = 255 = continuous

Byte 4 = other number is on-shot i.e. will execute only once the stop

Thanks to Greg Smith for the improvements

The circuit:

* potentiometers attached to analog inputs 0 and 1

* pushbutton attached to digital I/O 2

Created 15 June, 2011

by Colin Bacon

This example code is in the public domain.

http://www.robotmaker.eu/products-2/ircf360/ircf360-command-overview/072---ircf-command---circular-display---single-led-fade

*/

int BYTE1 =72; // Command

int BYTE2 =10; // Speed of fade. 100 is very fast 5 is very slow

int BYTE3 =0; // LED number default value

int BYTE4 =255; // 255 = continuous other = one-shot

void setup()

{

// start serial port at 9600 bps:

Serial.begin(9600);

{

delay (1000);

Serial.print(BYTE1, BYTE);

Serial.print(BYTE2,BYTE);

Serial.print(BYTE3,BYTE);

Serial.print(BYTE4,BYTE);

}

}

void loop()

{

// if we get a valid byte, read the LED to illuminate:

while (Serial.available() == 0); //keep looping until a value is entered

// convert the ascii value to decimal value and assign it to the LED

BYTE3 = Serial.read() -'0';

if ((BYTE3 <=7) && (BYTE3 >=0))

{

// sending any byte will stop the existing sequence

Serial.print(BYTE1, BYTE);

}

//Let the ping-pong routine run for 1 second

delay (1000);

{

//Send details of the new sequence

Serial.print(BYTE1, BYTE);

Serial.print(BYTE2,BYTE);

Serial.print(BYTE3,BYTE);

Serial.print(BYTE4,BYTE);

}

// Flush and rubbish

Serial.flush();

}

Arduino Example Code

/*

Command 072 - Fade a specified LED fade up and down

This program sends a commnand to the IRCF360 to fade up and down. By entering a number

from 0-7 the respective LED starts fading up and down.

Byte 1 = 72 which triggers the command

Byte 2 = Speed of fading - Changing this value will change the speed 10 is a good value to start with

Byte 3 = Is the LED to fade O=North, 1=NE, 2=E, 3=SE, 4=S, 5=SW, 6=W, 7=W

Byte 4 = 255 = continuous

Byte 4 = other number is on-shot i.e. will execute only once the stop

Thanks to Greg Smith for the improvements

The circuit:

* potentiometers attached to analog inputs 0 and 1

* pushbutton attached to digital I/O 2

Created 15 June, 2011

by Colin Bacon

This example code is in the public domain.

http://www.robotmaker.eu/products-2/ircf360/ircf360-command-overview/072---ircf-command---circular-display---single-led-fade

*/

int BYTE1 =72; // Command

int BYTE2 =10; // Speed of fade. 100 is very fast 5 is very slow

int BYTE3 =0; // LED number default value

int BYTE4 =255; // 255 = continuous other = one-shot

void setup()

{

// start serial port at 9600 bps:

Serial.begin(9600);

{

delay (1000);

Serial.print(BYTE1, BYTE);

Serial.print(BYTE2,BYTE);

Serial.print(BYTE3,BYTE);

Serial.print(BYTE4,BYTE);

}

}

void loop()

{

// if we get a valid byte, read the LED to illuminate:

while (Serial.available() == 0); //keep looping until a value is entered

// convert the ascii value to decimal value and assign it to the LED

BYTE3 = Serial.read() -'0';

if ((BYTE3 <=7) && (BYTE3 >=0))

{

// sending any byte will stop the existing sequence

Serial.print(BYTE1, BYTE);

}

//Let the ping-pong routine run for 1 second

delay (1000);

{

//Send details of the new sequence

Serial.print(BYTE1, BYTE);

Serial.print(BYTE2,BYTE);

Serial.print(BYTE3,BYTE);

Serial.print(BYTE4,BYTE);

}

// Flush and rubbish

Serial.flush();

}

PICAXE code

See the video of this short routine below.

IRCF360 - Demo of command 72 and 70

MAIN:

COMMAND_72:

SEROUT b.2,T9600_8, (72 ,100,0,0) 'Light North LED, for a period of 2500us/<BYTE2>)

SEROUT b.2,T9600_8, (11, 0,0,0) 'Turn off ping pong display

PAUSE 2000

SEROUT b.2,T9600_8, (72, 100 ,2,0) 'Light North LED, for a period of 2500us/<BYTE2>)

SEROUT b.2,T9600_8, (11, 0,0,0) 'Turn off ping pong display

PAUSE 2000

SEROUT b.2,T9600_8, (72 , 100,4,0) 'Light North LED, for a period of 2500us/<BYTE2>)

SEROUT b.2,T9600_8, (11, 0,0,0) 'Turn off ping pong display

pause 2000

SEROUT b.2,T9600_8, (72, 100,6,0) 'Light North LED, for a period of 2500us/<BYTE2>)

SEROUT b.2,T9600_8, (11, 0,0,0) 'Turn off ping pong display

PAUSE 2000

GOTO MAIN

Videos: