Instruction Examples
This page provides practical instruction tables for programming reference.
Instruction Table Format
| Field | Description |
|---|---|
| LINE | Program line number, 3-digit hexadecimal address |
| OPCODE | Instruction opcode, 2-digit hexadecimal value (e.g., 00, 01, FF) |
| OP-0 | First parameter (combining OP-00 + OP-01 as 16-bit value) |
| OP-1 | Second parameter (combining OP-10 + OP-11 as 16-bit value) |
| Remark | Functional description |
- LINE: Program address, 3-digit hexadecimal, range
000~FFF - OPCODE: Opcode, 2-digit hexadecimal (e.g.,
00,01,FF) - OP-0 / OP-1: Parameter values, 4-digit hexadecimal each
- Unused parameters should be set to
0000 - Program termination marker:
OPCODE=0x0F, OP-0=0000, OP-1=0000
0x00 NOP - No Operation
Do nothing, program counter moves on to next line. Can be used as a placeholder for future modifications.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 00 | 0000 | 0000 | No operation, proceed to next line |
001 | 00 | 0000 | 0000 | Reserved line for future modifications |
002 | 00 | 0000 | 0000 | Reserved line for future modifications |
003 | 0F | 0000 | 0000 | Program termination |
0x01 Set Digital Output
Set digital output pins to HIGH or LOW. HIGH turns LED on, LOW turns LED off.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 01 | 0000 | 0001 | Set DO0 HIGH |
001 | 00 | 0000 | 0000 | No operation |
002 | 01 | 0000 | 0000 | Set DO0 LOW |
003 | 00 | 0000 | 0000 | No operation |
004 | 01 | 0000 | 0009 | Set DO[3:0] to HIGH,LOW,LOW,HIGH |
005 | 0F | 0000 | 0000 | Program termination |
0x02 Set Delay
Set a delay before executing the next line. Unit can be millisecond, second, or minute.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 01 | 0000 | 0001 | Set DO0 HIGH |
001 | 02 | 03E8 | 0000 | Delay 1000 ms |
002 | 01 | 0000 | 0000 | Set DO0 LOW |
003 | 02 | 03E8 | 0000 | Delay 1000 ms |
004 | 0F | 0000 | 0000 | Program termination |
0x03 Set Timer
Set a down counter as timer. Register R23 is set to 0001 during countdown, reset to 0000 when done.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 03 | 1388 | 0000 | Set 5000 ms timer |
001 | 03 | 0000 | 0000 | Check R23 status |
002 | 0F | 0000 | 0000 | Program termination |
0x04 Conditional Jump: Greater than Literal Value
If value in R00 is greater than the given literal, jump to target line.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 0000 | 0000 | Write 0000 to register R00 |
001 | 02 | 0001 | 0001 | Delay 1 second for viewing result |
002 | 12 | 0000 | 0001 | Increment value in register R00 by 1 |
003 | 04 | 0008 | 0010 | Is R00 > 8? If yes, jump to line 010 |
004 | 05 | 0008 | 0020 | Is R00 < 8? If yes, jump to line 020 |
005 | 06 | 0008 | 0030 | Is R00 == 8? If yes, jump to line 030 |
006 | 02 | 03E8 | 0000 | Delay 1000 milliseconds |
007 | 0E | 0000 | 0001 | Return to line 001 for loop execution |
010 | 01 | 00FF | 000C | Turn on LED3 and LED2 |
011 | 0E | 0000 | 0001 | Return to line 001 for loop execution |
020 | 01 | 00FF | 0003 | Turn on LED1 and LED0 |
021 | 0E | 0000 | 0001 | Return to line 001 for loop execution |
030 | 01 | 00FF | 0006 | Turn on LED2 and LED1 |
031 | 0E | 0000 | 0001 | Return to line 001 for loop execution |
0x05 Conditional Jump: Less than Literal Value
See 0x04 example above.
0x06 Conditional Jump: Equals Literal Value
See 0x04 example above.
0x07 Conditional Jump: Greater than Register Value
If value in R00 is greater than the value in specified register, jump to target line.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 0000 | 0000 | Write 0000 to register R00 |
001 | 10 | 0005 | 0008 | Write 0008 to register R05 |
002 | 12 | 0000 | 0001 | Increment value in register R00 by 1 |
003 | 07 | 0005 | 0010 | Is R00 > R05? If yes, jump to line 010 |
004 | 08 | 0005 | 0020 | Is R00 < R05? If yes, jump to line 020 |
005 | 09 | 0005 | 0030 | Is R00 == R05? If yes, jump to line 030 |
006 | 02 | 03E8 | 0000 | Delay 1000 milliseconds |
007 | 0E | 0000 | 0002 | Return to line 001 for loop execution |
010 | 01 | 00FF | 0008 | Turn on LED3 |
011 | 0E | 0000 | 0001 | Return to line 001 for loop execution |
020 | 01 | 00FF | 0004 | Turn on LED2 |
021 | 0E | 0000 | 0001 | Return to line 001 for loop execution |
030 | 01 | 00FF | 0002 | Turn on LED1 |
031 | 0E | 0000 | 0001 | Return to line 001 for loop execution |
0x08 Conditional Jump: Less than Register Value
See 0x07 example above.
0x09 Conditional Jump: Equals Register Value
See 0x07 example above.
0x0A Advanced Conditional Jump: Register Comparison
Compare value in R00 with specified register, jump based on comparison result.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 0000 | 0064 | Write 100 to R00 |
001 | 10 | 0000 | 0050 | Write 80 to R05 |
002 | 0A | 0003 | 0005 | 0100 |
003 | 01 | 0000 | 0001 | Set DO0 HIGH |
004 | 0F | 0000 | 0000 | Program termination |
| Code | Condition |
|---|---|
01 | Equal (=) |
02 | Not equal (≠) |
03 | Greater than (>) |
04 | Less than (<) |
05 | Greater than or equal (≥) |
06 | Less than or equal (≤) |
07 | Is zero |
08 | Is not zero |
0x0B Advanced Conditional Jump: Digital Input
Jump based on digital input signals on DI0-DI3 pins.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 25 | 0000 | 000F | Configure lower 4 digital IO pins as input |
001 | 0B | FF0D | 0010 | If four digital inputs are 0101, jump to line 010 |
002 | 0E | 0000 | 0000 | Return to line 000 for re-evaluation |
003 | 00 | 0000 | 0000 | NOP |
010 | 01 | 00FF | 00F0 | Turn on LEDs on four output pins |
011 | 0F | 0000 | 0000 | Program termination |
0x0C Call: Jump to Subroutine
Call a subroutine at the specified line. Use 0x0D to return.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 00 | 0000 | 0000 | NOP |
001 | 0C | 0010 | 0000 | Call subroutine at line 010 |
002 | 0F | 0000 | 0000 | Program termination |
003 | 00 | 0000 | 0000 | NOP |
004 | 00 | 0000 | 0000 | NOP |
010 | 01 | 00FF | 00FF | Turn on all LEDs |
011 | 0C | 0020 | 0000 | Call subroutine at line 020 |
012 | 0D | 0000 | 0000 | Return to caller at line 001 |
020 | 02 | 0001 | 0001 | Delay 1 second |
021 | 01 | 00FF | 0000 | Turn off all LEDs |
022 | 0D | 0000 | 0000 | Return to caller at line 011 |
0x0D Return: Back from Subroutine
Return from a subroutine called by 0x0C.
See 0x0C example above.
0x0E Unconditional Jump
Jump to the specified line without any condition.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 25 | 0000 | 000F | Configure lower 4 digital IO pins as input |
001 | 0B | FF0D | 0010 | If four digital inputs are 0101, jump to line 010 |
002 | 0E | 0000 | 0001 | Return to line 000 for re-evaluation |
003 | 00 | 0000 | 0000 | NOP |
010 | 01 | 00FF | 00F0 | Turn on LEDs on four output pins |
011 | 0F | 0000 | 0000 | Program termination |
0x10 Write Value to Register
Modify the value in the specified register.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 001C | 03E8 | Write 03E8 to register R1C |
001 | 00 | 0000 | 0000 | NOP |
002 | 13 | 001C | 0000 | Output lower 8 bits of R1C to digital port |
003 | 0F | 0000 | 0000 | Program termination |
0x11 Register Copy
Copy value of one register to another.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 001C | 03E8 | Write 03E8 to register R1C |
001 | 11 | 001D | 001C | Copy value of register R1C to R1D |
002 | 13 | 001D | 0000 | Output lower 8 bits of R1D to digital port |
003 | 0F | 0000 | 0000 | Program termination |
0x12 Increment/Decrement Register
Increment or decrement register value, with optional overflow control.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 001C | FF00 | Write FF00 to register R1C |
001 | 12 | 001C | 03E8 | Increment R1C by 03E8, no overflow allowed |
002 | 13 | 001C | 0000 | Output lower 8 bits of R1C to digital port |
003 | 02 | 0005 | 0001 | Delay 5 seconds |
004 | 12 | 011C | 03E8 | Increment R1C by 03E8, overflow allowed |
005 | 13 | 001C | 0000 | Output lower 8 bits of R1D to digital port |
006 | 0F | 0000 | 0000 | Program termination |
0x13 Register Value to Digital Output
Use the least 8 bits of a register as digital output value.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 001C | 03E8 | Write 03E8 to register R1C |
001 | 11 | 001D | 001C | Copy value of register R1C to R1D |
002 | 13 | 001D | 0000 | Output lower 8 bits of R1D to digital port |
003 | 0F | 0000 | 0000 | Program termination |
0x14 Digital Input Value to Register
Capture digital input values and save to a register.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 0025 | 00FF | Configure all digital IO pins as input |
001 | 14 | 001C | 0000 | Write digital input port value to register R1C |
002 | 00 | 0000 | 0000 | NOP |
003 | 0E | 0000 | 0001 | Return to line 001 for loop execution |
0x15 Bit Shift
Shift bits in a register left or right, with optional circular mode.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 0001 | 0001 | Write 1 to register R01 |
001 | 13 | 0001 | 0000 | Output value in R01 to register R01 |
002 | 02 | 0001 | 0001 | Delay 1 second |
003 | 15 | 1101 | 0001 | Circular left shift R01 by 1 bit |
004 | 0E | 0000 | 0001 | Return to line 001 for loop execution |
0x16 Bit Inversion
Reverse all bits in a register.
See 0x19 example below.
0x17 Bitwise AND
Bitwise AND of two registers, result stored in first register.
See 0x19 example below.
0x18 Bitwise OR
Bitwise OR of two registers, result stored in first register.
See 0x19 example below.
0x19 Bitwise XOR
Bitwise XOR of two registers, result stored in first register.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 0025 | 000F | Configure lower 4 digital IO pins as input |
001 | 10 | 0007 | 8009 | Write 8009 to register R07 |
002 | 10 | 0009 | FF00 | Write FF00 to register R09 |
003 | 0B | FF0E | 0010 | If digital input is 0x0E, jump to line 010 |
004 | 0B | FF0D | 0020 | If digital input is 0x0D, jump to line 020 |
005 | 0B | FF0B | 0030 | If digital input is 0x0B, jump to line 030 |
006 | 0B | FF07 | 0040 | If digital input is 0x07, jump to line 040 |
007 | 0E | 0000 | 0000 | Return to program start for loop execution |
010 | 16 | 0007 | 0000 | Invert all bits in R07 |
011 | 0E | 0000 | 0000 | Return to program start for loop execution |
020 | 17 | 0007 | 0009 | R07 AND R09, result stored in R07 |
021 | 0E | 0000 | 0000 | Return to program start for loop execution |
030 | 18 | 0007 | 0009 | R07 OR R09, result stored in R07 |
031 | 0E | 0000 | 0000 | Return to program start for loop execution |
040 | 19 | 0007 | 0009 | R07 XOR R09, result stored in R07 |
041 | 0E | 0000 | 0000 | Return to program start for loop execution |
0x1A Addition
Add two registers, result stored in first register.
See 0x1D example below.
0x1B Subtraction
Subtract two registers, result stored in first register.
See 0x1D example below.
0x1C Multiplication
Multiply two registers, result stored in first register.
See 0x1D example below.
0x1D Division
Divide two registers, result stored in first register.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 0025 | 000F | Configure lower 4 digital IO pins as input |
001 | 10 | 0006 | 0020 | Write 0020 to register R06 |
002 | 10 | 0008 | 1234 | Write 1234 to register R08 |
003 | 0B | FF0E | 0010 | If digital input is 0x0E, jump to line 010 |
004 | 0B | FF0D | 0020 | If digital input is 0x0D, jump to line 020 |
005 | 0B | FF0B | 0030 | If digital input is 0x0B, jump to line 030 |
006 | 0B | FF07 | 0040 | If digital input is 0x07, jump to line 040 |
007 | 0E | 0000 | 0000 | Return to program start for loop execution |
010 | 1A | 0008 | 0006 | Addition, result 0x1254 stored in R08 |
011 | 0E | 0000 | 0000 | Return to program start for loop execution |
020 | 1B | 0008 | 0006 | Subtraction, result 0x1214 stored in R08 |
021 | 0E | 0000 | 0000 | Return to program start for loop execution |
030 | 1C | 0008 | 0006 | Multiplication, result 0x4680 stored in R08 |
031 | 0E | 0000 | 0000 | Return to program start for loop execution |
040 | 1D | 0008 | 0006 | Division, result 0x91 stored in R08 |
041 | 0E | 0000 | 0000 | Return to program start for loop execution |
0x1E Modulo
Calculate remainder of two registers, result stored in first register.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 0006 | 0020 | Write 0020 to register R06 |
001 | 10 | 0008 | 1234 | Write 1234 to register R08 |
002 | 02 | 0001 | 0001 | Delay 1 second for viewing R08 changes |
003 | 1E | 0008 | 0006 | Modulo calculation, result stored in R08 |
004 | 0F | 0000 | 0000 | Program termination |
0x1F Random Number
Generate a random number and store it in the specified register.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 1F | 0005 | 0000 | Generate a random number in R05 |
001 | 02 | 0001 | 0001 | Delay 1 second |
002 | 0E | 0000 | 0000 | Return to program start for loop execution |
0x20 Byte Recombination
Recombine lower bytes of two registers, store in first register.
See 0x21 example below.
0x21 Byte Swap
Swap higher and lower bytes of a register.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 0025 | 000F | Configure lower 4 digital IO pins as input |
001 | 10 | 0005 | 2450 | Write 2450 to register R05 |
002 | 10 | 0006 | FF00 | Write FF00 to register R06 |
003 | 0B | FF0E | 0010 | If digital input is 0x0E, jump to line 010 |
004 | 0B | FF0D | 0020 | If digital input is 0x0D, jump to line 020 |
005 | 0E | 0000 | 0000 | Return to program start for loop execution |
010 | 20 | 0005 | 0006 | Recombine R05 and R06 lower bytes, store in R05 |
011 | 02 | 0001 | 0001 | Delay 1 second for viewing register result |
012 | 0E | 0000 | 0000 | Return to program start for loop execution |
020 | 21 | 0005 | 0000 | Swap higher and lower bytes of R05 |
021 | 02 | 0001 | 0001 | Delay 1 second for viewing register result |
022 | 0E | 0000 | 0000 | Return to program start for loop execution |
0x2A Addition with Literal
Add a literal value to a register, result stored in register.
See 0x2D example below.
0x2B Subtraction with Literal
Subtract a literal value from a register, result stored in register.
See 0x2D example below.
0x2C Multiplication with Literal
Multiply a register by a literal value, result stored in register.
See 0x2D example below.
0x2D Division with Literal
Divide a register by a literal value, result stored in register.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 0025 | 000F | Configure lower 4 digital IO pins as input |
001 | 10 | 0008 | 1234 | Write 1234 to register R08 |
002 | 0B | FF0E | 0010 | If digital input is 0x0E, jump to line 010 |
003 | 0B | FF0D | 0020 | If digital input is 0x0D, jump to line 020 |
004 | 0B | FF0B | 0030 | If digital input is 0x0B, jump to line 030 |
005 | 0B | FF07 | 0040 | If digital input is 0x07, jump to line 040 |
006 | 0E | 0000 | 0000 | Return to program start for loop execution |
010 | 2A | 0008 | 0020 | Addition, result 0x1254 stored in R08 |
011 | 0E | 0000 | 0000 | Return to program start for loop execution |
020 | 2B | 0008 | 0020 | Subtraction, result 0x1214 stored in R08 |
021 | 0E | 0000 | 0000 | Return to program start for loop execution |
030 | 2C | 0008 | 0020 | Multiplication, result 0x4680 stored in R08 |
031 | 0E | 0000 | 0000 | Return to program start for loop execution |
040 | 2D | 0008 | 0020 | Division, result 0x91 stored in R08 |
041 | 0E | 0000 | 0000 | Return to program start for loop execution |
0x2E Modulo with Literal
Calculate remainder of a register divided by a literal value, result stored in register.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 00 | 0000 | 0000 | No operation |
001 | 10 | 0008 | 1234 | Write 1234 to register R08 |
002 | 02 | 0001 | 0001 | Delay 1 second for viewing R08 changes |
003 | 2E | 0008 | 0020 | Modulo calculation, result stored in R08 |
004 | 0F | 0000 | 0000 | Program termination |
0x30 Convert Register to BCD Code
Convert the lower 8 bits of a register value to seven-segment display BCD code.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | C5 | 0001 | 0000 | Enable PCA9685 PWM signal generator |
001 | C6 | 0001 | 0000 | Enable DS1307 RTC clock module |
002 | 30 | 3E00 | 0000 | Convert register R3E decimal to BCD code |
003 | EA | 0000 | 0190 | Set PWM channel value to 0x0190 (range 0x0000-0x0FFF) |
004 | 16 | 0000 | 0000 | Invert all bits in R00 |
005 | EA | 0000 | 00C8 | Set PWM channel value to 0x00C8 (range 0x0000-0x0FFF) |
006 | 0E | 0000 | 0002 | Return to line 002 for continued execution |
0x32 Advanced Register Operations
Perform various operations on register pairs.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 0001 | 73E8 | Write 0x73E8 to R01 |
001 | 10 | 0002 | 1024 | Write 0x1024 to R02 |
002 | 10 | 0003 | 0000 | Write 0x0000 to R03 |
003 | 32 | 0300 | 0102 | R01 AND R02, result stored in R03 |
004 | 32 | 0301 | 0102 | R01 OR R02, result stored in R03 |
005 | 32 | 0302 | 0102 | R01 XOR R02, result stored in R03 |
006 | 32 | 0303 | 0102 | R01 + R02, result stored in R03 |
007 | 32 | 0304 | 0102 | R01 - R02, result stored in R03 |
008 | 32 | 0305 | 0102 | R01 × R02, result stored in R03 |
009 | 32 | 0306 | 0102 | R01 ÷ R02, result stored in R03 |
00A | 32 | 0307 | 0102 | R01 × R02, result stored in R03 |
00B | 32 | 0008 | 0102 | Write R02 value to R01, R03 not involved |
00C | 32 | 030B | 0102 | R01, R02 recombination, result stored in R03 |
00D | 32 | 000C | 0100 | R01 high/low byte swap |
00E | 32 | 030D | 0102 | R01 ÷ R02 remainder, result stored in R03 |
00F | 0F | 0000 | 0000 | Program termination |
0x55 Formatted Text Output
Output values in a specified format to the screen at designated location.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | C3 | 0001 | 0000 | Enable temperature and humidity sensor |
001 | 11 | 0001 | 002E | Copy temperature value R2E to R01 |
002 | 10 | 0028 | FFFF | Write 0xFFFF to R28 for color configuration |
003 | 55 | 0000 | 0122 | Format and output R01 value with 2 decimal places at position (0,0) |
004 | 02 | 03E8 | 0000 | Delay 1000 milliseconds |
005 | 10 | 0028 | 0210 | Write 0x0210 to R28 for color configuration |
006 | 5A | 0000 | FFFF | Draw a filled rectangle (0,0)-(255,255) |
007 | 0E | 0000 | 0000 | Write 0x0000 to R00 |
0x56 Display String
Display characters from consecutive registers in specified format.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | C3 | 0001 | 0000 | Enable temperature and humidity sensor |
001 | 10 | 0004 | 5465 | Write 0x5465 to R04 |
002 | 10 | 0005 | 6D70 | Write 0x6D70 to R05 |
003 | 10 | 0006 | 6572 | Write 0x6572 to R06 |
004 | 10 | 0007 | 6174 | Write 0x6174 to R07 |
005 | 10 | 0008 | 7572 | Write 0x7572 to R08 |
006 | 10 | 0009 | 653A | Write 0x653A to R09 |
007 | 10 | 0028 | FFFF | Write 0xFFFF to R28 for color configuration |
008 | 56 | 2020 | 040C | Display string from R04 in specified format |
009 | 02 | 03E8 | 0000 | Delay 1000 milliseconds |
00A | 10 | 0028 | 0210 | Write 0x0210 to R28 for color configuration |
00B | 5A | 0000 | FFFF | Draw a filled rectangle (0,0)-(255,255) |
00C | 0E | 0000 | 0000 | Write 0x0000 to R00 |
0x57 Draw Circle
Draw a hollow circle with specified center and radius.
See 0x5B example below.
0x58 Draw Filled Circle
Draw a filled circle with specified center and radius.
See 0x5B example below.
0x59 Draw Rectangle
Draw a hollow rectangle with specified diagonal vertices.
See 0x5B example below.
0x5A Draw Filled Rectangle
Draw a filled rectangle with specified diagonal vertices.
See 0x5B example below.
0x5B Draw Line
Draw a straight line between two specified points.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 0028 | 001F | Write 0x001F to R028 for color configuration |
001 | 57 | 2020 | 2000 | Draw a hollow circle |
002 | 10 | 0028 | 07E0 | Write 0x07E0 to R028 for color configuration |
003 | 58 | 7070 | 1000 | Draw a filled circle |
004 | 10 | 0028 | F100 | Write 0xF100 to R028 for color configuration |
005 | 59 | 3030 | 5580 | Draw a hollow rectangle |
006 | 10 | 0028 | 07FF | Write 0x07FF to R028 for color configuration |
007 | 5A | 1010 | 2020 | Draw a filled rectangle |
008 | 10 | 0028 | FFFF | Write 0xFFFF to R028 for color configuration |
009 | 5B | 6060 | 2020 | Draw a straight line |
00A | 0E | 0000 | 0000 | Return to line 000 |
0xAD Drawing Shapes (Comprehensive)
Comprehensive drawing program demonstrating various shapes.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | 10 | 0028 | 001F | Write 0x001F to R028 for color configuration |
001 | 57 | 2020 | 2000 | Draw a hollow circle |
002 | 10 | 0028 | 07E0 | Write 0x07E0 to R028 for color configuration |
003 | 58 | 7070 | 1000 | Draw a filled circle |
004 | 10 | 0028 | F100 | Write 0xF100 to R028 for color configuration |
005 | 59 | 3030 | 5580 | Draw a hollow rectangle |
006 | 10 | 0028 | 07FF | Write 0x07FF to R028 for color configuration |
007 | 5A | 1010 | 2020 | Draw a filled rectangle |
008 | 10 | 0028 | FFFF | Write 0xFFFF to R028 for color configuration |
009 | 5B | 6060 | 2020 | Draw a straight line |
00A | 0E | 0000 | 0000 | Return to line 000 |
0xC0 Activation Switches: Peripheral Modules
Enable/Disable peripherals in bitwise mode.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | C0 | 0000 | 085F | Enable ADC module |
001 | 0F | 0000 | 0000 | Program termination |
| Bit | Peripheral |
|---|---|
| 0 | ADC Conversion |
| 1 | Environment Sensor |
| 2 | Real Time Clock |
| 3 | Colour Sensor |
| 4 | External PWM Generator |
| 6 | Full Colour LED |
0xC1 Activation Switch: ADC Module
Enable or disable analog-to-digital conversion.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | C1 | 0001 | 0000 | Enable ADC module |
001 | AD | 0001 | 0005 | Save AD channel 1 value to register R05 |
002 | 01 | 00FF | 0000 | Turn off all LEDs |
003 | 02 | 0005 | FF00 | Delay by milliseconds value in R05 |
004 | 01 | 00FF | 0000 | Turn on all LEDs |
005 | 02 | 0005 | FF00 | Delay by milliseconds value in R05 |
006 | 0E | 0000 | 0001 | Return to line 001 |
0xC3 Activation Switch: Temperature and Humidity Sensor
Enable temperature and humidity sensor and display readings.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | C3 | 0001 | 0000 | Enable temperature and humidity sensor |
001 | 11 | 0001 | 002E | Copy temperature value from R2E to R01 |
002 | 10 | 0028 | FFFF | Write 0xFFFF to R28 for color configuration |
003 | 55 | 0000 | 0122 | Format and output R01 with 2 decimal places |
004 | 10 | 0028 | 0210 | Write 0x0210 to R28 for color configuration |
005 | 5A | 0000 | FFFF | Draw a filled rectangle (0,0)-(255,255) |
006 | 0E | 0000 | 0000 | Write 0x0000 to R00 |
0xC4 Activation Switch: Colour Sensor
Enable colour detection sensor and read RGB values.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | C4 | 0001 | 0000 | Enable colour sensor |
001 | E5 | 3101 | 0001 | Use high 8 bits of R31-R33 as RGB values |
002 | 0E | 0000 | 0001 | Return to line 001 for loop execution |
0xC8 Set On-board PWM Channel Duty Cycle
0xC5 Activation Switch: External PWM Generator
Enable external PWM generator and control PWM channels.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | C5 | 0001 | 0000 | Enable external PWM generator |
001 | C1 | 0001 | 0000 | Enable ADC module |
002 | 10 | 0000 | 0003 | Write 0x0003 to R0 |
003 | 10 | 0001 | 0019 | Write 0x0019 to R1 |
004 | AD | 0000 | 0002 | Assign AD channel 0 value to R02 |
005 | 1D | 0002 | 0001 | R02 divided by R01, quotient |
006 | 12 | 0002 | 00C8 | R02 value increases by 0x00C8 |
007 | 00 | 0000 | 0000 | No operation |
008 | EA | 0000 | 0002 | Write R02 value to PWM channel |
009 | 0E | 0000 | 0002 | Return to line 002 |
0xC6 Activation Switch: RTC Clock Module
Enable DS1307 RTC clock module and display time.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | C6 | 0001 | 0000 | Enable DS1307 RTC clock module |
001 | 13 | 003E | 0000 | Display lowest 4 bits of R3E on LED |
002 | 0E | 0000 | 0001 | Return to line 001 |
0xC8 Set Onboard PWM Channel Duty Cycle
Enable built-in PWM and set duty cycle.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | C0 | 0000 | 0000 | Enable built-in PWM, disable buzzer |
001 | C8 | 0001 | 03E8 | Set channel 1 PWM value to 1000 |
002 | 0E | 0000 | 0001 | Return to line 001 |
0xE4 Set Colour of an LED
Set colour of one WS2812B LED with RGB values.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | E4 | 00FF | 8000 | Set LED 0 RGB value, display orange |
001 | 02 | 0001 | 0001 | Delay 1 second |
002 | E4 | 00FF | 0000 | Set LED 0 RGB value, display red |
003 | 02 | 0001 | 0001 | Delay 1 second |
004 | E4 | 0000 | FF00 | Set LED 0 RGB value, display green |
005 | 02 | 0001 | 0001 | Delay 1 second |
006 | E4 | 0000 | 00FF | Set LED 0 RGB value, display blue |
007 | 0F | 0000 | 0000 | Program termination |
0xE5 Read Colour Sensor
Read RGB values from colour sensor.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | C4 | 0001 | 0000 | Enable colour sensor |
001 | E5 | 3101 | 0001 | Use high 8 bits of R31-R33 as RGB values |
002 | 0E | 0000 | 0001 | Return to line 001 for loop execution |
0xE8 Play a Tone
Play a tone from preset three octaves.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | C0 | 0000 | 0800 | Switch to buzzer mode |
001 | E8 | 000F | 0001 | Thirty-second note, high Do |
002 | E8 | 0000 | 0001 | Thirty-second rest |
003 | E8 | 000F | 0001 | Thirty-second note, high Do |
004 | E8 | 0011 | 0001 | Thirty-second note, high Mi |
005 | E8 | 0013 | 0001 | Thirty-second note, high Sol |
006 | 0F | 0000 | 0000 | Program termination |
| Range | Octave |
|---|---|
| 01~07 | Low Do~Si |
| 08~0E | Mid Do~Si |
| 0F~15 | High Do~Si |
| 00 | Rest |
| Value | Duration |
|---|---|
| 0000 | Sixty-fourth note |
| 0003 | Sixteenth note |
| 0005 | Eighth note |
| 0007 | Quarter note |
| 0008 | Half note |
| 0009 | Whole note |
0xEA PCA9685 Register Channel and Value
Write value to selected PCA9685 PWM channel.
| LINE | OPCODE | OP-0 | OP-1 | Remark |
|---|---|---|---|---|
000 | C5 | 0001 | 0000 | Enable external PWM generator |
001 | C1 | 0001 | 0000 | Enable ADC module |
002 | 10 | 0000 | 0003 | Write 0x0003 to R0 |
003 | 10 | 0001 | 0019 | Write 0x0019 to R1 |
004 | AD | 0000 | 0002 | Assign AD channel 0 value to R02 |
005 | 1D | 0002 | 0001 | R02 divided by R01, quotient |
006 | 12 | 0002 | 00C8 | R02 value increases by 0x00C8 |
007 | 00 | 0000 | 0000 | No operation |
008 | EA | 0000 | 0002 | Write R02 value to PWM channel |
009 | 0E | 0000 | 0002 | Return to line 002 |
| Parameter | Description |
|---|---|
| OP-0 | Specifies the register whose value is used to select channels by bit |
| OP-1 | Specifies the register whose value is used to set duty cycle |
Duty cycle is 12-bit, range 0000-0FFF. If R00 = 0x0003, channels 0 and 1 are configured. If R02 = 0x01FF, duty cycle ≈ 511/4095 ≈ 12.5%.