"Does Not Name A Type" Error Question

Hi, I’m really new at coding and was hoping someone could point out what I’m obviously missing. I got a Zip Runt Rover for my daughter. It provided code (see snipet below), but I keep getting a ‘does not name a type’ error on the line below that’s in red when I try to verify it in the Arduino Editor. I’ve been poking around for info a while now and been testing different code options, but can’t seem to figure it out. Here’s a link to the full code, if that helps. Any guidance would be much appreciated. Thanks!

#include <DRV8835MotorShield.h> //Pololu DRV8835 Dual Motor Driver Shield Library
#include <QTRSensors.h> //Pololu QTR-1RC Reflectance Sensor Library

//DEFINE PARAMETERS**************
#define LeftSensePin 2 //Left Line Sensor Pin
#define RightSensePin 3 //Right Line Sensor Pin
#define MaxMotorSpeed 400 //Maximum speed value to send to motors
int MaxDesiredSpeed = MaxMotorSpeed0.45;
#define MinSpeed 15
int leftSpeed = 0;
int rightSpeed = 0;
int leftDarkness = 0;
int rightDarkness = 0;
int darkest = 0;
int lightest;
int contrast;
int contrastThreshold = 170;
//
******************************************************

//Create QTR Sensor Line Following Object
QTRSensorsRC qtrrc((unsigned char) {LeftSensePin, RightSensePin},2, 2500, QTR_NO_EMITTER_PIN);
unsigned int sensorValues[2];

Try removing the "RC".

Where did you get this code and library from?

Thanks! Tried that, but unfortunately get the same error still. Go the code here. It’s what was provided from the site where I bought it.

Please post the complete error message. It probably contains lots of useful information. If you press the "Copy error messages" button in the IDE you can then paste the complete error listing into a message.

Steve

The problem is the sketch was written for an older version of the library, but Pololu made some breaking changes to the library since that time. The easiest fix is to tell the Arduino Web Editor to use the version of the library the code was written for:

  • (In the Arduino Web Editor) Click the “Libraries” tab.
  • Click the “Library Manager” button.
  • In the “Search Library” field, type “qtrsensors”.
  • In the search results, click the star icon, so that its center is filled in blue.
  • Click the “Done” button.
  • In the Libraries tab, click the “Favorites” tab.
  • Hover your mouse over “QTRSENSORS”. You should now see an “Include” button appear. Click the downward pointing triangle on the right side of the “Include” button.
  • From the dropdown menu, click “Version 3.1.0”.

That will change the metadata of your sketch to tell the Arduino Web Editor to use version 3.1.0 of the library instead of the latest version of the library. Your code should now be able to compile.

1 Like

Pert,

Thanks so much! That worked. I didn't even think of versioning as being part of the issue. Really appreciate the help - my daughter says thanks as well!

You're both welcome. I'm glad to hear it's working now. I'm sure this will be great fun for your daughter, after a few hiccups getting going.

Enjoy!
Per

Thanks again! Got it up and running last night. It's just one of those cars that can follow a line. She made a course on the floor with electrical tape and was at it for hours. Guess I'm going to have to find another project soon for when she gets bored with it

Way cool! Congratulations. I sure wish I had something like that to play with when I was younger. I had one of the 100 in 1 type Radio Shack electronics learning platforms with a bunch of components mounted on a piece of cardboard with spring connectors to make your circuits, but it didn't draw me in to electronics beyond just learning the basics.