B52UPHILL
The task
P0 reads a sine wave. On each tick of P2, compare the reading with the one before.
Light the LED on P1 while the wave is rising, and keep it dark while it falls.
The board
- Sources
- V1 2 V sine at 25 Hz and V2 2.5 V
- Resistors
- R1 330 Ω
- LEDs
- D1 green
- Probes
- CH1 and CH2
Key idea
XCH swaps A and B, so B can hold the newest reading while A gets the old one.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
The old reading minus the new one is below 0 when the wave climbs.
Hint 2Show
JL takes the rising case. Anything else must become 0.
Solution
Reveal the Full SolutionThe complete program for UPHILL. 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 lights while the wave climbs.
u1SC-2 standard
IN P2
IN P0
XCH
SUB B
JL ON
MOV A, 0
ON: OUT P1- CYCLES
- 255
- at par
- ENERGY
- 510
- at par
- NODES
- 1
- at par
- INSTRUCTIONS
- 7
- at par