<< return to Pixycam.com

User Tools

Site Tools


wiki:v2:hooking_up_pixy_to_a_microcontroller_-28like_an_arduino-29

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
wiki:v2:hooking_up_pixy_to_a_microcontroller_-28like_an_arduino-29 [2018/05/23 20:57]
pixycam [Arduino API]
wiki:v2:hooking_up_pixy_to_a_microcontroller_-28like_an_arduino-29 [2020/09/18 00:52] (current)
jfrench [Troubleshooting]
Line 17: Line 17:
 {{wiki:​v2:​img_5257_result.jpg?​400}} {{wiki:​v2:​img_5257_result.jpg?​400}}
  
-Next, download the latest Arduino library "​arduino\_pixy2-x.y.z.zip"​ [[wiki:v2:​Latest_release|here]]. Bring up the Arduino IDE and import the Pixy library by selecting **Sketch➜Include Library➜Add .ZIP Library...** (or if you're using an older version **Sketch➜Import Library**) in the Arduino IDE, and then browsing to the Arduino zip file that you just downloaded.+Next, download the latest Arduino library "​arduino\_pixy2-x.y.z.zip"​ [[https://​pixycam.com/​downloads-pixy2/​|here]]. Bring up the Arduino IDE and import the Pixy library by selecting **Sketch➜Include Library➜Add .ZIP Library...** (or if you're using an older version **Sketch➜Import Library**) in the Arduino IDE, and then browsing to the Arduino zip file that you just downloaded.
  
-Next, load the "ccc_hello_world" example by selecting it in **File➜Examples➜Pixy2**. Upload it and bring up the **Serial Monitor**. You should see messages printed that look similar to this:+Next, load the "ccc\_hello\_world" example by selecting it in **File➜Examples➜Pixy2**. Upload it and bring up the **Serial Monitor** which can be found in **Tools➜Serial Monitor**. ​Also be sure to set the Serial Monitor baud rate to 115200 baud, which is selectable at the bottom of the Serial Monitor window. ​  
 + 
 + 
 +{{wiki:​v2:​image_521.png}} 
 + 
 + 
 +You should see messages printed ​in the Serial Monitor window ​that look similar to this:
  
 <​code>​ <​code>​
Line 62: Line 68:
   * ''​%%pixy.ccc.blocks[i].m_height%%''​ The height of the detected object (1 to 208)   * ''​%%pixy.ccc.blocks[i].m_height%%''​ The height of the detected object (1 to 208)
   * ''​%%pixy.ccc.blocks[i].m_angle%%''​ The angle of the object detected object if the detected object is a [[wiki:​v2:​Using_Color_Codes|color code]] (-180 to 180).   * ''​%%pixy.ccc.blocks[i].m_angle%%''​ The angle of the object detected object if the detected object is a [[wiki:​v2:​Using_Color_Codes|color code]] (-180 to 180).
-  * ''​%%pixy.ccc.blocks[i].m_index%%''​ The [[wiki:​v2:​color_connected_components#​Pixy2 "​tracks"​ each object it detects|tracking index]] of the block  +  * ''​%%pixy.ccc.blocks[i].m_index%%''​ The [[wiki:​v2:​color_connected_components#​Pixy2 "​tracks"​ each object it detects|tracking index]] of the block 
-  * ''​%%pixy.ccc.blocks[i].m_age%%''​ The number of frames the block has been tracked. ​ +  * ''​%%pixy.ccc.blocks[i].m_age%%''​ The number of frames the block has been tracked.
   * ''​%%pixy.ccc.blocks[i].print()%%''​ A member function that prints the detected object information to the serial port   * ''​%%pixy.ccc.blocks[i].print()%%''​ A member function that prints the detected object information to the serial port
 +
  
 So it's simple to talk to Pixy2 with your Arduino! For more information on the Arduino Library and API, go [[wiki:​v2:​Arduino_API|here]]. So it's simple to talk to Pixy2 with your Arduino! For more information on the Arduino Library and API, go [[wiki:​v2:​Arduino_API|here]].
Line 73: Line 80:
 Before installing a new version of the Arduino Library, it's recommended that you delete the existing library. To do this, you can go into your C:​\Users\<​yourname>​\Documents\Arduino\libraries (or similar directory, <​yourname>/​Documents/​Arduino in OSX and Linux) and remove the Pixy2 directory. Then re-run the Arduino IDE. Before installing a new version of the Arduino Library, it's recommended that you delete the existing library. To do this, you can go into your C:​\Users\<​yourname>​\Documents\Arduino\libraries (or similar directory, <​yourname>/​Documents/​Arduino in OSX and Linux) and remove the Pixy2 directory. Then re-run the Arduino IDE.
  
 +
 +==== Troubleshooting ====
 +
 +If you get the message "​error:​ no response"​ from the Arduino serial monitor, first make sure your Pixy2 is running the ccc (color connected components) program from PixyMon, and that you have taught it an object as described [[wiki:​v2:​teach_pixy_an_object_2|here]].
 +
 +{{:​wiki:​v2:​error_no_response.png?​600|}}
 +
 +=== Using Arduino with other devices ===
 +If you're having problems with parts of your program not working, and you're using motors or something else connected to the Arduino pins, make sure that your other devices aren't connected to pins 10, 11, 12, or 13. Pixy2 uses those pins for communicating with Arduino.
  
  
 +=== Zumo Errors ===
 +If you're using Arduino Due, you may get an error like this when compiling:
  
 +''​libraries\Pixy2\ZumoBuzzer.cpp:​90:​5:​ error: expected constructor,​ destructor, or type conversion before '​('​ token''​
  
 +In that case, just go into your Pixy library and delete the following 4 files:
  
 +{{:​wiki:​v2:​todelete.png}}
  
 +It should then compile!
wiki/v2/hooking_up_pixy_to_a_microcontroller_-28like_an_arduino-29.1527109041.txt.gz · Last modified: 2018/05/23 20:57 by pixycam