Hello,
given the approach of the exams and the problems with the initial project I was forced to change it in the hope of giving the commission examining something to see, but I found problems in the sketch, this sketch consists of 3 simple pieces that together form the distributor for animals (yes, I know this is not enough to take a good mark on the commission but I don't have time to prepare the machine I had in mind) the pieces are:
arduino
sensor
servo motor
the skerch is this:
#include <Servo.h>
#define trig 8
#define echo 9
int distanza;
int val;
Servo mioServo;
bool attivazione = false;
void setup() {
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
Serial.begin(9600);
mioServo.attach (7);
}
void loop() {
digitalWrite(trig, LOW);
delay(10);
digitalWrite(trig, HIGH);
delay(10);
digitalWrite(trig, LOW);
distanza = pulseIn(echo, HIGH) / 58.2;
Serial.println(distanza);
delay(10);
if(attivazione == false && distanza >28)
{ attivazione = true;
for(val=0;val<55;val++)
{ Serial.println(val);
mioServo.write(val);
delay(1);
}
delay(50);
for(val=54;val>-1;val–)
{Serial.println(val);
mioServo.write(val);
delay(1);
}
}
if(distanza < 28)
{
for(val=0;val<55;val++)
{ Serial.println(val);
mioServo.write(val);
delay(1);
}
delay(50);
for(val=54;val>-1;val–)
{Serial.println(val);
mioServo.write(val);
delay(1);
}
delay(10800000);
}
}
once copied and pasted I get this problem (which I think is due to a missing library in the program [but
I do not know which]):
for(val=54;val>-1;val–)
by copying the red part that appears below [from the error message copy] tells me:
exit status 1
stray '\342' in program
[Arduino:1.8.5 (Windows 10), Scheda:"Arduino/Genuino Uno"
sketch_jun03a:31: error: stray '\342' in program
for(val=54;val>-1;val–)
^
sketch_jun03a:31: error: stray '\200' in program
sketch_jun03a:31: error: stray '\223' in program
sketch_jun03a:45: error: stray '\342' in program
for(val=54;val>-1;val–)
^
sketch_jun03a:45: error: stray '\200' in program
sketch_jun03a:45: error: stray '\223' in program
exit status 1
stray '\342' in program
Questo report potrebbe essere più ricco di informazioni abilitando l'opzione
"Mostra un output dettagliato durante la compilazione"
in "File -> Impostazioni"
]
I take the sketch from this website:
I hope in an answer, in short timescales given the approach of the exams and the mistakes that the old project that caused me a change in all programs, thank you in advance for the answers (positive or negative that are)