Manufaturação industrial
Internet das coisas industrial | Materiais industriais | Manutenção e reparo de equipamentos | Programação industrial |
home  MfgRobots >> Manufaturação industrial >  >> Manufacturing Technology >> Processo de manufatura

Jogo de Operação Gigante Animatronics Lego Minfig

Componentes e suprimentos

Arduino UNO
× 2
Adafruit Arduino MP3 Shield
× 1
MG90S Gear Micro Servo
× 6
Alto-falante:3W, 4 ohms
× 2
OpenBuilds Ball Bearing - 688Z 8x16x5
× 12

Ferramentas e máquinas necessárias

Impressora Lulzbot Taz 5 FDM
X-Carve CNC

Sobre este projeto




Este projeto foi concluído em 4 etapas. Vou cobrir rapidamente os primeiros 3 estágios (que não continham eletrônicos) e detalhar os 4 estágios que estavam convertendo Frank no jogo de operação e adicionando áudio e animatrônicos.





Etapa 1:Construindo os Megafigs


Comecei construindo a mão. Achei que essa seria a parte mais difícil da construção inicial e definiu a escala para o resto das peças que precisavam ser fabricadas. A mão foi fabricada com tubo de PVC e resina de fibra de vidro para preencher o vazio entre as mãos interna e externa.

A fabricação da cabeça foi a próxima. É feito de tubo de PVC (um grande encaixe de tubo para a parte principal da cabeça), MDF e resina para preencher o vazio na saliência superior.

O corpo dos megafigs foi feito de MDF e uma construção de caixa bastante simples. Acessórios de PVC são usados ​​como articulações entre os apêndices e o torso

As pernas são feitas de MDF e PVC para definir as curvas da perna superior.

Os braços (que acabaram sendo a parte mais difícil) foram desbastados com tubo de PVC no antebraço e MDF no antebraço. A espuma floral foi usada como um preenchimento de espaço. Bondo foi usado para criar o formato do braço, e toneladas de lixamento e enchimento o trouxeram à sua forma final.







Os braços e as mãos foram moldados e fundidos com Smoothcast 300.

Tudo foi pintado com base no kit Monster Hunters Lego.





Fase 2:Cabelo


Esta fase consistia em fabricar o cabelo dos Cientistas. A espuma de ferramentas foi cortada com a serra de fita nas formas básicas dos fios de cabelo. As várias partes das mechas de cabelo foram coladas umas às outras com epóxi.

Todo o postiço foi coberto com Smoothcast 300 para criar uma concha de plástico sobre a espuma. foi então lixado e preenchido.



A escultura em epóxi foi usada para preencher todas as costuras entre as mechas de cabelo.



Foi preparado e pintado.





Fase 3:Cama do Frank


A terceira fase foi a construção da cama de Frank com base no Crazy Scientist e seu kit Monster Lego. É uma caixa simples feita de MDF e tubo de PVC para as protuberâncias.

Os detalhes dos cantos foram criados com tubo de PVC que imprensava um disco de MDF.

Tudo foi lixado, preparado e pintado.





Fase 4:Jogo de operação e movimento


A parte final deste projeto (até o momento) é converter Frank em um jogo de operação e adicionar áudio e movimento aos Megafigs. Vou detalhar cada parte do corpo da construção em vez de ir em ordem cronológica de como as coisas aconteceram (tudo estava sendo trabalhado ao mesmo tempo).





Torso:


O torso tinha suportes impressos em 3D adicionados às articulações que sustentavam 2 rolamentos de patins. Eles agem como um ponto de articulação para os braços e a cabeça.

A parte superior do corpo de Frank tinha 2 pratos de doces impressos em 3D, com bordas de alumínio fresado e uma nova placa de torso. Os lábios de alumínio atuam como um interruptor para o jogo de operação. Quando as pinças (que estão instaladas na proteção do MP3) tocam o alumínio, ele completa o circuito, ativando o programa.










Chefes:


Ambas as cabeças foram modificadas para mover e segurar os alto-falantes. Primeiro, um suporte impresso em 3D foi adicionado ao pescoço para segurar o parafuso 5/16 que atua como um eixo.



Metal perfurado foi usado como guia para mapear os orifícios da grade do alto-falante. Eu estava mais nervoso com esse processo. Qualquer erro arruinaria minha pintura de rostos. Os orifícios foram pintados para combinar com a cor circundante.







Um suporte impresso em 3D foi criado para segurar os alto-falantes atrás das grades.






Pernas:


As novas pernas foram impressas em 3D em duas metades, bem como um prato de doces em forma de osso. Uma placa de alumínio foi fresada como o torso. As pernas foram coladas, lixadas, alisadas com bondo e pintadas.










Braços:


O mestre original para os braços foi modificado para aceitar um suporte impresso em 3D que segurava um negrito 5/16 para um eixo. Eles foram então remodelados, fundidos, limpos e pintados.










Servos:


Os servos foram instalados usando suportes impressos em 3D e conectados aos apêndices por meio de arame e uma buzina de alumínio fixada nos parafusos 5/16. As molas foram adicionadas posteriormente para ajudar no levantamento dos braços.










Eletrônicos:


Todos os componentes eletrônicos foram montados em um pedaço de MDF para criar um protótipo de bancada de teste. Essa configuração permitiu que eu e Daniel descobríssemos a programação, ajustássemos as coisas e resolvêssemos as falhas. Tudo funcionou bem.

A forma como a eletrônica funciona é

1:o escudo MP3 aguarda 1 de 3 entradas (as pinças para uma das placas de alumínio)

2:Quando uma placa de alumínio é ativada, o escudo MP3 reproduz o arquivo MP3 correspondente e envia um sinal para o servo Arduino.

3:Quando o servo arduino obtém um sinal do escudo MP3, ele executa o código correspondente para os servos.

Os dois arduinos foram montados na parte de baixo da cama de Frank e tudo religado.





Pronto para truques ou tratadores:


Tudo funciona fantasticamente e resistiu a uma noite inteira de abusos.







Para um log de compilação mais detalhado, visite ... http://www.therpf.com/showthread.php?t=195101. Lá eu detalhei cada etapa conforme o produzia.

Código

  • Servos
  • efeitos sonoros
Servos Arduino
Este código é carregado no Arduino uno que controla todos os 6 servo motores. Basicamente, ele espera receber um dos 3 sinais do escudo MP3. Quando o sinal é recebido, o servo Arduino Uno executa os movimentos do servo correspondentes.
 / **************************** Targus - Operação - Servos ****************************** // ****** Notas ******* // / Os pinos digitais 0 e 1 são normalmente usados ​​para comunicação serial ao fazer o upload e monitorar um Arduino de um computador.// Os pinos digitais 0 e 1 podem ser usados ​​para servos se o Arduino não estiver conectado a um computador.// Se os pinos digitais 0 e 1 estão sendo usados ​​para servos, comente todas as linhas que começam com 'Serial'. neste arquivo.// Certifique-se de que este Arduino esteja ligado antes do outro Arduino, uma vez que este Arduino receberá sinais de 5 V.// Certifique-se de que um fio GND neste Arduino está conectado ao GND no outro Arduino./**** ***** Inclui ********** / # include  / ********** Variáveis ​​*********** / Servo servo5; Servo servo6; Servo servo7; Servo servo8; Servo servo9; Servo servo10; Servo servo11; int pin2 =2; int pin3 =3; int pin4 =4; / ************** Arduino Setup *************** / void setup () {Serial.begin (9600); // habilita a comunicação serial para desenvolvimento e solução de problemas Serial.println ("Targus - Operação - Servos \ n"); / ******************************************* Conecte Servos e defina as posições iniciais ** ****************************************** / servo5.attach (5); // pino digital 5 servo5.write (90); // mover para 90 graus servo6.attach (6); // pino digital 6 servo6.write (90); servo7.attach (7); // pino digital 7 servo7.write (90); servo8.attach (8); // pino digital 8 servo8.write (90); servo9.attach (9); // pino digital 9 servo9.write (80); servo10.attach (10); // pino digital 10 servo10.write (90); servo11.attach (11); // pino digital 11 servo11.write (80); / ************************* Configurar pinos de entrada digital ******************** ****** / // Configure os pinos de entrada para que o Arduino com efeitos sonoros possa nos dizer quando ativar os servos. pinMode (pin2, INPUT_PULLUP); pinMode (pin3, INPUT_PULLUP); pinMode (pin4, INPUT_PULLUP);} / ************* Arduino Loop ************** / void loop () {if (digitalRead (pin2) ==ALTO) {zap2 (); } else if (digitalRead (pin3) ==HIGH) {zap3 (); } else if (digitalRead (pin4) ==HIGH) {zap4 (); } delay (300);} / ********** Funções *********** / int moveServo (Servo e servo, int degreesStart, int degreeEnd, unsigned long timeEnd, unsigned long timeStart , float (* easing) (float), unsigned long timeNow) {// esta função retornará um número 1 se ainda houver trabalho a ser feito timeEnd + =timeStart; // adiciona qualquer atraso ao tempo de término if (timeNow  timeEnd) {// fase de movimento do servo concluída, nada a fazer return 0; } // se chegarmos até aqui, prepare-se para mover um servo float percentToMove =float (timeNow - timeStart) / float (timeEnd - timeStart); percentToMove =atenuação (percentToMove); // mapear faixas de grau de 0-180 a faixa de microssegundos 500-2400 para um SG-92R http://www.servodatabase.com/servo/towerpro/sg92r degreeStart =map (degreesStart, 0, 180, 500, 2400); grausEnd =mapa (grausEnd, 0, 180, 500, 2400); float servoTo =0; if (degreeEnd> degreeStart) {// rotaciona servoTo no sentido anti-horário =((degreeEnd - degreeStart) * percentToMove) + degreeStart; } else {// girar no sentido horário percentToMove =1 - percentToMove; // inverta a porcentagem para que valores como 0,8 se tornem 0,2 servoTo =((degreeStart - degreeEnd) * percentToMove) + degreeEnd; } servo.writeMicroseconds (servoTo); // Serial.print ("Mapearia para:"); Serial.println (servoTo); // Serial.print ("degreeStart:"); Serial.println (degreeStart); // Serial.print ("degreeEnd:"); Serial.println (degreeEnd); // Serial.print ("timeEnd:"); Serial.println (timeEnd); // Serial.print ("timeStart:"); Serial.println (timeStart); // Serial.print ("timeNow:"); Serial.println (timeNow); // Serial.print ("percentToMove:"); Serial.println (percentToMove); // Serial.print ("servoTo:"); Serial.println (servoTo); // Serial.print ("\ n"); return 1;} / ****************** Funções:Easing ******************** /// Funções de atenuação de https://github.com/warrenm/AHEasing/blob/master/AHEasing/easing.c renomeado para corresponder a http://easings.net/ para easy previewing.float facilidadeInBack (float pos) {// Modelado após o overshooting cúbico y =x ^ 3-x * sin (x * pi) retorno pos * pos * pos - pos * sin (pos * M_PI);} float facilidadeOutBack (float pos) {// Modelado após ultrapassagem y cúbico =1- ( (1-x) ^ 3- (1-x) * sin ((1-x) * pi)) float f =(1 - pos); return 1 - (f * f * f - f * sin (f * M_PI));} float facilidadeInOutBack (float pos) {// Modelado após a função cúbica de ultrapassagem por partes:// y =(1/2) * (( 2x) ^ 3- (2x) * sin (2 * x * pi)); [0, 0,5) // y =(1/2) * (1 - ((1-x) ^ 3- (1-x) * sin ((1-x) * pi)) + 1); [0,5, 1] ​​if (pos <0,5) {float f =2 * pos; retornar 0,5 * (f * f * f - f * sin (f * M_PI)); } else {float f =(1 - (2 * pos - 1)); retornar 0,5 * (1 - (f * f * f - f * sin (f * M_PI))) + 0,5; }} float facilidadeInBounce (posição flutuante) {return 1 - facilidadeOutBounce (1 - pos);} float facilidadeOutBounce (posição flutuante) {if (pos <4 / 11.0) {return (121 * pos * pos) / 16.0; } else if (pos <8 / 11.0) {return (363 / 40.0 * pos * pos) - (99 / 10.0 * pos) + 17 / 5.0; } else if (pos <9 / 10.0) {return (4356 / 361.0 * pos * pos) - (35442 / 1805.0 * pos) + 16061 / 1805.0; } else {return (54 / 5,0 * pos * pos) - (513 / 25,0 * pos) + 268 / 25,0; }} float facilidadeInOutBounce (float pos) {if (pos <0,5) {return 0,5 * facilidadeInBounce (pos * 2); } else {return 0,5 * facilidadeOutBounce (pos * 2 - 1) + 0,5; }} float facilidadeInCirc (float pos) {// Modelado após o quadrante deslocado IV do retorno do círculo unitário 1 - sqrt (1 - (pos * pos));} float facilidadeOutCirc (float pos) {// Modelado após o quadrante deslocado II da unidade círculo return sqrt ((2 - pos) * pos);} float facilidadeInOutCirc (float pos) {// Modelado após a função circular por partes // y =(1/2) (1 - sqrt (1 - 4x ^ 2)); [0, 0,5) // y =(1/2) (sqrt (- (2x - 3) * (2x - 1)) + 1); [0,5, 1] ​​if (pos <0,5) {return 0,5 * (1 - sqrt (1 - 4 * (pos * pos))); } else {return 0.5 * (sqrt (- ((2 * pos) - 3) * ((2 * pos) - 1)) + 1); }} float facilidadeInCubic (float pos) {// Modelado após o y cúbico =x ^ 3 return pos * pos * pos;} float facilidadeOutCubic (float pos) {// Modelado após o y cúbico =(x - 1) ^ 3 + 1 float f =(pos - 1); return f * f * f + 1;} float facilidadeInOutCubic (float pos) {// Modelado após a cúbica por partes // y =(1/2) ((2x) ^ 3); [0, 0,5) // y =(1/2) ((2x-2) ^ 3 + 2); [0,5, 1] ​​if (pos <0,5) {return 4 * pos * pos * pos; } else {float f =((2 * pos) - 2); retornar 0,5 * f * f * f + 1; }} float facilidadeInElastic (float pos) {// Modelado após a onda sinusoidal amortecida y =sin (13pi / 2 * x) * pow (2, 10 * (x - 1)) return sin (13 * M_PI_2 * pos) * pow (2, 10 * (pos - 1));} float facilidadeOutElastic (float pos) {// Modelado após a onda sinusoidal amortecida y =sin (-13pi / 2 * (x + 1)) * pow (2, - 10x) + 1 return sin (-13 * M_PI_2 * (pos + 1)) * pow (2, -10 * pos) + 1;} float facilidadeInOutElastic (float pos) {// Modelado após a onda sinusoidal exponencialmente amortecida por partes :// y =(1/2) * sin (13pi / 2 * (2 * x)) * pow (2, 10 * ((2 * x) - 1)); [0,0.5) // y =(1/2) * (sin (-13pi / 2 * ((2x-1) +1)) * pow (2, -10 (2 * x-1)) + 2 ); [0,5, 1] ​​if (pos <0,5) {return 0,5 * sin (13 * M_PI_2 * (2 * pos)) * pow (2, 10 * ((2 * pos) - 1)); } else {return 0.5 * (sin (-13 * M_PI_2 * ((2 * pos - 1) + 1)) * pow (2, -10 * (2 * pos - 1)) + 2); }} float facilidadeInExpo (float pos) {// Modelado após a função exponencial y =2 ^ (10 (x - 1)) return (pos ==0.0)? pos:pow (2, 10 * (pos - 1));} float facilidadeOutExpo (float pos) {// Modelado após a função exponencial y =-2 ^ (- 10x) + 1 return (pos ==1.0)? pos:1 - pow (2, -10 * pos);} float facilidadeInOutExpo (float pos) {// Modelado após o exponencial por partes // y =(1/2) 2 ^ (10 (2x - 1)); [0,0.5) // y =- (1/2) * 2 ^ (- 10 (2x - 1))) + 1; [0,5,1] if (pos ==0,0 || pos ==1,0) retorno pos; if (pos <0,5) {return 0.5 * pow (2, (20 * pos) - 10); } else {return -0.5 * pow (2, (-20 * pos) + 10) + 1; }} float linear (float pos) {return pos;} float facilidadeInQuad (float pos) {// Modelado após a parábola y =x ^ 2 return pos * pos;} float facilidadeOutQuad (float pos) {// Modelado após a parábola y =-x ^ 2 + 2x return - (pos * (pos - 2));} float facilidadeInOutQuad (float pos) {// Modelado após o quadrático por partes // y =(1/2) ((2x) ^ 2 ); [0, 0,5) // y =- (1/2) ((2x-1) * (2x-3) - 1); [0,5, 1] ​​if (pos <0,5) {return 2 * pos * pos; } else {return (-2 * pos * pos) + (4 * pos) - 1; }} float facilidadeInQuart (float pos) {// Modelado após o quártico x ^ 4 return pos * pos * pos * pos;} float facilidadeOutQuart (float pos) {// Modelado após o quártico y =1 - (x - 1) ^ 4 float f =(pos - 1); return f * f * f * (1 - pos) + 1;} float facilidadeInOutQuart (float pos) {// Modelado após o quártico por partes // y =(1/2) ((2x) ^ 4); [0, 0,5) // y =- (1/2) ((2x-2) ^ 4 - 2); [0,5, 1] ​​if (pos <0,5) {retorno 8 * pos * pos * pos * pos; } else {float f =(pos - 1); retornar -8 * f * f * f * f + 1; }} float facilidadeInQuint (float pos) {// Modelado após o quíntico y =x ^ 5 return pos * pos * pos * pos * pos;} float facilidadeOutQuint (float pos) {// Modelado após o quíntico y =(x - 1) ^ 5 + 1 flutuante f =(pos - 1); return f * f * f * f * f + 1;} float facilidadeInOutQuint (float pos) {// Modelado após a quintica por partes // y =(1/2) ((2x) ^ 5); [0, 0,5) // y =(1/2) ((2x-2) ^ 5 + 2); [0,5, 1] ​​if (pos <0,5) {retorno 16 * pos * pos * pos * pos * pos * pos; } else {float f =((2 * pos) - 2); retornar 0,5 * f * f * f * f * f + 1; }}float easeInSine(float pos) { // Modeled after quarter-cycle of sine wave return sin((pos - 1) * M_PI_2) + 1;}float easeOutSine(float pos) { // Modeled after quarter-cycle of sine wave (different phase) return sin(pos * M_PI_2);}float easeInOutSine(float pos) { // Modeled after half sine wave return 0.5 * (1 - cos(pos * M_PI));}/*************** Functions:Zap****************//****** Zap 2*******/void zap2() { Serial.println("ZAP 2 called!"); //Bone unsigned long timeStart =millis(); int todo; do { unsigned long timeNow =millis() - timeStart; todo =0; // M Leg Kick //todo +=moveServo(servo5, 90, 50, 100, 0, easeInOutCubic, timeNow); // move servo5 from 90 to 180 degrees for 1 second after a 0 second delay // todo +=moveServo(servo5, 50, 90, 500, 500, easeOutBounce, timeNow); // move servo5 from 180 to 90 degrees for 1 second after a 1 second delay // M Head side to side todo +=moveServo(servo7, 90, 110, 500,0, easeInOutCubic, timeNow); // move servo7 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo7, 110, 70, 500, 500, easeInOutCubic, timeNow); // move servo7 from 180 to 90 degrees for 1 second after a 1 second delay todo +=moveServo(servo7, 70, 110, 500, 1000, easeInOutCubic, timeNow); todo +=moveServo(servo7, 110, 70, 500, 1500, easeInOutCubic, timeNow); todo +=moveServo(servo7, 70, 110, 500, 2000, easeInOutCubic, timeNow); todo +=moveServo(servo7, 110, 70, 500, 2500, easeInOutCubic, timeNow); todo +=moveServo(servo7, 70, 90, 500, 3000, easeInOutCubic, timeNow); // M left arm up and down todo +=moveServo(servo8, 90, 170, 1000, 0, easeInOutCubic, timeNow); // move servo8 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo8, 170, 90, 1000, 4000, easeOutBounce, timeNow); // move servo8 from 180 to 90 degrees for 1 second after a 1 second delay // M right arm up and down todo +=moveServo(servo6, 90, 130, 1000, 1500, easeInOutCubic, timeNow); // move servo8 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo6, 130, 90, 1000, 5000, easeOutBounce, timeNow); // move servo8 from 180 to 90 degrees for 1 second after a 1 second delay // S Head side to side todo +=moveServo(servo10, 90, 40, 1000, 500, easeInOutCubic, timeNow); // move servo7 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo10, 40, 105, 1000, 2000, easeInOutCubic, timeNow); // move servo7 from 180 to 90 degrees for 1 second after a 1 second delay todo +=moveServo(servo10, 105, 90, 1000, 6000, easeInOutCubic, timeNow); // S left arm up and down todo +=moveServo(servo11, 80, 160, 1000, 2000, easeInOutCubic, timeNow); // move servo8 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo11, 160, 80, 1000, 5000, easeInOutCubic, timeNow); // move servo8 from 180 to 90 degrees for 1 second after a 1 second delay // S right arm up and down todo +=moveServo(servo9, 80, 20, 1000, 1000, easeInOutCubic, timeNow); // move servo8 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo9, 20, 80, 1000, 2000, easeInOutCubic, timeNow); // move servo8 from 180 to 90 degrees for 1 second after a 1 second delay delay(20); } while (todo> 0);}/****** Zap 3*******/void zap3() { Serial.println("ZAP 3 called!"); unsigned long timeStart =millis(); int todo; do { unsigned long timeNow =millis() - timeStart; todo =0; // M Head side to side todo +=moveServo(servo7, 90, 130, 1000, 0, easeInOutCubic, timeNow); // move servo7 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo7, 130, 90, 1000, 5000, easeInOutCubic, timeNow); // move servo7 from 180 to 90 degrees for 1 second after a 1 second delay // M left arm up and down todo +=moveServo(servo8, 90, 170, 1000, 0, easeInOutCubic, timeNow); // move servo8 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo8, 170, 90, 1000, 4000, easeOutBounce, timeNow); // move servo8 from 180 to 90 degrees for 1 second after a 1 second delay // M right arm up and down todo +=moveServo(servo6, 90, 130, 1000, 1500, easeInOutCubic, timeNow); // move servo8 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo6, 130, 90, 1000, 5000, easeOutBounce, timeNow); // move servo8 from 180 to 90 degrees for 1 second after a 1 second delay // S Head side to side todo +=moveServo(servo10, 90, 40, 1000, 500, easeInOutCubic, timeNow); // move servo7 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo10, 40, 105, 1000, 2000, easeInOutCubic, timeNow); // move servo7 from 180 to 90 degrees for 1 second after a 1 second delay todo +=moveServo(servo10, 105, 90, 1000, 6000, easeInOutCubic, timeNow); // S left arm up and down todo +=moveServo(servo11, 80, 160, 1000, 0, easeInOutCubic, timeNow); // move servo8 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo11, 160, 80, 1000, 5000, easeInOutCubic, timeNow); // move servo8 from 180 to 90 degrees for 1 second after a 1 second delay // S right arm up and down todo +=moveServo(servo9, 80, 20, 1000, 1000, easeInOutCubic, timeNow); // move servo8 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo9, 20, 80, 1000, 6000, easeInOutCubic, timeNow); // move servo8 from 180 to 90 degrees for 1 second after a 1 second delay delay(10); } while (todo> 0);}/****** Zap 4*******/void zap4() { Serial.println("ZAP 4 called!"); unsigned long timeStart =millis(); int todo; do { unsigned long timeNow =millis() - timeStart; todo =0; // M Head side to side todo +=moveServo(servo7, 90, 130, 1000, 0, easeInOutCubic, timeNow); // move servo7 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo7, 130, 90, 1000, 5000, easeInOutCubic, timeNow); // move servo7 from 180 to 90 degrees for 1 second after a 1 second delay // M left arm up and down todo +=moveServo(servo8, 90, 170, 1000, 0, easeInOutCubic, timeNow); // move servo8 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo8, 170, 90, 1000, 4000, easeOutBounce, timeNow); // move servo8 from 180 to 90 degrees for 1 second after a 1 second delay // M right arm up and down todo +=moveServo(servo6, 90, 130, 1000, 1500, easeInOutCubic, timeNow); // move servo8 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo6, 130, 90, 1000, 5000, easeOutBounce, timeNow); // move servo8 from 180 to 90 degrees for 1 second after a 1 second delay // S Head side to side todo +=moveServo(servo10, 90, 40, 1000, 500, easeInOutCubic, timeNow); // move servo7 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo10, 40, 105, 1000, 2000, easeInOutCubic, timeNow); // move servo7 from 180 to 90 degrees for 1 second after a 1 second delay todo +=moveServo(servo10, 105, 90, 1000, 6000, easeInOutCubic, timeNow); // S left arm up and down todo +=moveServo(servo11, 80, 160, 1000, 2000, easeInOutCubic, timeNow); // move servo8 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo11, 160, 80, 1000, 5000, easeInOutCubic, timeNow); // move servo8 from 180 to 90 degrees for 1 second after a 1 second delay // S right arm up and down todo +=moveServo(servo9, 80, 20, 1000, 1000, easeInOutCubic, timeNow); // move servo8 from 90 to 180 degrees for 1 second after a 0 second delay todo +=moveServo(servo9, 20, 80, 1000, 2000, easeInOutCubic, timeNow); // move servo8 from 180 to 90 degrees for 1 second after a 1 second delay delay(10); } while (todo> 0);}
Sound EffectsArduino
This code is loaded onto the Arduino Uno with the MP3 shield mounted to it. Basically it receives a signal from one of three switches, plays the corresponding audio file and send a signal the Arduino Uno controlling the servos. Two buttons can also be mounted to it to control volume.
/*********************************** Targus - Operation - Sound Effects************************************//****** Notes*******/// Digital Pins 0 and 1 are normally used for serial commucation when uploading and monitoring an Arduino from a computer.// Digital Pins 3, 4, 6, 7, 11, 12, and 13 are used by the Adafruit Music Maker Shield.// This Arduino should be powered on after the servos Arduino since this Arduino will be sending 5V signals.// Make sure a GND wire on this Arduino is connected to GND on the other Arduino./********* Includes**********/#include #include #include /********** Variables***********/int relayPin5 =5;int relayPin8 =8;int relayPin9 =9;int pinVolDown =14; // aka Analog In 0int pinVolUp =15; // aka Analog In 1int volume =50; // this is the default volume which can be changed later by the volDown() and volUp() functions/******************************************************************** Adafruit Music Maker Shield - https://www.adafruit.com/product/1788*********************************************************************/// Adafruit Music Maker Shield Pins#define SHIELD_RESET -1 // VS1053 reset pin (unused!)#define DREQ 3 // VS1053 Data request, ideally an Interrupt pin. See http://arduino.cc/en/Reference/attachInterrupt for more info.#define CARDCS 4 // Card chip select pin#define SHIELD_DCS 6 // VS1053 Data/command select pin (output)#define SHIELD_CS 7 // VS1053 chip select pin (output)// the most important thing on the line below is the variable 'musicPlayer' which we will use to play music laterAdafruit_VS1053_FilePlayer musicPlayer =Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);/************** Arduino Setup***************/void setup() { Serial.begin(9600); // enable serial communication for development and troubleshooting Serial.println("Targus - Operation - Sound Effects\n"); if (! musicPlayer.begin()) { // initialise the music player Serial.println(F("Couldn't find VS1053, do you have the right pins defined?")); while (1); // loop forever since we could not connect to the Adafruit Music Maker Shield } SD.begin(CARDCS); // initialise the SD card // Set volumes for the left and right channels. musicPlayer.setVolume(volume,volume); // 0-255 with 0 being crazy loud // If DREQ is on an interrupt pin (on uno, #2 or #3) we can do background audio playing musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT); // DREQ int // Specify which GPIO pins to use for input. musicPlayer.GPIO_pinMode(2, OUTPUT); // switch for ... musicPlayer.GPIO_pinMode(3, OUTPUT); // switch for ... musicPlayer.GPIO_pinMode(4, OUTPUT); // switch for ... // Specify which digital pins we will use for volume control pinMode(pinVolDown, INPUT_PULLUP); pinMode(pinVolUp, INPUT_PULLUP); // Specify which digital pins we will use to communicate with the other Arduino (aka the Arduino with all the servos). pinMode(relayPin5, OUTPUT); pinMode(relayPin8, OUTPUT); pinMode(relayPin9, OUTPUT);}/************* Arduino Loop**************/void loop() { int gpio2 =musicPlayer.GPIO_digitalRead(2); int gpio3 =musicPlayer.GPIO_digitalRead(3); int gpio4 =musicPlayer.GPIO_digitalRead(4); int ioDown =digitalRead(pinVolDown); // volume down int ioUp =digitalRead(pinVolUp); // volume up// Serial.println(ioDown);// Serial.println(ioUp);// Serial.println(gpio2); if (gpio2 ==1) { Serial.println("GPIO 2 triggered.\n"); zap2(); } else if (gpio3 ==1) { Serial.println("GPIO 3 triggered.\n"); zap3(); } else if (gpio4 ==1) { Serial.println("GPIO 4 triggered.\n"); zap4(); } else if (ioDown ==LOW) { Serial.println("Analog 0 triggered.\n"); volDown(); } else if (ioUp ==LOW) { Serial.println("Analog 1 triggered.\n"); volUp(); } delay(2); // this delay may need to be reduced or removed depending on how responsive hitting the tongs to the side of a container feels}/********** Functions***********/void audioPlay(String file) { Serial.println("Playing " + file); musicPlayer.startPlayingFile(file.c_str()); atraso (500); // wait half a second before returning so the audio can get going}void audioStop(String file) { musicPlayer.stopPlaying(); Serial.println("Done playing " + file);}void activate(int pin) { digitalWrite(pin, HIGH); delay(300); // delay as long as needed for the other Arduino to notice an event digitalWrite(pin, LOW);}void volDown() { volume =volume + 1; if (volume> 255) { volume =255; } // Set volumes for the left and right channels. musicPlayer.setVolume(volume,volume); // 0-255 with 0 being crazy loud Serial.print("Volume set to "); Serial.println(volume);}void volUp() { volume =volume - 1; if (volume <0) { volume =0; } // Set volumes for the left and right channels. musicPlayer.setVolume(volume,volume); // 0-255 with 0 being crazy loud Serial.print("Volume set to "); Serial.println(volume);}/*************** Functions:Zap****************/ /****** Zap 2 *******/ void zap2() { // Audio and Servo(s) triggered by GPIO 2 String file ="02.mp3"; // this file should exist on the SD card /*********** Play Audio ************/ audioPlay(file); /************************************* Tell other Arduino to Animate Servos **************************************/ activate(relayPin5); delay(6000); // Customize delay to match end of servo movements, go by feel vs. accurate math since this Arduino's clock may not sync with the other Arduino. /*********** Stop Audio ************/ audioStop(file); } /****** Zap 3 *******/ void zap3() { // Audio and Servo(s) triggered by GPIO 3 String file ="03.mp3"; // this file should exist on the SD card /*********** Play Audio ************/ audioPlay(file); /************************************* Tell other Arduino to Animate Servos **************************************/ activate(relayPin8); delay(6000); // Customize delay to match end of servo movements, go by feel vs. accurate math since this Arduino's clock may not sync with the other Arduino. /*********** Stop Audio ************/ audioStop(file); } /****** Zap 4 *******/ void zap4() { // Audio and Servo(s) triggered by GPIO 4 String file ="04.mp3"; // this file should exist on the SD card /*********** Play Audio ************/ audioPlay(file); /************************************* Tell other Arduino to Animate Servos **************************************/ activate(relayPin9); delay(6000); // Customize delay to match end of servo movements, go by feel vs. accurate math since this Arduino's clock may not sync with the other Arduino. /*********** Stop Audio ************/ audioStop(file); } 

Peças personalizadas e gabinetes

3D grown Parts
Arquivo CAD em thingiverse.com

Esquemas

Connect GPIO 2, 3, 4 of the MP3 shield to the aluminum Plates.
Connect 3v of the MP3 shield to the tongs.
Connect pins 5, 8, 9 of the MP3 shiled to pins 2, 3, 4 of the servo Arduino.
Connect pins 6, 7, 8, 9, 10, 11 of the servo Arduino to the servos.
Wire the positive and negative of the servos to a 5v plug.
Wire the graounds of both the servo Arduino and the MP3 shield to the 5v plug.
Wire up both speaker inputs. These are the scaled and dimensioned drawings I used to construct the megafigs.

Processo de manufatura

  1. Faça Monitor Ambilight usando Arduino
  2. Jogo Arduino Pong - Tela OLED
  3. Controlador de jogo Arduino
  4. Lego Shooter automatizado
  5. Jogo Arduino Touch Breakout
  6. Detector de frequência de áudio
  7. Arduino Tamagotchi Clone - Animal de estimação digital
  8. Manipulador de interruptor de luz sem fio
  9. Tech-TicTacToe
  10. Pistola de água com sensor de movimento