I have the library but it still gives the same error
#include <Servo.h>
Servo myservo;
float sicaklik;
int sensor=0;
int pos = 0;
void setup()
{Serial.begin(9600);}
myservo.attach(9);
void loop() {
sicaklik = analogRead(sensor);
sicaklik = sicaklik * 0.48828125;
Serial.print("Sıcaklık=");
Serial.print(sicaklik);
Serial.println("Derece");
if (sicaklik>25);
myservo.write(100);
myservo.write(20);
delay(1000);
}
void setup()
{
Serial.begin(9600);
}
myservo.attach(9);
You could put myservo.attach inside the setup() function.
void setup()
{
Serial.begin(9600);
myservo.attach(9);
}
Putting every { and every } on its own line will help keep track of matching braces. Using autoformat (ctrl-t or Tools, Auto Format) will indent your code in a standard manner and often point out mismatched braces.
if (sicaklik > 25);
That if statement is probably not doing what you think. The semicolon ends the if. Nothing after the if is executed conditionally. Enclose the statements that you want to ececute conditionally in {} braces and lose the semicolon. Have a look at the reference for the if statement .
Arduino:1.8.5 (Windows 7), Kart:"Arduino/Genuino Uno"
sketch_mar24a:8: error: variable or field 'setup' declared void
sketch_mar24a:9: error: expected unqualified-id before '{' token
exit status 1
variable or field 'setup' declared void
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I have done the changes you've said,but now it gives another error.
#include <Servo.h>
Servo myservo;
float sicaklik;
int sensor = 0;
int pos = 0;
void setup(myservo.attach(9));
{Serial.begin(9600)};
void loop() {
sicaklik = analogRead(sensor);
sicaklik = sicaklik * 0.48828125;
Serial.print("Sıcaklık=");
Serial.print(sicaklik);
Serial.println("Derece");
if (sicaklik > 25) {
myservo.write(100);
myservo.write(20);
}
delay(1000);
}
void setup(myservo.attach(9));
{
Serial.begin(9600)
};
Should be
void setup()
{
myservo.attach(9);
Serial.begin(9600);
}
also
myservo.write(100);
myservo.write(20);
The servo will never get to 100 because the code does not wait until it gets there before sending it to 20
UKHeliBob:
void setup(myservo.attach(9));
{
Serial.begin(9600)
};
Should be
void setup()
{
myservo.attach(9);
Serial.begin(9600);
}
also
myservo.write(100);
myservo.write(20);
The servo will never get to 100 because the code does not wait until it gets there before sending it to 20
thank you bro. It helped.
system
March 24, 2018, 8:30pm
7
if (sicaklik > 25) {
myservo.write(100);
myservo.write(20);
}
You may as well just write
if (sicaklik > 25) {
myservo.write(20);
}
Because the servo just can't move fast enough.