test the controller with a Playstation 2 to verify that it is working.
Second please check the connections…
The image shows a different board but the pin orientation id the same…
OR…
lynxmotion.com/images/html/build034.htm
Copy & paste the program from the bottom of the page into the editor. There are two sections that need to be tailored to your setup. At the top of the program, in the “Bot Board Selection” section, you select either Mini-Atom Bot Board, or the Bot Board II. Remove the semicolons in front of the four lines that match your board, and add semicolons in front of the four lines that do NOT match your board. At the bottom of the program, in the “Basic Micro IDE Terminal” section you select the IDE you are using. You will need to do this twice - once under “sending carriage return”, and once under “sending all the data”. Remove the semicolons from the 1 line in both places to match your IDE, and add semicolons in front of the lines that do NOT match your IDE.
The program uses the Bot Board II, Basic Atom 28 and the 5.3.0.0 editor as the default. If this is your setup, no changes need to be made.
[code];-----------Bot Board Selection----------
;PS2 Controller / BotBoard I
;DAT con P4
;CMD con P5
;SEL con P6
;CLK con P7
;PS2 Controller / BotBoard II
DAT con P12
CMD con P13
SEL con P14
CLK con P15
;-----------------------------
index var byte
temp var byte(19)
mode var byte
Small_Motor var byte
Large_Motor var byte
;PS2Init
high CLK
low SEL
shiftout CMD,CLK,FASTLSBPRE,$1\8,$43\8,$0\8,$1\8,$0\8] ;CONFIG_MODE_ENTER
high SEL
pause 1
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$44\8,$00\8,$01\8,$03\8,$00\8,$00\8,$00\8,$00\8] ;SET_MODE_AND_LOCK
high SEL
pause 100
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$4F\8,$00\8,$FF\8,$FF\8,$03\8,$00\8,$00\8,$00\8] ;SET_DS2_NATIVE_MODE
high SEL
pause 1
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$4D\8,$00\8,$00\8,$01\8,$FF\8,$FF\8,$FF\8,$FF\8] ;VIBRATION_ENABLE
high SEL
pause 1
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$43\8,$00\8,$00\8,$5A\8,$5A\8,$5A\8,$5A\8,$5A\8] ;CONFIG_MODE_EXIT_DS2_NATIVE
high SEL
pause 1
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$43\8,$00\8,$00\8,$00\8,$00\8,$00\8,$00\8,$00\8] ;CONFIG_MODE_EXIT
high SEL
pause 1
main
;-----------PS2 Mode----------
low SEL
; asking “mode” to PS2 controller
shiftout CMD,CLK,FASTLSBPRE,$1\8]
; reading “mode” from PS2 controller
; 73(hex) is dualshock1 (digital buttons)
; 79(hex) is dualshock2 (analog buttons)
shiftin DAT,CLK,FASTLSBPOST,[mode\8]
high SEL
;-----------------------------
pause 1
;-----------PS2 Data----------
low SEL
; asking data to PS2 controller
shiftout CMD,CLK,FASTLSBPRE,$1\8,$42\8]
; reading data from controller
; (don’t use a “for-next” loop, it’s too slow to read PS2 data)
shiftin DAT,CLK,FASTLSBPOST,[temp(0)\8,temp(1)\8,temp(2)\8,temp(3)\8,temp(4)\8,temp(5)\8,temp(6)\8,temp(7)\8,temp(8)\8, |
temp(9)\8,temp(10)\8,temp(11)\8,temp(12)\8,temp(13)\8,temp(14)\8,temp(15)\8,temp(16)\8,temp(17)\8,temp(18)\8]
high SEL
;-----------------------------
pause 1
;-----------PS2 Vibration motors----------
Small_Motor = 1 - Temp(1).bit5 ; Numeric right arrow button (Small Motor on/off)
Large_Motor = Temp(8) ; Analog left arrow button (Large Motor speed)
low SEL
; asking data to PS2 controller (again)
; sending at the same time the vibration motors speed to perform
; (using the previously read analog buttons position ( <- : large motor, -> : small motor )
; the more you press on these buttons, the more the corresponding motor vibrates fast
; some wireless PS2 controllers react only to the large motor command and some have no motor at all.
shiftout CMD,CLK,FASTLSBPRE,$1\8,$42\8,$0\8,Small_Motor\8,Large_Motor\8]
; we don’t care about reading the data from the controller here.
; so, why not use this to read PS2 data the first time? because it’s not working:
; as the PS2 controller is starting to send data just after receiving the
; “shiftout CMD,CLK,FASTLSBPRE,$1\8,$42\8…”<------here
; and as we are sending after that some data for motors “… ,$0\8,temp(7)\8,temp(8)\8]”
; it’s now too late to read all the data from the PS2 controller
; because there’s already some bytes sent by it and lost (no buffer here).
high SEL
;-----------------------------
;-----------Basic Micro IDE terminal----------
; sending carriage return (CR = 13) and the PS2 mode(hex) to the PC
;serout S_OUT,i57600,[13, hex2 mode\2] ; Basic Micro IDE <= 02.2.1.1
serout S_OUT,I8N1_57600,[13, hex2 mode\2] ; Basic Micro IDE <= 05.3.0.0
;serout S_OUT,i57600,[13, hex2 mode\2] ; Basic Micro Pro IDE <= 08.0.1.7
for index = 1 to 18 ; temp(0) contains a dummy variable so we don’t send it to the PC
; sending all the data to the PC
;serout S_OUT,i57600," “, dec3 temp(index)\3] ; Basic Micro IDE <= 02.2.1.1
serout S_OUT,I8N1_57600,” “, dec3 temp(index)\3] ; Basic Micro IDE <= 05.3.0.0
;serout S_OUT,i57600,” ", dec3 temp(index)\3] ; Basic Micro Pro IDE <= 08.0.1.7
next
;-----------------------------
goto main[/code]