{"id":4292,"date":"2016-01-31T21:28:01","date_gmt":"2016-01-31T20:28:01","guid":{"rendered":"http:\/\/salesianosatocha.es\/domit\/?p=4292"},"modified":"2016-01-31T21:35:59","modified_gmt":"2016-01-31T20:35:59","slug":"grupo-1-semana-3","status":"publish","type":"post","link":"https:\/\/salesianosatocha.es\/domit\/blog\/2016\/01\/31\/grupo-1-semana-3\/","title":{"rendered":"Grupo 1 &#8211; Semana 3"},"content":{"rendered":"<p>En \u00e9sta tercera semana hemos aprovechado para\u00a0comprar los materiales necesarios para el montaje de la maqueta, ya que tuvimos\u00a0algunos problemas al respecto de la compra por Internet.<\/p>\n<p>Adem\u00e1s de hacer los preparativos para la maqueta, hemos empezado a probar\u00a0el mando PS2 con el siguiente c\u00f3digo:<\/p>\n<div style=\"border: solid 2px #bdbdbd;background: #bdbdbd;color: #000000;padding: 4px;width: 730px;height: 200px;overflow: auto\">\n<p>#include \/\/for v1.6<\/p>\n<p>PS2X ps2x; \/\/ create PS2 Controller Class<\/p>\n<p>\/\/right now, the library does NOT support hot pluggable controllers, meaning<br \/>\n\/\/you must always either restart your Arduino after you conect the controller,<br \/>\n\/\/or call config_gamepad(pins) again after connecting the controller.<br \/>\nint error = 0;<br \/>\nbyte type = 0;<br \/>\nbyte vibrate = 0;<\/p>\n<p>void setup(){<br \/>\nSerial.begin(9600);<\/p>\n<p>\/\/CHANGES for v1.6 HERE!!! **************PAY ATTENTION*************<\/p>\n<p>error = ps2x.config_gamepad(13,11,10,12, true, true); \/\/setup pins and settings: GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error<\/p>\n<p>if(error == 0){<br \/>\nSerial.println(\u00abFound Controller, configured successful\u00bb);<br \/>\nSerial.println(\u00abTry out all the buttons, X will vibrate the controller, faster as you press harder;\u00bb);<br \/>\nSerial.println(\u00abholding L1 or R1 will print out the analog stick values.\u00bb);<br \/>\nSerial.println(\u00abGo to www.billporter.info for updates and to report bugs.\u00bb);<br \/>\n}<\/p>\n<p>else if(error == 1)<br \/>\nSerial.println(\u00abNo controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips\u00bb);<\/p>\n<p>else if(error == 2)<br \/>\nSerial.println(\u00abController found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips\u00bb);<\/p>\n<p>else if(error == 3)<br \/>\nSerial.println(\u00abController refusing to enter Pressures mode, may not support it. \u00ab);<\/p>\n<p>\/\/Serial.print(ps2x.Analog(1), HEX);<\/p>\n<p>type = ps2x.readType();<br \/>\nswitch(type) {<br \/>\ncase 0:<br \/>\nSerial.println(\u00abUnknown Controller type\u00bb);<br \/>\nbreak;<br \/>\ncase 1:<br \/>\nSerial.println(\u00abDualShock Controller Found\u00bb);<br \/>\nbreak;<br \/>\ncase 2:<br \/>\nSerial.println(\u00abGuitarHero Controller Found\u00bb);<br \/>\nbreak;<br \/>\n}<\/p>\n<p>}<\/p>\n<p>void loop(){<br \/>\n\/* You must Read Gamepad to get new values<br \/>\nRead GamePad and set vibration values<br \/>\nps2x.read_gamepad(small motor on\/off, larger motor strenght from 0-255)<br \/>\nif you don&#8217;t enable the rumble, use ps2x.read_gamepad(); with no values<\/p>\n<p>you should call this at least once a second<br \/>\n*\/<\/p>\n<p>if(error == 1) \/\/skip loop if no controller found<br \/>\nreturn;<\/p>\n<p>if(type == 2){ \/\/Guitar Hero Controller<\/p>\n<p>ps2x.read_gamepad(); \/\/read controller<\/p>\n<p>if(ps2x.ButtonPressed(GREEN_FRET))<br \/>\nSerial.println(\u00abGreen Fret Pressed\u00bb);<br \/>\nif(ps2x.ButtonPressed(RED_FRET))<br \/>\nSerial.println(\u00abRed Fret Pressed\u00bb);<br \/>\nif(ps2x.ButtonPressed(YELLOW_FRET))<br \/>\nSerial.println(\u00abYellow Fret Pressed\u00bb);<br \/>\nif(ps2x.ButtonPressed(BLUE_FRET))<br \/>\nSerial.println(\u00abBlue Fret Pressed\u00bb);<br \/>\nif(ps2x.ButtonPressed(ORANGE_FRET))<br \/>\nSerial.println(\u00abOrange Fret Pressed\u00bb);<\/p>\n<p>if(ps2x.ButtonPressed(STAR_POWER))<br \/>\nSerial.println(\u00abStar Power Command\u00bb);<\/p>\n<p>if(ps2x.Button(UP_STRUM)) \/\/will be TRUE as long as button is pressed<br \/>\nSerial.println(\u00abUp Strum\u00bb);<br \/>\nif(ps2x.Button(DOWN_STRUM))<br \/>\nSerial.println(\u00abDOWN Strum\u00bb);<\/p>\n<p>if(ps2x.Button(PSB_START)) \/\/will be TRUE as long as button is pressed<br \/>\nSerial.println(\u00abStart is being held\u00bb);<br \/>\nif(ps2x.Button(PSB_SELECT))<br \/>\nSerial.println(\u00abSelect is being held\u00bb);<\/p>\n<p>if(ps2x.Button(ORANGE_FRET)) \/\/ print stick value IF TRUE<br \/>\n{<br \/>\nSerial.print(\u00abWammy Bar Position:\u00bb);<br \/>\nSerial.println(ps2x.Analog(WHAMMY_BAR), DEC);<br \/>\n}<br \/>\n}<\/p>\n<p>else { \/\/DualShock Controller<\/p>\n<p>ps2x.read_gamepad(false, vibrate); \/\/read controller and set large motor to spin at &#8216;vibrate&#8217; speed<\/p>\n<p>if(ps2x.Button(PSB_START)) \/\/will be TRUE as long as button is pressed<br \/>\nSerial.println(\u00abStart is being held\u00bb);<br \/>\nif(ps2x.Button(PSB_SELECT))<br \/>\nSerial.println(\u00abSelect is being held\u00bb);<\/p>\n<p>if(ps2x.Button(PSB_PAD_UP)) { \/\/will be TRUE as long as button is pressed<br \/>\nSerial.print(\u00abUp held this hard: \u00ab);<br \/>\nSerial.println(ps2x.Analog(PSAB_PAD_UP), DEC);<br \/>\n}<br \/>\nif(ps2x.Button(PSB_PAD_RIGHT)){<br \/>\nSerial.print(\u00abRight held this hard: \u00ab);<br \/>\nSerial.println(ps2x.Analog(PSAB_PAD_RIGHT), DEC);<br \/>\n}<br \/>\nif(ps2x.Button(PSB_PAD_LEFT)){<br \/>\nSerial.print(\u00abLEFT held this hard: \u00ab);<br \/>\nSerial.println(ps2x.Analog(PSAB_PAD_LEFT), DEC);<br \/>\n}<br \/>\nif(ps2x.Button(PSB_PAD_DOWN)){<br \/>\nSerial.print(\u00abDOWN held this hard: \u00ab);<br \/>\nSerial.println(ps2x.Analog(PSAB_PAD_DOWN), DEC);<br \/>\n}<\/p>\n<p>vibrate = ps2x.Analog(PSAB_BLUE); \/\/this will set the large motor vibrate speed based on<br \/>\n\/\/how hard you press the blue (X) button<\/p>\n<p>if (ps2x.NewButtonState()) \/\/will be TRUE if any button changes state (on to off, or off to on)<br \/>\n{<\/p>\n<p>if(ps2x.Button(PSB_L3))<br \/>\nSerial.println(\u00abL3 pressed\u00bb);<br \/>\nif(ps2x.Button(PSB_R3))<br \/>\nSerial.println(\u00abR3 pressed\u00bb);<br \/>\nif(ps2x.Button(PSB_L2))<br \/>\nSerial.println(\u00abL2 pressed\u00bb);<br \/>\nif(ps2x.Button(PSB_R2))<br \/>\nSerial.println(\u00abR2 pressed\u00bb);<br \/>\nif(ps2x.Button(PSB_GREEN))<br \/>\nSerial.println(\u00abTriangle pressed\u00bb);<\/p>\n<p>}<\/p>\n<p>if(ps2x.ButtonPressed(PSB_RED)) \/\/will be TRUE if button was JUST pressed<br \/>\nSerial.println(\u00abCircle just pressed\u00bb);<\/p>\n<p>if(ps2x.ButtonReleased(PSB_PINK)) \/\/will be TRUE if button was JUST released<br \/>\nSerial.println(\u00abSquare just released\u00bb);<\/p>\n<p>if(ps2x.NewButtonState(PSB_BLUE)) \/\/will be TRUE if button was JUST pressed OR released<br \/>\nSerial.println(\u00abX just changed\u00bb);<\/p>\n<p>if(ps2x.Button(PSB_L1) || ps2x.Button(PSB_R1)) \/\/ print stick values if either is TRUE<br \/>\n{<br \/>\nSerial.print(\u00abStick Values:\u00bb);<br \/>\nSerial.print(ps2x.Analog(PSS_LY), DEC); \/\/Left stick, Y axis. Other options: LX, RY, RX<br \/>\nSerial.print(\u00ab,\u00bb);<br \/>\nSerial.print(ps2x.Analog(PSS_LX), DEC);<br \/>\nSerial.print(\u00ab,\u00bb);<br \/>\nSerial.print(ps2x.Analog(PSS_RY), DEC);<br \/>\nSerial.print(\u00ab,\u00bb);<br \/>\nSerial.println(ps2x.Analog(PSS_RX), DEC);<br \/>\n}<\/p>\n<p>}<\/p>\n<p>delay(50);<\/p>\n<p>}<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p>\u00c9ste c\u00f3digo lo podemos encontrar en \u00abEjemplos\u00bb al instalar la librer\u00eda PS2X de arduino, y sirve para comprobar la lectura del mando PS2 a la plataforma arduino. A pesar de que el mando parece estar bien conexionado, el mando y la librer\u00eda nos est\u00e1 dando problemas de compatibilidad, ya que recibe la alimentaci\u00f3n correctamente, pero no lee ninguno de los joysticks ni pulsadores.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>En \u00e9sta tercera semana hemos aprovechado para\u00a0comprar los materiales necesarios para el montaje de la maqueta, ya que tuvimos\u00a0algunos problemas al respecto de la compra por Internet. Adem\u00e1s de hacer los preparativos para la maqueta, hemos empezado a probar\u00a0el mando PS2 con el siguiente c\u00f3digo: #include \/\/for v1.6 PS2X ps2x; \/\/ create PS2 Controller Class [&hellip;]<\/p>\n","protected":false},"author":90,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","ngg_post_thumbnail":0,"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/salesianosatocha.es\/domit\/wp-json\/wp\/v2\/posts\/4292"}],"collection":[{"href":"https:\/\/salesianosatocha.es\/domit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salesianosatocha.es\/domit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salesianosatocha.es\/domit\/wp-json\/wp\/v2\/users\/90"}],"replies":[{"embeddable":true,"href":"https:\/\/salesianosatocha.es\/domit\/wp-json\/wp\/v2\/comments?post=4292"}],"version-history":[{"count":2,"href":"https:\/\/salesianosatocha.es\/domit\/wp-json\/wp\/v2\/posts\/4292\/revisions"}],"predecessor-version":[{"id":4294,"href":"https:\/\/salesianosatocha.es\/domit\/wp-json\/wp\/v2\/posts\/4292\/revisions\/4294"}],"wp:attachment":[{"href":"https:\/\/salesianosatocha.es\/domit\/wp-json\/wp\/v2\/media?parent=4292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salesianosatocha.es\/domit\/wp-json\/wp\/v2\/categories?post=4292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salesianosatocha.es\/domit\/wp-json\/wp\/v2\/tags?post=4292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}