Aller au contenu


Contenu de 69robot

Il y a 1 élément(s) pour 69robot (recherche limitée depuis 02-mai 13)


#53194 Programme arduino pour 2 servomoteurs

Posté par 69robot sur 30 janvier 2013 - 01:33 dans Aide pour projets scolaire

Salut


C'est peut etre un peu tard mais je mets mon programme
Servomoteur avec capteur ligne et carte arduino


/*
Button

Turns on and off a light emitting diode(LED) connected to digital
pin 13, when pressing a pushbutton attached to pin 2.


The circuit:
* LED attached from pin 13 to ground
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground

* Note: on most Arduinos there is already an LED on the board
attached to pin 13.


created 2005
by DojoDave <http://www.0j0.org>
modified 30 Aug 2011
by Tom Igoe

This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/Button
*/

// constants won't change. They're used here to
// set pin numbers:
#include <Servo.h>
const int buttonPin = 6; // the number of the pushbutton pin
const int capteurPin = 9;
Servo servo1; // the number of the LED pin
Servo servo2;
int buttonState = 0; // variable for reading the pushbutton state
int capteurState = 0;
void PROPULTION ()
{
}


void setup() {

pinMode(buttonPin, INPUT);
pinMode(capteurPin, INPUT);

servo1.attach(10);
servo2.attach(11);
}

void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
capteurState = digitalRead(capteurPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
PROPULTION();
if (buttonState == HIGH) {
// turn LED on:
servo1.writeMicroseconds(2000);
servo2.writeMicroseconds(50);
}
else {
// turn LED off:
servo1.writeMicroseconds(50);
servo2.writeMicroseconds(50);
}
// read the state of the pushbutton value:
capteurState = digitalRead(capteurPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (capteurState == HIGH) {
// turn LED on:
servo1.writeMicroseconds(2000);
servo2.writeMicroseconds(50);
}
else {
// turn LED off:
servo1.writeMicroseconds(2000);
servo2.writeMicroseconds(2000);
}
}

Apres tout depend de ou tu branche t capteur et t servo tu change les numero