B04STAIRCASE
The task
Build a staircase on CH1: five steps from 0 to 5 volts, then start over.
Climb one step on each tick of P1. P0 is a PWM pin into R1 and C1.
The board
- Resistors
- R1 1 kΩ
- Capacitors
- C1 1 µF
- Probes
- CH1
Key idea
Each step is a quarter of the supply: 25 percent more duty.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
MOV B, A copies A into B, and MOV A, B copies it back, so B can hold the duty between ticks.
Hint 2Show
After 100 percent the next step is 0.
Solution
Reveal the Full SolutionThe complete program for STAIRCASE. Open it only when you want the answer.
The reference program
The game's own solution. It passes every test and scores exactly par on every benchmark.
u1SC-2 standard
MOV A, B
OUT P0
ADD 25
MOV B, A
SUB 125
JNZ W
MOV B, A
W: IN P1- CYCLES
- 72
- at par
- ENERGY
- 144
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 8
- at par
Another way: Mod
A second program that also passes, and beats par on CYCLES, ENERGY, and INSTRUCTIONS.
MOD 125 wraps the duty in one line.
u1SC-2 standard
MOV A, B
OUT P0
ADD 25
MOD 125
MOV B, A
IN P1- CYCLES
- 60
- under par
- ENERGY
- 120
- under par
- NODES
- 1
- at par
- INSTRUCTIONS
- 6
- under par