Hello, I was messing around with the calc functions at the bottom of my code then I started getting this error. Help please, I cannot see what is wrong.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20, 20, 4);
byte OnOffSw = 4;
byte DirectionSw = 5;
long w; //angular acceleration
long T; //Torque
long P; //Power
int f; //frequency
int N; //mapped RPM
int valN; //rmp before mapping
int valT; // torque be4mapping
void setup() {
lcd.init();
lcd.backlight();
lcd.clear();
pinMode(OnOffSw, INPUT);
pinMode(DirectionSw, INPUT_PULLUP);
}
void loop() {
calcSpeed();
calcFrequency();
calcTorque();
calcPw();
if (digitalRead(OnOffSw) == HIGH) {
lcd.setCursor(0, 0);
lcd.print("Motor OFF");
delay(400);
lcd.clear();
}
if (digitalRead(OnOffSw) == LOW) {
lcd.clear();
if (digitalRead(DirectionSw) == HIGH) {
lcd.setCursor(0, 0);
lcd.print("Anti-Clockwise");
lcd.setCursor(0, 1);
lcd.print("Speed:");
lcd.print(N);
lcd.print("rpm");
lcd.setCursor(0, 2);
lcd.print("Frequency:");
lcd.print(f);
lcd.print("Hz");
lcd.setCursor(0, 3);
lcd.print("Pwr:");
lcd.print(P);
lcd.print("W");
lcd.setCursor(10, 3);
lcd.print("Tor:");
lcd.print(T);
lcd.print("Nm");
delay(500);
lcd.clear();
}
else if (digitalRead(DirectionSw) == LOW) {
lcd.setCursor(0, 0);
lcd.print("Clockwise");
lcd.setCursor(0, 1);
lcd.print("Speed:");
lcd.print(N);
lcd.print("rpm");
lcd.setCursor(0, 2);
lcd.print("Frequency:");
lcd.print(f);
lcd.print("Hz");
lcd.setCursor(0, 3);
lcd.print("Pwr:");
lcd.print(P);
lcd.print("W");
lcd.setCursor(10, 3);
lcd.print("Tor:");
lcd.print(T);
lcd.print("Nm");
delay(500);
lcd.clear();
}
}
}
void calcSpeed() {
// read from pin
valN = analogRead(A0); //RPM
N = map(valN, 0, 1023, 0, 15000);
}
void calcFrequency() {
f = N / 180; // rms x number of poles (6)/2
}
void calcTorque() {
valT = analogRead(A1);
T = map(valT, 0, 1023, 0, 100);
}
void calcPw() {
w = (2 * PI * N) / 60; //angular acceleration (2*pi*rpm)/60 to get per second
P = T * w; //torque x angular acceleration
}
error message:
Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"
lcdPower:22:2: error: stray '\342' in program
}
^
lcdPower:22:3: error: stray '\200' in program
}
^
lcdPower:22:4: error: stray '\213' in program
}
^
lcdPower:22:5: error: stray '\342' in program
}
^
lcdPower:22:6: error: stray '\200' in program
}
^
lcdPower:22:7: error: stray '\213' in program
}
^
lcdPower:30:5: error: stray '\342' in program
^
lcdPower:30:6: error: stray '\200' in program
^
lcdPower:30:7: error: stray '\213' in program
^
lcdPower:30:8: error: stray '\342' in program
^
lcdPower:30:9: error: stray '\200' in program
^
lcdPower:30:10: error: stray '\213' in program
^
lcdPower:35:4: error: stray '\342' in program
}
^
lcdPower:35:5: error: stray '\200' in program
}
^
lcdPower:35:6: error: stray '\213' in program
}
^
lcdPower:35:7: error: stray '\342' in program
}
^
lcdPower:35:8: error: stray '\200' in program
}
^
lcdPower:35:9: error: stray '\213' in program
}
^
lcdPower:37:5: error: stray '\342' in program
^
lcdPower:37:6: error: stray '\200' in program
^
lcdPower:37:7: error: stray '\213' in program
^
lcdPower:37:8: error: stray '\342' in program
^
lcdPower:37:9: error: stray '\200' in program
^
lcdPower:37:10: error: stray '\213' in program
^
lcdPower:40:7: error: stray '\342' in program
^
lcdPower:40:8: error: stray '\200' in program
^
lcdPower:40:9: error: stray '\213' in program
^
lcdPower:40:10: error: stray '\342' in program
^
lcdPower:40:11: error: stray '\200' in program
^
lcdPower:40:12: error: stray '\213' in program
^
lcdPower:61:6: error: stray '\342' in program
}
^
lcdPower:61:7: error: stray '\200' in program
}
^
lcdPower:61:8: error: stray '\213' in program
}
^
lcdPower:61:9: error: stray '\342' in program
}
^
lcdPower:61:10: error: stray '\200' in program
}
^
lcdPower:61:11: error: stray '\213' in program
}
^
lcdPower:63:7: error: stray '\342' in program
^
lcdPower:63:8: error: stray '\200' in program
^
lcdPower:63:9: error: stray '\213' in program
^
lcdPower:63:10: error: stray '\342' in program
^
lcdPower:63:11: error: stray '\200' in program
^
lcdPower:63:12: error: stray '\213' in program
^
lcdPower:84:6: error: stray '\342' in program
}
^
lcdPower:84:7: error: stray '\200' in program
}
^
lcdPower:84:8: error: stray '\213' in program
}
^
lcdPower:84:9: error: stray '\342' in program
}
^
lcdPower:84:10: error: stray '\200' in program
}
^
lcdPower:84:11: error: stray '\213' in program
}
^
lcdPower:85:4: error: stray '\342' in program
}
^
lcdPower:85:5: error: stray '\200' in program
}
^
lcdPower:85:6: error: stray '\213' in program
}
^
lcdPower:85:7: error: stray '\342' in program
}
^
lcdPower:85:8: error: stray '\200' in program
}
^
lcdPower:85:9: error: stray '\213' in program
}
^
lcdPower:92:2: error: stray '\342' in program
}
^
lcdPower:92:3: error: stray '\200' in program
}
^
lcdPower:92:4: error: stray '\213' in program
}
^
lcdPower:92:5: error: stray '\342' in program
}
^
lcdPower:92:6: error: stray '\200' in program
}
^
lcdPower:92:7: error: stray '\213' in program
}
^
lcdPower:95:2: error: stray '\342' in program
}
^
lcdPower:95:3: error: stray '\200' in program
}
^
lcdPower:95:4: error: stray '\213' in program
}
^
lcdPower:95:5: error: stray '\342' in program
}
^
lcdPower:95:6: error: stray '\200' in program
}
^
lcdPower:95:7: error: stray '\213' in program
}
^
lcdPower:99:2: error: stray '\342' in program
}
^
lcdPower:99:3: error: stray '\200' in program
}
^
lcdPower:99:4: error: stray '\213' in program
}
^
lcdPower:99:5: error: stray '\342' in program
}
^
lcdPower:99:6: error: stray '\200' in program
}
^
lcdPower:99:7: error: stray '\213' in program
}
^
exit status 1
stray '\342' in program
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.