For the most part i have been able to fumble my way around code and get it to work but I am stumped on this one. I am trying to use an rotary incremental encoder to measure degrees. But there have been a few times i have found this error (expected ')' before ';' token) while trying stuff and i cannot figure it out.
Arduino: 1.8.9 (Linux), Board: "Arduino/Genuino Uno"
/tmp/arduino_modified_sketch_680805/Basic.pde: In function 'void loop()':
Basic:33:15: error: expected ')' before ';' token
if (test = 0; test <= 21; test++) { //test = 0; test <= 21; test++
^
Basic:33:35: error: expected ';' before ')' token
if (test = 0; test <= 21; test++) { //test = 0; test <= 21; test++
^
exit status 1
expected ')' before ';' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
/* Encoder Library - Basic Example
http://www.pjrc.com/teensy/td_libs_Encoder.html
This example code is in the public domain.
*/
#include <Encoder.h>
// Change these two numbers to the pins connected to your encoder.
// Best Performance: both pins have interrupt capability
// Good Performance: only the first pin has interrupt capability
// Low Performance: neither pin has interrupt capability
Encoder myEnc(2, 3);
// avoid using pins with LEDs attached
void setup() {
Serial.begin(57600);
Serial.println("Basic Encoder Test:");
}
long oldPosition = -999;
int test = 0;
void loop() {
long newPosition = myEnc.read();
if (newPosition != oldPosition) {
oldPosition = newPosition;
Serial.println(newPosition);
newPosition = test;
}
if (test = 0; test <= 21; test++) { //test = 0; test <= 21; test++
Serial.println(test);
}
// myEnc.write()
//int fancyMath(){
//
// int answer;
//
// answer = test / 360;
// return answer;
// }
// if(test =
//if (test=0; test <= 21; test++){
// Serial.println(test);
// }
// if (oldPosition > 4095) {
// oldPosition++;
// Serial.println(newPosition);
//}
}