Visualizzazione post con etichetta servo. Mostra tutti i post
Visualizzazione post con etichetta servo. Mostra tutti i post

lunedì 17 giugno 2013

Servo e Arduino un semplice sistema di Pan e Tilt

Poco fa mi sono arrivati dall'inghilterra due micro servo ed un sistema di Pan e Tilt, non ho perso tempo e mi sono subito cimentato nella costruzione di un semplice circuito per poterli testare
Non volevo utilizzare la bread board, cosi' ho definito le uscite analogiche 0 e 2 di Arduino ripettivamente come LOW ed HIGH per poter alimentare il potenziometro che funge da sistema di INPUT per la posizione.
Mentre ho collegato ai pin 9 e 10 l'ingresso PWM dei due servo.
Questo e' il risultato:




#include

Servo myservo;  // create servo object to control a servo
Servo myservo1;
int potpin = 1;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin
#define meno A0
#define piu A2
void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
   myservo1.attach(10);
pinMode (meno, OUTPUT);
pinMode (piu, OUTPUT);
digitalWrite (meno, LOW);
digitalWrite (piu, HIGH);

}

void loop()
{
 
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)

  val = map(val, 0, 1023, 179, 0);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);                  // sets the servo position according to the scaled value
  delay(10);                           // waits for the servo to get there
   myservo1.write(val);                  // sets the servo position according to the scaled value
  delay(10);                           // waits for the servo to get there
 
}


altri progetto o per contattarmi su www.Tognozzi.net
Stay Tuned TecnoGeppetto

Sensori Mic - ovvero un sistema di rivelazione rumore con Arduino

Questa volta ho lavorato sul sensore microfonico. Per capire la soluzione migliore, questa volta, ho montato il sensore in una scatoletta a se stante, con il circuito di rilevamento del segnale incorportato.

Questo rende piu' solido il sistema, ma costringe ad andare verso il sensore con tre fili invece che con due. (il segnale, e due dell'alimentazione - mentre nel caso del solo microfono, bastava collegare il sensore direttamente alla scheda principale con calza e segnale - due fili soli)
Per testare lla funzionalita' del circuito ho utilizzato il Microcontrollore che ho appena caricato con Arduino bootloader (due piccioni con una fava! cosi' testo tutti e due).
Sembra funzionare egregiamente.

Stay Tuned
TecnoGeppetto   su www.Tognozzi.net

lunedì 6 febbraio 2012

Esperienze con due servo motore

Posto oggi le primissime esperienze con i servo motori e la splendida scheda Arduino.
Ho cannibalizzato un vecchio robot della De Agostini che ho costruito qualche anno fa (credo fosse il 2002-2003) dal quale ho ricavato due bei motori servo della parallax, ho seguito il tutorial sul sito di riferimento di Arduino ed ho iniziato a fare le prime esperienze.

In progetto c'e' da costruire uno stabilizzatore di macchina, da applicare ad

una fotocamera per mantenere in asse la camera durante delle riprese con l'operatore in movimento, l'idea di base e' quella di utilizzare il sensore nunchuck della wii e due o tre servomotori.
Vedremo dove portano questi primi test.


Di seguito lo Scketch che ho utilizzato per comandare i due servo motori con i potenziometri
// Controlling a servo position using a potentiometer (variable resistor)
// by Jam ++++ servo senza fermo,

#include Servo.h 

Servo myservo; // create servo object to control a servo
Servo myservo1; // create servo object to control a servo

int potpin = 0; // analog pin used to connect the potentiometer
int potpin1 = 1; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
int val1; // variable to read the value from the analog pin

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
myservo1.attach(10);
}

void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val1 = analogRead(potpin1); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 1000, 2000); // scale it to use it with the servo (value between 1000 and 2000)
val1 = map(val1, 0, 1023, 1000, 2000); // scale it to use it with the servo (value between 1000 and 2000)

myservo.writeMicroseconds(val);
myservo1.writeMicroseconds(val1);
delay(15);
}