Shenzhen I/O: Fake Surveillance Camera

The very first challenge we get in Shenzhen IO is to make some LEDs blink on a fake security camera. We have just been hired by Shenzhen Longteng Electronics CO. Ltd and we are taking on an old project we are taking over from a guy who quit. The camera has two LEDs called “active” and “network” and we should design and code the solution to make them blink in this pattern

 

The problem looks like this when it is given to us. So the active LED is already solved.

The programming starts out really simple, and as you can also see in the manual (which you really should print), we are using two instructions.

mov R/I R – which is an instruction to move a register (R) or Integer (I) to a register. But not the pins are considered registers as well

slp R/I – Pause the program execution for the number of units given by the register or integer.

So the first MC4000 is instructed to send a 0 to p0, sleep for 6 units, send 100 to p0 and sleep again. And then repeat.

First solution

In order to program a solution for the network, we need a new MC4000 microcontroller and some lines of code.

  mov 0 p0
  slp 4
  mov 100 p0
  slp 2
  mov 0 p0
  slp 1
  mov 100 p0
  slp 1

We simply move either 0 (off) or 100 (on) the the p0 pin to control the light, and then sleep for whatever duration the light needs to be in that state. When we run a simulation of the system, it unsurprisingly works as expected. First assignment complete!

This makes the solution look like

 

Second solution

There is an alternative solution to the one I just described, but if you are new to the game, these instructions have not been given to you yet. But there are two instructions that will be

which tells the micro controller to only execute this on the first run.

gen R I/R I/R – which generates a pulse on the register in the first argument for the duration in the second argument and then sleep for the length of the third argument.

For the second new command we could write

  gen p0 2 3

which is equivalent to the commands

  mov 100 p0
  slp 2 
  mov 0 p0
  slp 3

Given these two instructions we can limit the solution to

It costs the same, but has fewer lines of code and a slightly reduced power profile.

I have been playing around to see if I could wire the network to p1 on the first controller, but I cannot cross from one board to the next. So I don’t think that is possible.

Posted by Kristian

Leave a Reply