B53ZERO CROSS
The task
P0 reads a sine wave around 2.5 volts. P2 ticks every 10 cycles.
Flash the LED on P1 for one tick each time the wave crosses 2.5 volts on its way up,
and keep it dark the rest of the time.
The board
- Sources
- V1 2 V sine at 50 Hz and V2 2.5 V
- Resistors
- R1 330 Ω
- LEDs
- D1 yellow
- Probes
- CH1 and CH2
Key idea
Compare each sample with 50 percent, and remember in B whether the last one was below.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
A crossing is a sample at or above 50 right after one below it.
Hint 2Show
On a low sample, write 0 and set B to 1. On a high one, write B, then set B to 0.
Solution
Reveal the Full SolutionThe complete program for ZERO CROSS. 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.
Flash once each time the wave climbs through the middle.
u1SC-2 standard
L: IN P2
IN P0
SUB 50
JL LO
MOV A, B
OUT P1
MOV A, 0
MOV B, A
JMP L
LO: MOV A, 1
MOV B, A
MOV A, 0
OUT P1- CYCLES
- 676
- at par
- ENERGY
- 1352
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 13
- at par