<< return to Pixycam.com

Pixy2 with mBot


I’ve recently purchased a Pixy2 to try out. I also have an mBot v1.1 and will look at connecting the two once I am a bit more familiar with the Pixy2. However, I am interested in whether anyone else has successfully connected the two already.

I’ve found an example with the original Pixy:

Would connection between Pixy2 and mBot follow a similar approach?

1 Like

No replies but I’ve been able to work this out. I’ve used the SPI cable to connect the Pixy2 to an mBot.

Some links I found helpful for this (they are for Pixy1 but connection is the same)

I wanted my kids to be able to use the mBlock interface to code for the Pixy2. I found that an extension has been provided for Pixy1 which, although not compatible, is a useful starter on how to build them. Using the following guide (http://download.makeblock.com/mblock/mblock_extension_guide.pdf), we’ve started to create an extension for Pixy2 functions. We’ve got a couple of functions working as blocks in mBlock (e.g. getBlocks and setLamp) so will publish once a few more are ready.


Hi Grant,
Sorry that no one replied to your original inquiry. Thanks for sharing your findings and congrats getting it working! It looks like really solid and useful work :slight_smile:

Keep us informed on how this project progresses!


For anyone who is interested in using the mBlock (Scratch-based) environment to access a Pixy2, I created an extension to add Pixy2 blocks for this environment. Here is the description and the package:

To add in mBlock:

  • Select Extensions -> Manage Extensions
  • Search for ‘pixy2cam_spi’ and Download the extension

If this doesn’t work for some reason, you can download the zip file from GitHub and upload directly via the ‘Add Extension’ button.

Here is an example of what it looks like in the environment:

We’ve tried this using a Makeblock mBot and a generic Arduino Uno. It makes the Pixy2 features more accessible for junior coders who are yet to make the leap to text-based programming.

I haven’t implemented the full API as we only need a subset but you can let me know if you need more for your project and I can try to help.

Hi Grant,
Nice! Thanks so much for sharing! We’ll give it a try here as well :slight_smile:


Thank you. I am very grateful for your work. By the way, there is one point I was worried about. It’s about pan and tilt settings.

pixy.setServos((uint8_t) 500,(uint8_t) 800)

Pan-tilt is crazy with uint8. It becomes stable if it makes it “uint16”. how about that?
My English is unfamiliar. Please understand.

Well, setServos requires a 16-bit value.


If you send an 8 bit value, you’re not going to be able to send the correct value. Does that make sense?

Thanks Kazuya for pointing this out and great that someone is getting some use of what I did. You’re English is certainly good enough to have explained the issue so I understand.

Also, thanks for Edward for confirming this. It was my mistake. I added the servo function to the library but didn’t test it that well as we didn’t need it for our project. I’ll update soon, hopefully this weekend, and re-publish a corrected version.

I’ve updated the extension to fix the data type on setServos BUT I don’t have a pan/tilt assembled to check it. Please try and let me know if OK or not: