<< return to Pixycam.com

Pixy to 16*2 lcd

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);
}
}
}
}

Hello,
There are lots of LCDs out there, so it’s difficult to tell why your code may not be working.

Have you been able to get the LCD working without Pixy?

Edward

My 16*2 LCD is working properly without LCD. But in my code initialising pixy makes LCD improper.

Hello Sai,
(Please use 1 thread for a given question/issue – thanks!)

It’s possible that your LCD uses your Arduino’s SPI port, in which case, it will interfere with Pixy, which also uses the SPI port.

If so, you might consider using a different LCD (that doesn’t use the SPI port), or use a different port for Pixy (I2C or UART)

This page has some information about the other serial ports. The main required task when using a different serial port is making a custom cable. This page has details on the different ports, pin-outs and how to connect:

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide

There is an Arduino example that uses I2C or UART called “ccc_i2c_uart”.

Hope this helps!

Edward