Fablab Ado > robot insecte 2eme partie Arduino

(actualisé le ) par Antoine

Nous avons continué a travailler nos robots insectes (ce qui est pas tout a fait exact car nos robots n’ont pas 6 pattes...)

Après la première partie détaillée ici, nous avons ajouté un 2ème servo, voici ce que cela donne :

JPEG - 81.8 ko
robot_2

et le code qui va avec :

// robot insecte PLMCB - cree a partir du fichier source Sweep

/* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.

modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/
int interrupteur=12; // interrupteur branche en position 12
int etatInterrupteur; // Déclaration des variables

#include <Servo.h>

Servo myservo1;  // créer un objet servo 1 pour le contrôler
Servo myservo2;  // créer un objet servo 2 pour le contrôler            

int pos1 = 0;    // variable pour stocker la position du potentiomètre 1
int pos2 = 0;    // variable pour stocker la position du potentiomètre 2

void setup()
{
 myservo1.attach(9);  // brancher le servomoteur 1 sur l'entrée 9
 myservo2.attach(5);  // brancher le servomoteur 1 sur l'entrée 5
 pinMode(interrupteur,INPUT);
 myservo1.write(30);
 myservo2.write(80);
 delay(3000);
}

void loop()
{
etatInterrupteur = digitalRead(12);

if  (etatInterrupteur == HIGH)  // Teste l'état de l'interrupteur
  {
   myservo1.write(10);
   delay(500);
   myservo2.write(110);
   delay(500);
   myservo1.write(50);
   delay(500);
   myservo2.write(50);
   delay(500);    
     }
}

Nous avons également d’autres créations en cours :

JPEG - 45.1 ko
robot_1
JPEG - 74.2 ko
robot_3