Program utama test puxt cmucam5 di stm32f446re

Dependencies:   mbed

Fork of PIXY_KRPAI_ITB by Achmad Fathoni

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "Pixy.h"
00003 
00004 Pixy pixy(Pixy::SPI, PB_5, PB_4, PB_3);
00005 Serial pc(USBTX, USBRX);
00006 
00007 int main() {
00008     pixy.setSerialOutput(&pc);
00009     pc.printf("Hello World!\n\r");
00010     while (1) {
00011         wait(0.5);
00012         static int i = 0;
00013         int j;
00014         uint16_t blocks;
00015   
00016         blocks = pixy.getBlocks();
00017   
00018         if (blocks) {
00019             i++;
00020                 
00021                 pc.printf("Detected %d:\n\r", blocks);
00022                 pc.printf("\n\r");
00023                 for (j = 0; j < blocks; j++) {
00024                     pc.printf("  block %d: \n\r", j);
00025                     //pixy.blocks[j].print(pc);
00026                     pc.printf("%d cm\n\r",pixy.blocks[j].width/6);
00027                 }
00028             
00029         }
00030     }  
00031 }