what does this error means Arduino: 1.8.13 (Windows 7), Board: "Arduino Uno"
HC_SR04Test1:44:21: error: stray '\342' in program
t22 and t11 returns micros() and they correctly defined
pulse_width = (t22) – (t11);
^
HC_SR04Test1:44:22: error: stray '\200' in program
pulse_width = (t22) – (t11);
^
HC_SR04Test1:44:23: error: stray '\223' in program
pulse_width = (t22) – (t11);
^
C:\Users\maher\Documents\Arduino\HC_SR04Test1\HC_SR04Test1.ino: In function 'void loop()':
HC_SR04Test1:44:29: error: 't22' cannot be used as a function
pulse_width = (t22) – (t11);
^
exit status 1
stray '\342' in program
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Post your code,in code tags.
You've got some invisible characters, either from copying from an incompatible source, or from an incompatible editor.
But incorrectly used?
this is the code i an using
void loop() {
unsigned long t;
unsigned long t2;
unsigned long pulse_width;
float cm;
float inches;
// Hold the trigger pin high for at least 10 us
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
// Wait for pulse on echo pin
while ( digitalRead(ECHO_PIN) == 0 );
// Measure how long the echo pin was held high (pulse width)
t = micros();
while ( digitalRead(ECHO_PIN) == 1);
//t22 = micros();
t2 = micros();
pulse_width = t2 – t;// this line is giving stray in program error
// i do not know why?
//
cm = pulse_width / 58.0;
inches = pulse_width / 148.0;
k19615319:
pulse_width = t2 – t;
That doesn't say "(t22) - (t11)" like your original post
Your code is incomplete and missing code tags.
Did you write the code yourself, or copy it?
If the latter, where from?
@k19615319 , your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project See About the Installation & Troubleshooting category .
Do you know what google is? arduino stray - Google Search . There are solutions that used to work in the old forum, they might work in the new forum.
Copy your complete code from the IDE.
Paste it here in the reply box.
Delete all code in the IDE.
Select all code in the reply box.
Copy it.
Paste it in the IDE.
Compile.
If the compile was succesful, cancel the reply on the forum. If it failed, add code tags around your code and post.
You have an en dash there instead of a minus.
This trick does not work in the new forum.
1 Like
system
Closed
April 9, 2022, 4:13am
9
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.