#include <Servo.h>
Servo myservo;
int pos = 0;
int value = 0;
void setup(){
myservo.attach(2);
Serial.begin(9600)
}
void loop()
{
for(pos=0;pos<=180;+=pos){
myservo.write(pos);
value=myservo.read(0);
Serial.printIn(value);
delay(100);
}
for(pos=180;pos>=0;--pos)
{
myservo.write(pos);
value=myservo.read();
Serial.printIn(value);
delay(100);
}
}
#include <Servo.h>
Servo myservo;
int pos = 0;
int value = 0;
void setup(){
myservo.attach(2);
Serial.begin(9600);
}
void loop()
{
for(pos=0;pos<=180;++pos){
myservo.write(pos);
value=myservo.read(0);
Serial.printIn(value);
delay(100);
}
for(pos=180;pos>=0;--pos)
{
myservo.write(pos);
value=myservo.read();
Serial.printIn(value);
delay(100);
}
}
#include <Servo.h>
Servo myservo;
int pos = 0;
int value = 0;
void setup(){
myservo.attach(2);
Serial.begin(9600);
}
void loop()
{
for(pos=0;pos<=180;++pos){
myservo.write(pos);
value=myservo.read();
Serial.println(value);
delay(100);
}
for(pos=180;pos>=0;--pos)
{
myservo.write(pos);
value=myservo.read();
Serial.println(value);
delay(100);
}
}
Arduino: 1.6.12 (Windows 10), Board: "Arduino Nano, ATmega328"
Sketch uses 3,632 bytes (11%) of program storage space. Maximum is 30,720 bytes.
Global variables use 235 bytes (11%) of dynamic memory, leaving 1,813 bytes for local variables. Maximum is 2,048 bytes.
avrdude: ser_open(): can't open device "\\.\COM1": Access is denied.
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
سلام بببخشید کد درست بود من وقتی خواستم کد رو اپلود کنم به برد اردینو ای erorرو اورد
متشکرم از همکاری شما :)