SlideShare uma empresa Scribd logo
1 de 6
Baixar para ler offline
#include​ ​<​Servo​.​h​>​    ​//incluimos la librerÃ​a servo. 
 
 
Servo​ servo1;   ​//declaramos los servos en la librerÃ​a. 
Servo​ servo2; 
Servo​ servo3; 
Servo​ servo4; 
Servo​ servo5; 
Servo​ servo6; 
 
int​ ejex1 ​=​ A1;   ​//pines joystick y botones 
int​ ejey1 ​=​ A2; 
int​ ejex2 ​=​ A3; 
int​ ejey2 ​=​ A4; 
int​ button1 ​=​ 7; 
int​ button2 ​=​ 13; 
int​ button3 ​=​ 2; 
int​ xvalue1 ​=​ 0; ​//valores joystick 
int​ yvalue1 ​=​ 0; 
int​ xvalue2 ​=​ 0; 
int​ yvalue2 ​=​ 0; 
 
int​ tiempo ​=​ 50;  ​//tiempo de espera de los servos 
 
int​ posServo1 ​=​ 90;   ​//posiciones iniciales de los servos 
int​ posServo2 ​=​ 100; 
int​ posServo3 ​=​ 90; 
int​ posServo4 ​=​ 90; 
int​ posServo5 ​=​ 90; 
int​ posServo6 ​=​ 0; 
 
 
 
int​ buttonvalue1;   ​//valores botones 
int​ buttonvalue2; 
int​ buttonvalue3; 
 
void​ ​setup​() { 
 
  ​pinMode​ (button1​,​ ​INPUT​);   ​//establecemos los botones como entradas digitales. 
  ​pinMode​ (button2​,​ ​INPUT​); 
  ​pinMode​ (button3​,​ ​INPUT​); 
 
  servo1​.​attach​(3);   ​//pines de los servos, los declaramos en la librerÃ​a 
  servo2​.​attach​(5); 
  servo3​.​attach​(6); 
  servo4​.​attach​(8); 
  servo5​.​attach​(10); 
  servo6​.​attach​(11); 
 
  ​Serial​.​begin​(9600);   ​//iniciamos comunicación con el puerto serie 
 
} 
 
void​ ​loop​() { 
 
  xvalue1 ​=​ ​analogRead​(ejex1);  ​//fijamos los valores de los joysticks a lo leido por los pines. 
  yvalue1 ​=​ ​analogRead​(ejey1); 
 
  xvalue2 ​=​ ​analogRead​(ejex2); 
  yvalue2 ​=​ ​analogRead​(ejey2); 
 
  ​//primer joystick 
  ​if​ (xvalue1 ​<​ 400)  { 
  posServo2 ​=​ posServo2 ​­​ 1; 
  servo2​.​write​(posServo2); 
  ​delay​(tiempo); 
  ​Serial​.​print​(​"Servo2 ­ "​); 
  ​Serial​.​println​(posServo2); 
  } 
  ​if​ (xvalue1 ​>​ 600)  { 
  posServo2 ​=​ posServo2 ​+​ 1; 
  servo2​.​write​(posServo2); 
  ​delay​(tiempo); 
  ​Serial​.​print​(​"Servo2 ­ "​); 
  ​Serial​.​println​(posServo2); 
  } 
 
 
  ​if​ (yvalue1 ​<​ 400)  { 
  posServo3 ​=​ posServo3 ​­​ 1; 
  servo3​.​write​(posServo3); 
  ​delay​(tiempo); 
  ​Serial​.​print​(​"Servo3 ­ "​); 
  ​Serial​.​println​(posServo3); 
  } 
  ​if​ (yvalue1 ​>​ 600)  { 
  posServo3 ​=​ posServo3 ​+​ 1; 
  servo3​.​write​(posServo3); 
  ​delay​(tiempo); 
  ​Serial​.​print​(​"Servo3 ­ "​); 
  ​Serial​.​println​(posServo3); 
  } 
 
 
  ​//segundojoystick 
  ​if​ (xvalue2 ​<​ 400)  { 
  posServo4 ​=​ posServo4 ​­​ 1; 
  servo4​.​write​(posServo4); 
  ​delay​(tiempo); 
  ​Serial​.​print​(​"Servo4 ­ "​); 
  ​Serial​.​println​(posServo4); 
  } 
  ​if​ (xvalue2 ​>​ 600)  { 
  posServo4 ​=​ posServo4 ​+​ 1; 
  servo4​.​write​(posServo4); 
  ​delay​(tiempo); 
  ​Serial​.​print​(​"Servo4 ­ "​); 
  ​Serial​.​println​(posServo4); 
  } 
 
 
  ​if​ (yvalue2 ​<​ 400)  { 
  posServo5 ​=​ posServo5 ​­​ 1; 
  servo5​.​write​(posServo5); 
  ​delay​(tiempo); 
  ​Serial​.​print​(​"Servo5 ­ "​); 
  ​Serial​.​println​(posServo5); 
  } 
  ​if​ (yvalue2 ​>​ 600)  { 
  posServo5 ​=​ posServo5 ​+​ 1; 
  servo5​.​write​(posServo5); 
  ​delay​(tiempo); 
  ​Serial​.​print​(​"Servo5 ­ "​); 
  ​Serial​.​println​(posServo5); 
  } 
 
  ​//boton 
  buttonvalue1 ​=​ ​digitalRead​ (button1); 
 
  ​if​ (buttonvalue1 ​==​ ​HIGH​) { 
  posServo1 ​=​ posServo1 ​­​ 1; 
  servo1​.​write​(posServo1); 
  ​delay​(tiempo); 
  ​Serial​.​print​(​"Servo1 ­ "​); 
  ​Serial​.​println​(posServo1); 
 
  } 
  buttonvalue2 ​=​ ​digitalRead​ (button2); 
 
  ​if​ (buttonvalue2 ​==​ ​HIGH​) { 
  posServo1 ​=​ posServo1 ​+​ 1; 
  servo1​.​write​(posServo1); 
  ​delay​(tiempo); 
  ​Serial​.​print​(​"Servo1 ­ "​); 
  ​Serial​.​println​(posServo1); 
  } 
 
  ​if​ (posServo1 ​>​ 179) { 
  posServo1 ​=​ 179; 
  } 
  ​if​ (posServo1 ​<​ 1) { 
  posServo1 ​=​ 1; 
  } 
  ​if​ (posServo2 ​>​ 179) { 
  posServo2 ​=​ 179; 
  } 
  ​if​ (posServo2 ​<​ 1) { 
  posServo2 ​=​ 1; 
  } ​if​ (posServo3 ​>​ 179) { 
  posServo3 ​=​ 179; 
  } 
  ​if​ (posServo3 ​<​ 1) { 
  posServo3 ​=​ 1; 
  } ​if​ (posServo4 ​>​ 179) { 
  posServo4 ​=​ 179; 
  } 
  ​if​ (posServo4 ​<​ 1) { 
  posServo4 ​=​ 1; 
  } ​if​ (posServo5 ​>​ 179) { 
  posServo5 ​=​ 179; 
  } 
  ​if​ (posServo5 ​<​ 1) { 
  posServo5 ​=​ 1; 
  } 
  buttonvalue3 ​=​ ​digitalRead​ (button3); 
 
  ​//boton 2 
  ​if​ (buttonvalue3 ​==​ ​HIGH​) { 
  posServo6 ​=​ 0; 
  servo6​.​write​(posServo6); 
  ​Serial​.​print​(​"Servo6 ­ abierto"​); 
  } 
 
  ​if​ (buttonvalue3 ​==​ ​LOW​) { 
  posServo6 ​=​ 180; 
  servo6​.​write​(posServo6); 
  ​delay​(1000); 
  ​Serial​.​print​(​"Servo6 ­ cerrado"​); 
  } 
} 
 
 
 
 
 

Mais conteúdo relacionado

Mais procurados (6)

PLC y electroneumática: Ejemplos de PLC
 PLC y electroneumática: Ejemplos de PLC PLC y electroneumática: Ejemplos de PLC
PLC y electroneumática: Ejemplos de PLC
 
Union y concatenacion
Union y concatenacionUnion y concatenacion
Union y concatenacion
 
Presentacionarduino
PresentacionarduinoPresentacionarduino
Presentacionarduino
 
Presentación1
Presentación1Presentación1
Presentación1
 
Programacion control numerico por computadora
Programacion control numerico por computadoraProgramacion control numerico por computadora
Programacion control numerico por computadora
 
Jose
JoseJose
Jose
 

Destaque

2011-Full-FPDForum-program-new
2011-Full-FPDForum-program-new2011-Full-FPDForum-program-new
2011-Full-FPDForum-program-new
Amr Shady
 
Kevin Barraclough CV NACE CIP 2
Kevin Barraclough CV NACE CIP 2Kevin Barraclough CV NACE CIP 2
Kevin Barraclough CV NACE CIP 2
Kevin Barraclough
 

Destaque (17)

You Pinheiros - Corretor Brahma
You Pinheiros - Corretor BrahmaYou Pinheiros - Corretor Brahma
You Pinheiros - Corretor Brahma
 
LinxFIT 7 GDK UX Tips
LinxFIT 7 GDK UX TipsLinxFIT 7 GDK UX Tips
LinxFIT 7 GDK UX Tips
 
Front Cover for Albie Merani and The Desendants
Front Cover for Albie Merani and The DesendantsFront Cover for Albie Merani and The Desendants
Front Cover for Albie Merani and The Desendants
 
Word 2 tha mutha.pt.2.p.d.f
Word 2 tha mutha.pt.2.p.d.fWord 2 tha mutha.pt.2.p.d.f
Word 2 tha mutha.pt.2.p.d.f
 
China
China  China
China
 
Location
LocationLocation
Location
 
2011-Full-FPDForum-program-new
2011-Full-FPDForum-program-new2011-Full-FPDForum-program-new
2011-Full-FPDForum-program-new
 
Evaluaties060314
Evaluaties060314Evaluaties060314
Evaluaties060314
 
Dongyangyang LIU CV
Dongyangyang LIU CVDongyangyang LIU CV
Dongyangyang LIU CV
 
『アフィリエイト・プログラムに関する意識調査2010』 ama 理事 野崎雷太
『アフィリエイト・プログラムに関する意識調査2010』 ama 理事 野崎雷太『アフィリエイト・プログラムに関する意識調査2010』 ama 理事 野崎雷太
『アフィリエイト・プログラムに関する意識調査2010』 ama 理事 野崎雷太
 
Kevin Barraclough CV NACE CIP 2
Kevin Barraclough CV NACE CIP 2Kevin Barraclough CV NACE CIP 2
Kevin Barraclough CV NACE CIP 2
 
Ecology Unit Review
Ecology Unit ReviewEcology Unit Review
Ecology Unit Review
 
Word 2 tha mutha.pt.4.p.d.f
Word 2 tha mutha.pt.4.p.d.fWord 2 tha mutha.pt.4.p.d.f
Word 2 tha mutha.pt.4.p.d.f
 
El bar1
El bar1El bar1
El bar1
 
Schaffer
SchafferSchaffer
Schaffer
 
Measuring Learning Readiness for TRIO Students
Measuring Learning Readiness for TRIO StudentsMeasuring Learning Readiness for TRIO Students
Measuring Learning Readiness for TRIO Students
 
Dataspace presentatie
Dataspace presentatieDataspace presentatie
Dataspace presentatie
 

Semelhante a Programacionmandobrazorobot

53692670 arduino-programacion
53692670 arduino-programacion53692670 arduino-programacion
53692670 arduino-programacion
Cesar Castelo
 
Arduino
ArduinoArduino
Arduino
jjjss
 
Tecladomatricial
TecladomatricialTecladomatricial
Tecladomatricial
systemgil
 

Semelhante a Programacionmandobrazorobot (20)

PRIMER Proyecto alarma arduino
PRIMER Proyecto alarma arduinoPRIMER Proyecto alarma arduino
PRIMER Proyecto alarma arduino
 
53692670 arduino-programacion
53692670 arduino-programacion53692670 arduino-programacion
53692670 arduino-programacion
 
Arduino: Programando el Simon dice
Arduino: Programando el Simon diceArduino: Programando el Simon dice
Arduino: Programando el Simon dice
 
Arduino Basico.pptx
Arduino Basico.pptxArduino Basico.pptx
Arduino Basico.pptx
 
Arduino
ArduinoArduino
Arduino
 
Arduino
ArduinoArduino
Arduino
 
Arduino
ArduinoArduino
Arduino
 
Arduino
ArduinoArduino
Arduino
 
Manual de Arduino
Manual de ArduinoManual de Arduino
Manual de Arduino
 
PDF OP DE KRISTI
PDF OP DE KRISTIPDF OP DE KRISTI
PDF OP DE KRISTI
 
ARDUINO - LADDER PROYECTO CX3 RESET TEMP EH EN 2 CILINDROS BI MONO...
ARDUINO  - LADDER   PROYECTO  CX3 RESET  TEMP  EH  EN   2  CILINDROS  BI MONO...ARDUINO  - LADDER   PROYECTO  CX3 RESET  TEMP  EH  EN   2  CILINDROS  BI MONO...
ARDUINO - LADDER PROYECTO CX3 RESET TEMP EH EN 2 CILINDROS BI MONO...
 
218727950 curso-robots-motoman-pptx
218727950 curso-robots-motoman-pptx218727950 curso-robots-motoman-pptx
218727950 curso-robots-motoman-pptx
 
ARDUINO GRAFCET - ESTRUCTURAS GRAFCET - ECUACION BINODAL CON ARDUINO.pdf
ARDUINO  GRAFCET   -  ESTRUCTURAS GRAFCET   -  ECUACION BINODAL  CON ARDUINO.pdfARDUINO  GRAFCET   -  ESTRUCTURAS GRAFCET   -  ECUACION BINODAL  CON ARDUINO.pdf
ARDUINO GRAFCET - ESTRUCTURAS GRAFCET - ECUACION BINODAL CON ARDUINO.pdf
 
C facil de_v2
C facil de_v2C facil de_v2
C facil de_v2
 
Equipo7 Arduino
Equipo7 ArduinoEquipo7 Arduino
Equipo7 Arduino
 
Práctica con Arduino: Simon Dice
Práctica con Arduino: Simon DicePráctica con Arduino: Simon Dice
Práctica con Arduino: Simon Dice
 
Termómetro con arduino uno
Termómetro con arduino unoTermómetro con arduino uno
Termómetro con arduino uno
 
Tecladomatricial
TecladomatricialTecladomatricial
Tecladomatricial
 
Arduino
ArduinoArduino
Arduino
 
Proyecto Brazo Robótico con arduino.pptx
Proyecto Brazo Robótico con arduino.pptxProyecto Brazo Robótico con arduino.pptx
Proyecto Brazo Robótico con arduino.pptx
 

Último

Proyecto integrador. Las TIC en la sociedad S4.pptx
Proyecto integrador. Las TIC en la sociedad S4.pptxProyecto integrador. Las TIC en la sociedad S4.pptx
Proyecto integrador. Las TIC en la sociedad S4.pptx
241521559
 
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
silviayucra2
 
EPA-pdf resultado da prova presencial Uninove
EPA-pdf resultado da prova presencial UninoveEPA-pdf resultado da prova presencial Uninove
EPA-pdf resultado da prova presencial Uninove
FagnerLisboa3
 

Último (10)

guía de registro de slideshare por Brayan Joseph
guía de registro de slideshare por Brayan Josephguía de registro de slideshare por Brayan Joseph
guía de registro de slideshare por Brayan Joseph
 
pruebas unitarias unitarias en java con JUNIT
pruebas unitarias unitarias en java con JUNITpruebas unitarias unitarias en java con JUNIT
pruebas unitarias unitarias en java con JUNIT
 
Proyecto integrador. Las TIC en la sociedad S4.pptx
Proyecto integrador. Las TIC en la sociedad S4.pptxProyecto integrador. Las TIC en la sociedad S4.pptx
Proyecto integrador. Las TIC en la sociedad S4.pptx
 
Desarrollo Web Moderno con Svelte 2024.pdf
Desarrollo Web Moderno con Svelte 2024.pdfDesarrollo Web Moderno con Svelte 2024.pdf
Desarrollo Web Moderno con Svelte 2024.pdf
 
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
 
Trabajo Mas Completo De Excel en clase tecnología
Trabajo Mas Completo De Excel en clase tecnologíaTrabajo Mas Completo De Excel en clase tecnología
Trabajo Mas Completo De Excel en clase tecnología
 
Presentación guía sencilla en Microsoft Excel.pptx
Presentación guía sencilla en Microsoft Excel.pptxPresentación guía sencilla en Microsoft Excel.pptx
Presentación guía sencilla en Microsoft Excel.pptx
 
International Women's Day Sucre 2024 (IWD)
International Women's Day Sucre 2024 (IWD)International Women's Day Sucre 2024 (IWD)
International Women's Day Sucre 2024 (IWD)
 
Global Azure Lima 2024 - Integración de Datos con Microsoft Fabric
Global Azure Lima 2024 - Integración de Datos con Microsoft FabricGlobal Azure Lima 2024 - Integración de Datos con Microsoft Fabric
Global Azure Lima 2024 - Integración de Datos con Microsoft Fabric
 
EPA-pdf resultado da prova presencial Uninove
EPA-pdf resultado da prova presencial UninoveEPA-pdf resultado da prova presencial Uninove
EPA-pdf resultado da prova presencial Uninove
 

Programacionmandobrazorobot