KBLED mask

Mask - is a variable/constant which specifies the LEDs to use.


Set/clear the keyboard LEDs.

This command is used to control the LEDs on a computer keyboard (connected directly to the PICAXE - not the keyboard used whilst programming). The mask value sets the operation of the LEDs. Mask is used as follows:

Bit 0 Scroll Lock (1=on, 0=off)
Bit 1 Num Lock (1=on, 0=off)
Bit 2 Caps Lock (1=on, 0=off)
Bit 3-6 Not Used
Bit 7 Disable Flash (1=no flash, 0=flash)

On reset mask is set to 0, and so all three LEDs will flash when the 'kbin' command detects a new key hit. This provides the user with feedback that the key press has been detected by the PICAXE. This flashing can be disabled by setting bit 7 of mask high. In this case the condition of the three LEDs can be manually controlled by setting/clearing bits 2-0.

Effect of Increased Clock Speed

This command will only function at 4MHz.

18M2 Firmware

Please note the 'kbled' command is only supported for 18M2 firmware D.x (PICAXE chips labelled 18M2+) and is not available for use with 18M2 firmware 2.x (PICAXE chips labelled 18M2).

The PICAXE compiler will syntax check code for an 18M2 as correct when using the 'kbled' command but will generate an error when an attempt is made to download into an 18M2 with firmware 2.x.

Applies To:
14M2, 18M2+, 20M2, 20X2, 28X1, 28X2, 40X1, 40X2
See Also:
Related Create:

Using 'kbled'

This program repeatedly sets the keyboard LEDs on and then turns them all off again.

Code Example:
main:	kbled %10000111		; all LEDs on
	pause 500		; pause 0.5s
	kbled %10000000		; all LEDs off
	pause 500		; pause 0.5s
	goto main		; loop
Copy Code Submit an Example

Submit Your Own Code!

You must be logged in to submit code examples. Login now.


  • Login to leave a comment.