View difference between Paste ID: 7LBjMR8q and JESFG4k1
SHOW: | | - or go back to the newest paste.
1-
#include <Servo.h>
1+
2
3-
Servo myservo;  // create servo object to control a servo
3+
 void setup() {
4
  // initialize serial communication at 9600 bits per second:
5
  Serial.begin(9600);
6
}
7-
void setup() {
7+
8-
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
8+
// the loop routine runs over and over again forever:
9
void loop() {
10
  // read the input on analog pin 0:
11
  
12-
     for(int i = 0;i<180;i++){
12+
  int sensorValue = analogRead(A0);
13-
          myservo.write(i);                  // sets the servo position according to the scaled value
13+
  // print out the value you read:
14-
           delay(20);                           // waits for the servo to get there
14+
  
15
  Serial.print("sa valeur est de:");
16
  Serial.println(sensorValue);
17-
  for(int i = 180;i>0;i--){
17+
  delay(500);        // delay in between reads for stability
18-
         myservo.write(i);                  // sets the servo position according to the scaled value
18+