A demo setup of the "Pan/Tilt Demo" code. This demo code uses the default setup of the Pixy servo motor control to follow Block 0 signature defined on the Pixy camera using the PixyMon software. Demo can be found here: https://www.youtube.com/watch?v=6D5IQyrFocU https://developer.mbed.org/users/swilkins8/notebook/cmucam5-pixy/
Dependencies: mbed TPixy-Interface
main.cpp@1:b05954fae6d8, 2020-11-17 (annotated)
- Committer:
- michelmoulin
- Date:
- Tue Nov 17 17:06:06 2020 +0000
- Revision:
- 1:b05954fae6d8
- Parent:
- 0:886deae63aa3
Ce pg affiche les coordonnees x et y du block detecte par la pixy
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
michelmoulin | 1:b05954fae6d8 | 1 | |
michelmoulin | 1:b05954fae6d8 | 2 | /* 17/11/20 : Ce pg affiche les coordonnées x et y du block détecté par la pixy */ |
swilkins8 | 0:886deae63aa3 | 3 | #include "Pixy.h" |
swilkins8 | 0:886deae63aa3 | 4 | |
swilkins8 | 0:886deae63aa3 | 5 | Serial serial(USBTX, USBRX); |
michelmoulin | 1:b05954fae6d8 | 6 | SPI spi(PC_12, PC_11, PC_10); // mosi, miso, clk du SPI3 |
swilkins8 | 0:886deae63aa3 | 7 | PixySPI pixy(&spi, &serial); |
swilkins8 | 0:886deae63aa3 | 8 | |
swilkins8 | 0:886deae63aa3 | 9 | int main() |
swilkins8 | 0:886deae63aa3 | 10 | { |
michelmoulin | 1:b05954fae6d8 | 11 | uint16_t blocks; |
michelmoulin | 1:b05954fae6d8 | 12 | serial.printf("debut....\n\r"); |
michelmoulin | 1:b05954fae6d8 | 13 | spi.frequency(1000000); |
michelmoulin | 1:b05954fae6d8 | 14 | while(1) |
michelmoulin | 1:b05954fae6d8 | 15 | { |
michelmoulin | 1:b05954fae6d8 | 16 | serial.printf("nouvel essai : "); |
michelmoulin | 1:b05954fae6d8 | 17 | blocks = pixy.getBlocks(); |
michelmoulin | 1:b05954fae6d8 | 18 | if (blocks) |
michelmoulin | 1:b05954fae6d8 | 19 | { |
michelmoulin | 1:b05954fae6d8 | 20 | serial.printf("Detected %d : ", blocks); |
michelmoulin | 1:b05954fae6d8 | 21 | serial.printf("x=%d, y=%d \n\r",pixy.blocks[0].x,pixy.blocks[0].y); |
michelmoulin | 1:b05954fae6d8 | 22 | } |
michelmoulin | 1:b05954fae6d8 | 23 | wait(1); |
michelmoulin | 1:b05954fae6d8 | 24 | } |
swilkins8 | 0:886deae63aa3 | 25 | } |