This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next 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 [2019/01/28 23:35] jfrench [Updating Pixy Library for Arduino] |
||
---|---|---|---|
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're using Arduino Due or Mega, 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! |