In a project I am trying to print x,y position of detected object in LCD using Arduino. After intialising pixy the data is not printing in lcd but before initialising pixy the data is printed to LCD. What is the problem. I think connecting pixy and LCD to Arduino at a time is the problem. Help me with the code. The code is shown below,
#include <SPI.h>
#include <Pixy.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
Pixy pixy;
void setup()
{
Serial.begin(9600);
Serial.print(“Starting…\n”);
lcd.begin(16,2);
pixy.init();
}
void loop()
{
static int i = 0;
uint16_t blocks;
char buf[32];
blocks = pixy.getBlocks();
if (blocks)
{
i++;
if (i%50==0)
{
if(pixy.blocks[0].signature==1)
{
sprintf(buf, “X:POSITION: %d\n”,pixy.blocks[0].x);
Serial.print(buf);
lcd.print(buf);
}
}
}
}