Im having another problem

prizm.setmotorSpeeds(5,5);

what is wrong here?

What is wrong is that you did not post your whole sketch or the error message

1 Like
#include <PRIZM.h>
PRIZM prizm;
int wheelDiam = 4; 
float wheelCirc = wheelDiam*M_PI;
long totalTime = 3; 
int totalDist = 0;

void setup() {
  prizm.PrizmBegin () ;
}
void loop() {
  for (int x = 0; x<=720; x=x+5) {
     prizm.setmotorSpeeds(5,5); 
  }
  prizm.setGreenLED(HIGH);
  prizm.resetEncoders();
  long startTime = millis();
  while(prizm.readLineSensor)(3) == 0) { } 

  totalTime = round ((millis() - start Time)/1000); 
  totalDist = round(prizm.readEncoderDegrees (1) * wheelCirc / 360);
  prizm.setMotorPowers(5,5);
  displayVelocity();
  prizm.PrizmEnd();
}
void displayVelocity(){
  prizm.setGreenLED(LOW);
  delay(2000)
  int velocity = round(totalDist / totalTime); 
  for (int i = 0; i<=velocity; i++) { 
    prizm.setRedLED(HIGH);
    delay(500);
    prizm.setRedLED(LOW)
    delay (500) 
  }
}

So i have errors on the following lines:
while(prizm.readLineSensor)(3) == 0) { }

totalTime = round ((millis() - start Time)/1000);

int velocity = round(totalDist / totalTime);

for (int i = 0; i<=velocity; i++) {

delay (500)

Try this:

#include <PRIZM.h>
PRIZM prizm;
int wheelDiam = 4;
float wheelCirc = wheelDiam * M_PI;
long totalTime = 3;
int totalDist = 0;

void setup() {
  prizm.PrizmBegin () ;
}
void loop() {
  for (int x = 0; x <= 720; x = x + 5) {
    prizm.setmotorSpeeds(5, 5);
  }
  prizm.setGreenLED(HIGH);
  prizm.resetEncoders();
  long startTime = millis();
  while (prizm.readLineSensor)[3] == 0) { }
  totalTime = round ((millis() - start Time) / 1000);
  totalDist = round(prizm.readEncoderDegrees[1] * wheelCirc / 360);
  prizm.setMotorPowers(5, 5);
  displayVelocity();
  prizm.PrizmEnd();
}
void displayVelocity() {
  prizm.setGreenLED(LOW);
  delay(2000);
  int velocity = round(totalDist / totalTime);
  for (int i = 0; i <= velocity; i++) {
    prizm.setRedLED(HIGH);
    delay(500);
    prizm.setRedLED(LOW);
    delay (500);
  }
}

No idea if it will work.
Where did the code come from?

i found it on google from a pdf that tetrix prime made
https://asset.pitsco.com/sharedimages/resources/tetrixprizm-arduinoide-referenceguide.pdf

now i have less error at least

while (prizm.readLineSensor)[3] == 0) { }
totalTime = round ((millis() - start Time) / 1000);
totalDist = round(prizm.readEncoderDegrees[1] * wheelCirc / 360);

these are the lines that are with an error

If this is suppose to be the sketch on page 16, it's not. You changed some parameters.
prizm.setmotorSpeeds(5, 5);
is most likely it's too small a value to get the motors turning.

You require a finish line of some sort to stop this thing.

What error message are you getting?

while (prizm.readLineSensor[3] == 0) { }

1 Like

Please specify the error message!

@3lj0shuax - You copied a LOT of typographical errors from the PDF. Missing braces... translating parenthesis as brackets....

Why not use their example code from their library?

Library (zip)
https://www.pitsco.com/sharedimages/resources/TETRIX_PRIZM_080219.zip

A 168 page reference guide... library found
https://asset.pitsco.com/sharedimages/resources/tetrix-prizm-programming-guide.pdf

Here is the code from Post #6 as it should appear... (it compiles using the library zip above)

#include "PRIZM.h"
PRIZM prizm;
int wheelDiam = 4;
float wheelCirc = wheelDiam * M_PI;
long totalTime = 3;
int totalDist = 0;

void setup() {
  prizm.PrizmBegin () ;
}

void loop() {
  for (int x = 0; x <= 720; x = x + 5) {
    prizm.setMotorSpeeds(5, 5);
  }

  prizm.setGreenLED(HIGH);
  prizm.resetEncoders();
  long startTime = millis();

  while (prizm.readLineSensor(3) == 0) {
    totalTime = round ((millis() - startTime) / 1000);
    totalDist = round(prizm.readEncoderDegrees(1) * wheelCirc / 360);
    prizm.setMotorPowers(5, 5);
    displayVelocity();
    prizm.PrizmEnd();
  }
}

void displayVelocity() {
  prizm.setGreenLED(LOW);
  delay(2000);
  int velocity = round(totalDist / totalTime);
  for (int i = 0; i <= velocity; i++) {
    prizm.setRedLED(HIGH);
    delay(500);
    prizm.setRedLED(LOW);
    delay (500);
  }
}

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