The code should now be running! Try tilting around the CPX and see if the mouse moves.

Head to our Scratch program, enter full screen and test it out!

  • Tilting the CPX moves around the pen.
  • Clicking button A on the CPX changes colors.
  • Shaking the CPX erases the picture.


  • If the pen in scratch is acting glitchy as you tilt the CPX around, try decreasing the value of stepSize.
  • Head here to troubleshoot MakeCode issues.
  • For CPX related issues head here.
  • Head to the Scratch Wiki to troubleshoot Scratch related issues.

What will you create next?

How can you modify what we created to make something even cooler? What other sensors on the CPX could we use to add more effects with the pen in Scratch? 

Happy Hacking!

This guide was first published on Jan 18, 2019. It was last updated on Mar 08, 2024.

This page (Putting it All Together) was last updated on Mar 08, 2024.

Text editor powered by tinymce.