Regarding programming an arduino uno and Pixy Cam errors in code

Hi I’m currently trying to run a XiaoR Geek tank robot with an Arduino Uno, an adafruit motorshield v2.3, and PixyCam 2. I’m having trouble getting the code to end up running although some of the things are just some things I have declared wrong I believe. Other than that I’m confused on what some of the errors are. I’ve attached the file with the code and then posted the error messages in here that I’m having issues with.

Here are my current error messages

Arduino: 1.6.5 (Windows 7), Board: "Arduino/Genuino Uno"

In file included from sketch_apr30a.ino:9:0:
H:\Documents\Arduino\libraries\Pixy2/Pixy2UART.h: In member function 'int8_t Link2UART::open(uint32_t)':
H:\Documents\Arduino\libraries\Pixy2/Pixy2UART.h:32:7: error: 'Serial1' was not declared in this scope
       Serial1.begin(PIXY_UART_BAUDRATE);
       ^
H:\Documents\Arduino\libraries\Pixy2/Pixy2UART.h:34:7: error: 'Serial1' was not declared in this scope
       Serial1.begin(arg);      
       ^
H:\Documents\Arduino\libraries\Pixy2/Pixy2UART.h: In member function 'int16_t Link2UART::recv(uint8_t*, uint8_t, uint16_t*)':
H:\Documents\Arduino\libraries\Pixy2/Pixy2UART.h:56:10: error: 'Serial1' was not declared in this scope
      c = Serial1.read();
          ^
H:\Documents\Arduino\libraries\Pixy2/Pixy2UART.h: In member function 'int16_t Link2UART::send(uint8_t*, uint8_t)':
H:\Documents\Arduino\libraries\Pixy2/Pixy2UART.h:71:5: error: 'Serial1' was not declared in this scope
     Serial1.write(buf, len);
     ^
sketch_apr30a.ino: In function 'void setup()':
sketch_apr30a:100: error: request for member 'setSpeed' in 'leftMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:101: error: request for member 'setSpeed' in 'rightMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:103: error: 'motor1' was not declared in this scope
sketch_apr30a.ino: In function 'void loop()':
sketch_apr30a:115: error: 'pixy' was not declared in this scope
sketch_apr30a:126: error: request for member 'setSpeed' in 'leftMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:127: error: request for member 'run' in 'leftMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:129: error: request for member 'setSpeed' in 'rightMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:130: error: request for member 'run' in 'rightMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a.ino: In function 'int TrackBlock(int)':
sketch_apr30a:152: error: 'pixy' was not declared in this scope
sketch_apr30a:163: error: 'pixy' was not declared in this scope
sketch_apr30a:171: error: 'Pixy2' has no member named 'blocks'
sketch_apr30a:172: error: 'Pixy2' has no member named 'blocks'
sketch_apr30a:173: error: 'Pixy2' has no member named 'blocks'
sketch_apr30a.ino: In function 'void FollowBlock(int)':
sketch_apr30a:191: error: 'Pixy2' has no member named 'blocks'
sketch_apr30a:191: error: 'Pixy2' has no member named 'blocks'
sketch_apr30a:205: error: request for member 'setSpeed' in 'leftMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:206: error: request for member 'setSpeed' in 'rightMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a.ino: In function 'void ScanForBlocks()':
sketch_apr30a:230: error: request for member 'run' in 'leftMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:232: error: request for member 'run' in 'rightMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:237: error: request for member 'run' in 'leftMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:239: error: request for member 'run' in 'rightMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
request for member 'setSpeed' in 'leftMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

I’m not understanding what these errors really entail and I’ve managed to fix everything up to now but am currently stuck, any and all help would be appreciated.

sketch_apr30a.ino (5.94 KB)

I'm currently trying to run a XiaoR Geek tank robot with an Arduino Uno

From the error message and looking at Pixy2UART.h you can see that the library is trying to use Serial1 on the Arduino but the Uno does not have a Serial1 port, hence the error.

My knowledge of Pixy2 ends at that point !

Thanks for the input, I'm seeing online that there is a serial port which can be Serial.begin not serial1.begin, could I just change that in the library? I don't believe this motor shield will work for a mega and I already have the shield soldered on

As I said, I have reached my the end of my knowledge of Pixy2.

Others may know more

Thank you for the help!

See the description of the Pixy2UART library class (from comments at top of code, probably elsewhere in their documentation:

// Arduino UART link class, intended to be used with an Arduino with more than 1 UART, 
// like the Arduino MEGA 2560.

That's why it's trying to use Serial1, which is what the second UART would be called (it's Serial for UART0, Serial1 for UART1, and so on. The Mega2560 has 4 UARTs. Third party boards based on ATmega1284p (sanguino, bobuino, mighty 1284, etc) have 2 UARTs. The ATTiny441/841/1634 also have 2 UARTs, but they have limited flash, and may not be a good fit for this application. Micro/Leo uses "Serial" for the USB-serial virtual port, and Serial1 for it's only hardware UART, so that would work too. Third party boards based on the atmega328p*b* will also work, as it's got 2 serial ports. Finally, the ARM-based Arduino and Arduino-compatible boards all have multiple serial ports (as far as I know). I think the ESP32 does as well.

The Arduino Uno does not have more than one serial port, so that library will not work without modification - and since the one serial port that the uno does have is used for uploading, you would have to disconnect the camera from those pins while uploading code if you went ahead and modified the library to use Serial, and you could not use the serial monitor to send commands, nor to print debug information, without interfering with operation of the Pixy. Which is why the library doesn't support this in the first place - the user experience will kinda suck!

It looks like the Pixy2 supports other modes of communication (SPI, I2C) - can either of those be used?

I’ve switched out for an arduino mega 2560 and it cleared that issue for me I’m still left stuck with these errors. Do I need to just add arrows instead of a star? I’m guessing that no blocks declared means I do not have an image declared for the pixy cam?

Arduino: 1.6.5 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

sketch_apr30a.ino: In function 'void setup()':
sketch_apr30a:96: error: request for member 'setSpeed' in 'leftMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:97: error: request for member 'setSpeed' in 'rightMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:99: error: request for member 'run' in 'leftMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:100: error: request for member 'run' in 'rightMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a.ino: In function 'void loop()':
sketch_apr30a:111: error: 'Pixy2' has no member named 'getBlocks'
sketch_apr30a:122: error: request for member 'setSpeed' in 'leftMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:123: error: request for member 'run' in 'leftMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:125: error: request for member 'setSpeed' in 'rightMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:126: error: request for member 'run' in 'rightMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a.ino: In function 'int TrackBlock(int)':
sketch_apr30a:148: error: 'Pixy2' has no member named 'blocks'
sketch_apr30a:150: error: 'Pixy2' has no member named 'blocks'
sketch_apr30a:150: error: 'pixy' was not declared in this scope
sketch_apr30a:159: error: 'pixy' was not declared in this scope
sketch_apr30a:167: error: 'Pixy2' has no member named 'blocks'
sketch_apr30a:168: error: 'Pixy2' has no member named 'blocks'
sketch_apr30a:169: error: 'Pixy2' has no member named 'blocks'
sketch_apr30a.ino: In function 'void FollowBlock(int)':
sketch_apr30a:187: error: 'Pixy2' has no member named 'blocks'
sketch_apr30a:187: error: 'Pixy2' has no member named 'blocks'
sketch_apr30a:201: error: request for member 'setSpeed' in 'leftMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:202: error: request for member 'setSpeed' in 'rightMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a.ino: In function 'void ScanForBlocks()':
sketch_apr30a:226: error: request for member 'run' in 'leftMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:228: error: request for member 'run' in 'rightMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:233: error: request for member 'run' in 'leftMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
sketch_apr30a:235: error: request for member 'run' in 'rightMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)
request for member 'setSpeed' in 'leftMotor', which is of pointer type 'Adafruit_DCMotor*' (maybe you meant to use '->' ?)

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

I’ve fixed almost all of my issues with my code for a RC car using a pixy2cam and arduino Mega 2560. I can’t find anything about what to use instead of a getBlocks command to tell the program to get the Object to go to the RC and from what I’ve seen elsewhere they used the get blocks command. Attached are the sketch and error messages, any help would be hugely appreciated, thank you.

Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Build options changed, rebuilding all
C:\Users\gabe0\Downloads\sketch_apr30a\sketch_apr30a.ino: In function 'void loop()':

sketch_apr30a:112:19: error: 'Pixy2 {aka class TPixy2<Link2SPI>}' has no member named 'getBlocks'

  ; blocks = pixy2.getBlocks();

                   ^

C:\Users\gabe0\Downloads\sketch_apr30a\sketch_apr30a.ino: In function 'int TrackBlock(int)':

sketch_apr30a:149:39: error: 'Pixy2 {aka class TPixy2<Link2SPI>}' has no member named 'blocks'

     if ((oldSignature == 0) || (pixy2.blocks[i].signature == oldSignature))

                                       ^

sketch_apr30a:151:28: error: 'Pixy2 {aka class TPixy2<Link2SPI>}' has no member named 'blocks'

       long newSize = pixy2.blocks[i].height -> pixy.blocks[i].width;

                            ^

sketch_apr30a:160:39: error: 'Pixy2 {aka class TPixy2<Link2SPI>}' has no member named 'blocks'

   int32_t panError = X_CENTER - pixy2.blocks[trackedBlock].x;

                                       ^

sketch_apr30a:161:29: error: 'Pixy2 {aka class TPixy2<Link2SPI>}' has no member named 'blocks'

   int32_t tiltError = pixy2.blocks[trackedBlock].y - Y_CENTER;

                             ^

sketch_apr30a:168:16: error: 'Pixy2 {aka class TPixy2<Link2SPI>}' has no member named 'blocks'

   oldX = pixy2.blocks[trackedBlock].x;

                ^

sketch_apr30a:169:16: error: 'Pixy2 {aka class TPixy2<Link2SPI>}' has no member named 'blocks'

   oldY = pixy2.blocks[trackedBlock].y;

                ^

sketch_apr30a:170:24: error: 'Pixy2 {aka class TPixy2<Link2SPI>}' has no member named 'blocks'

   oldSignature = pixy2.blocks[trackedBlock].signature;

                        ^

C:\Users\gabe0\Downloads\sketch_apr30a\sketch_apr30a.ino: In function 'void FollowBlock(int)':

sketch_apr30a:188:17: error: 'Pixy2 {aka class TPixy2<Link2SPI>}' has no member named 'blocks'

   size += pixy2.blocks[trackedBlock].width -> pixy2.blocks[trackedBlock].height;

                 ^

exit status 1
'Pixy2 {aka class TPixy2<Link2SPI>}' has no member named 'getBlocks'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

sketch_apr30a.ino (6.05 KB)

Check the library documentation.

You are calling a function that does not exist in the library you instanced.

So I fixed my first error by changing it to pixy.ccc.getBlocks and I've tried pixy.blocks.height which is what the cmucam wiki says to use. I think I'm just completely lost at this point and can't figure out what to change it to. Thank you for the libraries suggestion though

Please post a link (using the chain links icon on the forum toolbar to make it clickable) to where you downloaded the pixy library from. Or if you installed it using Library Manger (Sketch > Include Library > Manage Libraries in the Arduino IDE or Libraries > Library Manager in the Arduino Web Editor) then say so and state the full name of the library.

GABE0421 has created a new thread about their new errors:
http://forum.arduino.cc/index.php?topic=613497

I downloaded it from the link on the Pixy2 Website https://pixycam.com/downloads-pixy2/