LusoRobótica - Robótica em Português

Sistemas específicos => Arduino / AVR => Tópico iniciado por: kerwac em 20 de Abril de 2010, 15:29

Título: Exemplo-VirtualBreadboard
Enviado por: kerwac em 20 de Abril de 2010, 15:29
Como tinha referido à uns dias atrás aqui deixo um exemplo de um programa feito com o VirtualBreadboard.
Codigo:
class Sweep extends com.muvium.compatibility.arduino.Arduino{//Automatically Added VBB Framework Code - do not remove
   // Controlling a servo position using a potentiometer (variable resistor)
   // Kerwac

   #include <Servo.h>
 
   Servo myservo9;  // create servo object to control a servo
   Servo myservo10;  // create servo object to control a servo
 
   int potpin9 = 0;  // analog pin used to connect the potentiometer
   int potpin10 = 1;  // analog pin used to connect the potentiometer
   int val;    // variable to read the value from the analog pin
 
   void setup()
   {
      myservo9.attach(9);  // attaches the servo on pin 9 to the servo object
      myservo10.attach(10);  // attaches the servo on pin 9 to the servo object
   }
 
   void loop()
   {
      val = analogRead(potpin9);            // reads the value of the potentiometer (value between 0 and 1023)
      val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
      myservo9.write(val);                  // sets the servo position according to the scaled value
      
      val = analogRead(potpin10);            // reads the value of the potentiometer (value between 0 and 1023)
      val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
      myservo10.write(val);                  // sets the servo position according to the scaled value
      
 
      delay(15);                           // waits for the servo to get there
   }
 
}
Título: Re: Exemplo-VirtualBreadboard
Enviado por: amando96 em 20 de Abril de 2010, 19:22
Não podes usar a hypercam para vermos a simulação no pc? ou uma print screen?
Título: Re: Exemplo-VirtualBreadboard
Enviado por: kerwac em 20 de Abril de 2010, 21:56
Como faço isso aqui no forum?
já tentei por um video mas algo correu mal.
Tens uma imagem em anexo das ligaçoes.
É muito simples trabalhar com este programa.Qualquer coisa que precises diz.Eu ajudo