My code keeps giving me "'prizm' does not name a type"

I use the following code and regardless of what I change I can't stop the "'prizm' does not name a type" message.

#include <PRIZM.h>

PRIZM prizm;
EXPANSION exc; 
void setup() {
  // put your setup code here, to run once:
prizm.PrizmBegin();
   prizm.setServoSpeed(1,25);
  prizm.setMotorInvert(1,1);
exc.controllerEnable(1);

}

void loop() {

}

prizm.setServoPosition(1,180); 
exc.setMotorDegree(1,15,20);
prizm.setMotorDegrees(50,180,50,180);
prizm.setServoPosition(1,0);

Did you notice loop() is empty?

Did you notice this code is outside of loop()? Actually that code is not in any function.

did you try

void loop() 
{

prizm.setServoPosition(1,180); 
exc.setMotorDegree(1,15,20);
prizm.setMotorDegrees(50,180,50,180);
prizm.setServoPosition(1,0);

}

?

I didn't want to put it in a loop, but you're right I didn't put it in any kind of function. I'll put it in a for(int x=0;x<=0;x++) style function and see if it works. thanks for your help.

why??

no, for loop is not a function. You can't organize code this way.

The C doesn't permit using the code outside the any function.

this

for (statement 1; statement 2; statement 3) {
  // code block to be executed
}

is not a function.

You could do

void loop() 
{
aFunction();

}

void aFunction()
{
prizm.setServoPosition(1,180); 
exc.setMotorDegree(1,15,20);
prizm.setMotorDegrees(50,180,50,180);
prizm.setServoPosition(1,0);

}

now the code should run and is not in loop()

that function should work for me. although now it's telling me

exc.setMotorDegree(1,15,20);

isn't a function even though its in the programming guide

Help us help you.

Where is the library for that?

Please point out where EXPANSION is included in the Prizm library,

https://asset.pitsco.com/sharedimages/resources/tetrixprizm-arduinoide-referenceguide.pdf

im creating a robot to draw a circle using a marker help with an arm to lower and lift the arm up ive attacked a Rack and Pinion Linear Slide and used a motor to move the wheel because a part required for the servo isn't available to me. Since the robot still needs to drive I need a motor for each wheel and attached a MAX DC Motor Expansion Controller to the chassis however Ive never coded with this before.
Im sorry for not being helpful Im new to coding as a whole and have never used this forum before.

see post#9

the code I used for this came from an example code preinstalled on this computer

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.