B39PRESCALER
The task
V1 drives P0 with a fast square wave. Divide it by six for the LED on P1:
count the rising edges, and keep the LED lit for counts 3, 4, and 5 of every six.
Counts 0, 1, and 2 leave it dark. The first edge is count 1.
The board
- Sources
- V1 5 V square at 250 Hz
- Resistors
- R1 330 Ω
- LEDs
- D1 green
- Probes
- CH1 and CH2
Key idea
A rising edge is a 1 read after a 0: wait out the high, then wait for the next one.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Keep the count in B. MOD 6 brings it back to 0 after 5.
Hint 2Show
DIV 3 turns counts 0 to 2 into 0 and counts 3 to 5 into 1.
Solution
Reveal the Full SolutionThe complete program for PRESCALER. 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.
The LED runs at one sixth of the input.
u1SC-2 standard
L: IN P0
JNZ L
H: IN P0
JZ H
MOV A, B
ADD 1
MOD 6
MOV B, A
DIV 3
OUT P1- CYCLES
- 720
- at par
- ENERGY
- 1440
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 10
- at par