If you used an eyeball and are going for a scary theme, as I did with mine, you might like this Servo Youkai code—download it below.
Project60123-Servo-Youkai.svg [1]
The code’s first task is to initialize the RGB LEDs. The rest of the code is in a repeat forever block.
This outermost infinite loop holds a repeat while check pin 3 block that monitors the PIR sensor. If motion is detected the PIR sends a high signal, and so this block returns a 1 (true) and the loop executes.
Once the PIR sensor detects motion, the first task is to set a color for the RGB LEDs, and then use the RGB-LED update block to turn them on. (It is really easy to forget that block and suspect your wiring job for no reason...)
Next, a repeat item block counts from 45 to 135 using a variable named up. The value of up increments the servo angles to swivel hips and shoulders. A frequency block scales the value of up into an audible range for the speaker, sending the signal to P26 (D/A 0 socket).
Then, another repeat item loop does much the same thing with a variable named down. This time however, down is subtracted from 180 to set the servo angles, so they start at 135 where they left off in the previous loop. Likewise, the frequency block both scales the value of down and subtracts it from 3375, the maximum frequency reached in the previous repeat item loop.
If the PIR sensor is no longer sensing motion, code execution exits the repeat while loop. Then the RGB-LED set and RGB-LED update blocks turn off the Neopixel ring. Your Servo Spirit is still, quiet, and dark until it senses motion again.
Links
[1] https://learn.parallax.com/sites/default/files/content/AB-Blockly/Projects/Servo-Youkai/Project60123-Servo-Youkai.svg