Hello I am doing a project but it gives an error

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>

double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
double __var__69_108_32_103_246_114_252_110_100_252_32_109_252_63;
float getDistance(int trig,int echo){
pinMode(trig,OUTPUT);
digitalWrite(trig,LOW);
delayMicroseconds(2);
digitalWrite(trig,HIGH);
delayMicroseconds(10);
pinMode(echo, INPUT);
return pulseIn(echo,HIGH,30000)/58.0;
}
Servo servo_10;

void setup(){
servo_10.attach(10);
__var__69_108_32_103_246_114_252_110_100_252_32_109_252_63 = 0;
if((getDistance(4,5)) < (20)){
__var__69_108_32_103_246_114_252_110_100_252_32_109_252_63 += 1;
if((getDistance(4,5)) < (20)){
__var__69_108_32_103_246_114_252_110_100_252_32_109_252_63 += -1;
}
}
if(((__var__69_108_32_103_246_114_252_110_100_252_32_109_252_63)==(1))){
servo_10.write(90);
}
if(((__var__69_108_32_103_246_114_252_110_100_252_32_109_252_63)==(0))){
servo_10.write(-90);
}
}

void loop(){
_loop();
}

void _delay(float seconds){
long endTime = millis() + seconds * 1000;
while(millis() < endTime)_loop();
}

void _loop(){
}
the code is this and the error is this

program Files (x86)\mBlock\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\libraries\Wire -IC:\Program Files (x86)\mBlock\Arduino\hardware\arduino\avr\libraries\SoftwareSerial C:\Users\poyra\AppData\Local\Temp\build438859862090385590.tmp\project_PROJEP_1.SB27_4.cpp -o C:\Users\poyra\AppData\Local\Temp\build438859862090385590.tmp\project_PROJEP_1.SB27_4.cpp.o
project_PROJEP_1.SB27_4.ino:18:1: error: 'Servo' does not name a type
project_PROJEP_1.SB27_4.ino: In function 'void setup()':
project_PROJEP_1.SB27_4.ino:23:5: error: 'servo_10' was not declared in this scope
'Servo' does not name a type

In order to learn how to use the Servo library, you should take some time to study and experiment with the Servo library tutorials:

And its reference pages:

Thank you :+1:

And for your next post with code, do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including code tags and necessary documentation of your ask).

Hi, @mr_codemaster
Can you tell us what your code is supposed to do?
What are you inputs and outputs?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Please follow the advice given in the link below when posting code . Use code tags when posting code here to make it easier to read and copy for examination

You forgot "#include <Servo.h>"

double __var__69_108_32_103_246_114_252_110_100_252_32_109_252_63;

Seriously?

Oops

seems like code generated by one of those block tools

Did it generate that too? :open_mouth:

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