Guest User

Arduino Due PIxy i2c

a guest
Jun 1st, 2014
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <PixyI2C.h>
  3.  
  4. PixyI2C pixy;
  5.  
  6. void setup()
  7. {
  8.   Wire.begin();
  9.   Serial.begin(9600);
  10.   Serial.print("Starting...\n");
  11. }
  12.  
  13. void loop()
  14. {
  15.   static int i = 0;
  16.   int j;
  17.   uint16_t blocks;
  18.   char buf[32];
  19.  
  20.   blocks = pixy.getBlocks();
  21.  
  22.   if (blocks)
  23.   {
  24.     i++;
  25.    
  26.     if (i%50==0)
  27.     {
  28.       sprintf(buf, "Detected %d:\n", blocks);
  29.       Serial.print(buf);
  30.       for (j=0; j<blocks; j++)
  31.       {
  32.         sprintf(buf, "  block %d: ", j);
  33.         Serial.print(buf);
  34.         pixy.blocks[j].print();
  35.       }
  36.     }
  37.   }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment