Return to Snippet

Revision: 68354
at January 11, 2015 08:56 by agarcia


Updated Code
#include <Servo.h>
Servo miservo;
int Motor_Esq=7, Velocitat_Esq=6, Motor_Dret=12, Velocitat_Dret=10; //Declarem motors
int t=0;
int i = 0;

void setup()
{
    pinMode(Motor_Esq, OUTPUT);
    pinMode(Velocitat_Esq, OUTPUT);
    pinMode(Motor_Dret, OUTPUT);
    pinMode(Velocitat_Dret, OUTPUT);
    miservo.attach(3);
}

void loop()
{
    if(t == 0)
     {
       //des de la base fins la primera piramide
        Motor_Rodes(HIGH, -250,HIGH,-250);
        delay(2300);

      // gir a la dreta per colocar-se be a la primera piramide
        Motor_Rodes(HIGH, -164,LOW,-10);
        delay(1100);

      // avançar per descarregar primera piramide
        Motor_Rodes(HIGH, -250,HIGH,-250);
        delay(285);
        Motor_Rodes(LOW, 0,LOW,0);
        delay(50);

      // descarregar primera piramide
        descarrega();
      
      // avançar fins segona piramide
        Motor_Rodes(HIGH, -250,HIGH,-250);
        delay(990);
        Motor_Rodes(LOW, 0,LOW,0);
        delay(10);


      // descarregar segona piramide
        descarrega();
      
          
      // girar per posicio tercera piramide
        Motor_Rodes(HIGH, -250,LOW,0);
        delay(900);
        Motor_Rodes(LOW, 0,LOW,0);
        delay(10);

      // descarregar tercera piramide
        descarrega();
      
      // tornar a la base
        Motor_Rodes(HIGH, -250,HIGH,-100);
        delay(3200);
        Motor_Rodes(LOW, 0,LOW,0);
    
      t++;      
     }    
}

void Motor_Rodes (char Motor_Esq_Estat, int Motor_Esq_Potencia, char Motor_Dret_Estat, int Motor_Dret_Potencia)
{
      digitalWrite(Motor_Esq, Motor_Esq_Estat);
      analogWrite(Velocitat_Esq, Motor_Esq_Potencia);
      digitalWrite(Motor_Dret, Motor_Dret_Estat);
      analogWrite(Velocitat_Dret, Motor_Dret_Potencia);
}

void descarrega()
  {
      	miservo.write(180);
	delay(73);
	miservo.write(90);
	delay(1000);

    
    
  }

Revision: 68353
at January 11, 2015 08:47 by agarcia


Initial Code
#include <Servo.h>
Servo miservo;
int Motor_Esq=7, Velocitat_Esq=6, Motor_Dret=12, Velocitat_Dret=10; //Declarem motors
int t=0;
int i = 0;

void setup()
{
    pinMode(Motor_Esq, OUTPUT);
    pinMode(Velocitat_Esq, OUTPUT);
    pinMode(Motor_Dret, OUTPUT);
    pinMode(Velocitat_Dret, OUTPUT);
    miservo.attach(3);
}

void loop()
{
    if(t == 0)
     {
       //des de la base fins la primera piramide
        Motor_Rodes(HIGH, -250,HIGH,-250);
        delay(2300);

      // gir a la dreta per colocar-se be a la primera piramide
        Motor_Rodes(HIGH, -164,LOW,-10);
        delay(1100);

      // avançar per descarregar primera piramide
        Motor_Rodes(HIGH, -250,HIGH,-250);
        delay(285);
        Motor_Rodes(LOW, 0,LOW,0);
        delay(50);

      // descarregar primera piramide
        descarrega();
      
      // avançar fins segona piramide
        Motor_Rodes(HIGH, -250,HIGH,-250);
        delay(990);
        Motor_Rodes(LOW, 0,LOW,0);
        delay(10);


      // descarregar segona piramide
        descarrega();
      
          
      // girar per posicio tercera piramide
        Motor_Rodes(HIGH, -250,LOW,0);
        delay(900);
        Motor_Rodes(LOW, 0,LOW,0);
        delay(10);

      // descarregar tercera piramide
        descarrega();
      
      // tornar a la base
        Motor_Rodes(HIGH, -250,HIGH,-100);
        delay(3200);
        Motor_Rodes(LOW, 0,LOW,0);
    
      t++;      
     }    
}

void Motor_Rodes (char Motor_Esq_Estat, int Motor_Esq_Potencia, char Motor_Dret_Estat, int Motor_Dret_Potencia)
{
      digitalWrite(Motor_Esq, Motor_Esq_Estat);
      analogWrite(Velocitat_Esq, Motor_Esq_Potencia);
      digitalWrite(Motor_Dret, Motor_Dret_Estat);
      analogWrite(Velocitat_Dret, Motor_Dret_Potencia);
}

void descarrega()
  {
      	miservo.write(180);
	delay(73);
	miservo.write(90);
	delay(1000);

    
    
  }

Initial URL
www.mad-team.a78.org

Initial Description
This i s the task 1 of the ClauTIC robotics league by MAD Team.

Initial Title
Task 1, ClauTIC League, by MadTeam

Initial Tags

                                

Initial Language
Processing