<< return to Pixycam.com

Arduino Pixy.close(); I can’t use the command

hi, i can’t end connection with Pixy on arduino.
To the command line Pixy.close(); I am writing as
I am getting such an error.

error: ‘Pixy {aka class TPixy}’ has no member named ‘close’
exit status 1
‘Pixy {aka class TPixy}’ has no member named ‘close’

@edge @freed

Can you help me please ??
@edge @freed

There is no close method for the Pixy2 class. It will close the link in the destructor.

You should be able to do this however if it’s important for what you’re doing (?), but it’s not necessary

pixy.m_link.close(); // pixy is the Pixy2 object


I am using original pixy, not pixy2.
When the robot arm is activated in my project, it repeats as much as the number of objects I introduce. So I introduce an object, I get the object with robot arm but then it works again when the object is not present. I did this by introducing 3 objects. This time, it takes the object when there is an object on the screen, and then reactivates the robot arm 3 times when there is no object on the screen. I never understood why. I thought the solution was to disable the camera.
I need to disable camera after robot arm codes.
It’s really important to me. I didn’t quite understand what you mean. I need help. I took a look at the Pixy source code, but there seems to be such a command.
@edge @freed

I’m considering re-enable it anywhere with the pixy.init(); code.
Is this possible ??
@edge @freed

Hi @Robotikman,

it sounds like you’re wanting to prevent the robot arm from moving when there are no objects on the screen. To do this, you’re trying to stop the video / data feed from Pixy. And you’re using original Pixy. Is that right?

You can write some code to do nothing when Pixy does not detect any objects (adapted from the Arduino “hello world” code in the Pixy library):

blocks = pixy.getBlocks();
if (blocks)
{ // do something }
else if (!blocks)
{ // do nothing }

If you’re getting false positives (like Pixy detecting objects when there are none in the view of the camera) then you might try tweaking the Signature Tuning sliders as described here: https://docs.pixycam.com/wiki/doku.php?id=wiki:v1:some_tips_on_generating_color_signatures_2

Hope this helps!


No, sir. I guess I didn’t express myself correctly. I already use the codes you mentioned in any part of the program. I need to disconnect the pixy from the arduino. I just have to do this. There is no other way around this. I have adjusted the signature settings you mentioned very well and there is no problem in this regard. I tried a lot and there is no problem with my codes.

Pixy.close(); I need to be able to use your code.

@edge @freed

There is no close in the Pixy1 Arduino library. You may need to modify the source code:

Here is the SPI interface code:

You will need to add a call to end().

How it gets called is up to you. It may be possible to include SPI.h and call it directly without modifying the Pixy Arduino library.

Hope this helps.


I didn’t understand any of these.
I don’t think I can do what you say.
Also, for some reason, I cannot log in to your www.cmucam.org page.
That’s a separate thread, but unfortunately that didn’t help me.

@edge @freed

Unfortunately, what you are trying to do requires some modifying of code. Perhaps a friend can help.


So I can’t do that ?? What I want is actually something very simple isn’t it ??
Why isn’t such a code added ?? It actually exists, but we don’t know how to use it.
Original Pixy first version. Pixy.close();
If anyone knows, I’m waiting for your help. Thank you.

@edge @freed