Quantcast
Channel: fritzing forum - Latest topics
Viewing all articles
Browse latest Browse all 5416

Moteur et bouton poussoir / motor and push button

$
0
0

@Antoine1255 wrote:

Bonjour,
je souhaiterais contrôler mon moteur grâce à un bouton poussoir. Lorsque j’appuie sur le bouton, je voudrais que le moteur tourne pendant 30 seconde, et qu’il s’arrête une fois fini. Je ne vois pas où est l’erreur dans mon programme et le bouton est bien reconnu dans le moniteur série. J’utilise un bouton 2 broches mais sur le schéma c’est un 4 broches. J’utilise un Arduino Uno. Le but final serait de relier le tout à un écran LCD en I2C (la partie de l’écran avec le bouton est déjà terminée), afin de faire en sorte que lorsque j’appuie sur le bouton, le moteur tourne pendant 30 secondes et un opération se fait sur l’écran LCD.
/
Hello,
I would like to control my engine with a push button. When I press the button, I would like the engine to run for 30 seconds, and stop when finished. I don’t see where the error is in my program and the button is well recognized in the serial monitor. I use a 2 pin button but on the diagram it’s a 4 pin. I’m using an Arduino Uno. The final goal would be to connect everything to an LCD screen in I2C (the part of the screen with the button is already finished), so that when I press the button, the engine runs for 30 seconds and an operation is performed on the LCD screen.

Le programme / the program :

int pin1Moteur1=12; //cmd 1 du moteur 1
int pin2Moteur1=8; // cmd 2 du moteur 1
int pinPMoteur1=11; // PMM du moteur 1
int pinBouton=7; // bouton poussoir
int EtatBouton;

void setup()
{
Serial.begin(9600);
pinMode(7,INPUT); //Signale à l’Arduino que la connexion 7 doit pouvoir recevoir du courant
pinMode(12,OUTPUT); //Signale à l’Arduino que la connexion 13 doit pouvoir envoyer du courant
pinMode(8,OUTPUT); //Signale à l’Arduino que la connexion 8 doit pouvoir envoyer du courant
pinMode(11,OUTPUT); //Signale à l’Arduino que la connexion 11 doit pouvoir envoyer du courant
}

void loop()
{
boolean a=digitalRead(7);// et on l’affecte à la variable “a”
Serial.println(a); // on l’affiche sur le moniteur
delay(5);

if (EtatBouton == LOW);
{
digitalWrite(12,HIGH);
digitalWrite(8,LOW);
analogWrite(11,255);
delay(5000);
}

if (EtatBouton == HIGH);
{
digitalWrite(12,LOW);
digitalWrite(8,LOW);
analogWrite(11,0);
delay(5000);
}
}

Merci beaucoup / Thank you very much :slight_smile:

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>