Nov 24
Arreglo de Servos
Sindicados
Comments Off
Utilizando arreglos se puede simplificar mucho el código para la configuración de los servos y la comunicación con estos.
#include #undef int #undef abs #undef double #undef float #undef round Servo servos[5]; long loopCounter = 0; int angleCounter = 0; int angles[] = { 45,90,135,90 }; void setup() { for(int i=0; i<5; i++) servos[i].attach(i+2); } void loop() { Servo::refresh(); if(loopCounter++%25000 == 0) updateServos(angles[angleCounter++%4]); } void updateServos(int angle) { for(int i=0; i<5; i++) servos[i].write(angle); }
