0

Hey,


I'm new to the forum, so hello everyone. I am indeed a n00b when it comes to software dev, so please help! ;)

Well I'm doing a hack controlling an RC toy through the parallel port, I am learning about circuitry, etc. at the moment and have just been focusing on that... I did not realise how hard it would be to find a suitable program to control the parallel port how I wish, here is what I want to do:

Data 0 & 1 - Be able to continuously leave on 5v or 0v

Data 2 - Have it go to 5v when the "Q" Key is pressed, then back to 0v when the key is no longer pressed.

Data 3 - Have it go to 5v when the "A" Key is pressed, then back to 0v when the key is no longer pressed.

Data 4 - Have it go to 5v when the "W" Key is pressed, then back to 0v when the key is no longer pressed.

Data 5 - Have it go to 5v when the "S" Key is pressed, then back to 0v when the key is no longer pressed.

Data 6 - Have it go to 5v when the "E" Key is pressed, then back to 0v when the key is no longer pressed.

Data 7 - Have it go to 5v when the "D" Key is pressed, then back to 0v when the key is no longer pressed.


So I am asking if anyone knows of any parallel port control programs that allow you to assign a hotkey to each pin?, if not... I know virtually NOTHING about coding, but does anyone know how I'd best go about doing the above, if there’s source code for a parallel port program that I could easily modify to do the above? Or if it is quite simple and someone could whip one up, I'd be happy to give you a paypal present =P.


Any help would be greatly appreciated!


(I am on Windows XP btw)

3
Contributors
5
Replies
6
Views
10 Years
Discussion Span
Last Post by smasher3189
0

Public address As Integer 'to store the parallel port address
Public x As Integer
Public output As Integer 'to store the value to be output to be put to the parallel port
Public up, down, lleft, right As Boolean 'to keep track of which buttons are already pressed
Private Declare Sub DlPortWritePortUchar Lib "dlportio.dll" (ByVal Port As Long, ByVal Value As Byte)
'make sure you put dlportio.dll and dlportio.sys into the /windows/sytem32 folder ... or install my rc car software. That'll do it for you.

Private Sub exit_Click(Index As Integer)
Unload Me
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'------------------------------------------------------------------'
'This section of code detects which key is being pressed. Once the
'key is pressed, it changes the colour of the label to red and adds the
'correct value to ouput. 1,2,4,8 are the correct values. To write
'to the parallel port, it's done in binary. 1 in binary is 00000001
'2 in binary is 00000010, 4 in binary is 00000100, 8 in binary is 00001000
'so by saying "out DlPortWritePortUchar, 4" we are actually turning on one pin of the parallel port
'If we say "out 888, (1+2)" or "DlPortWritePortUchar 888, 3" we are turning on two pins, pins 1 and 2.
'-------------------------------------------------------------------'

If KeyCode = vbKeyUp And up <> True Then Label1.ForeColor = &HFF&: output = output + 1: up = True
If KeyCode = vbKeyDown And down <> True Then Label2.ForeColor = &HFF&: output = output + 2: down = True
If KeyCode = vbKeyLeft And lleft <> True Then Label3.ForeColor = &HFF&: output = output + 4: lleft = True
If KeyCode = vbKeyRight And right <> True Then Label4.ForeColor = &HFF&: output = output + 8: right = True
Label6.Caption = output 'This is only for debugging. This is the value that is output to the parallel port
DlPortWritePortUchar address, output 'The command to output to the parallel port
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
'------------------------------------------------------------------'
'This section of code detects when a pressed key has been lifted.
'changes the label's colour back to black and subtracts a value from
'output. It does the opposite of the keydown code, in that it turns
'off a parallel pin rather than turning it on.
'-------------------------------------------------------------------'

If KeyCode = vbKeyUp Then Label1.ForeColor = &H0&: output = output - 1: up = False
If KeyCode = vbKeyDown Then Label2.ForeColor = &H0&: output = output - 2: down = False
If KeyCode = vbKeyLeft Then Label3.ForeColor = &H0&: output = output - 4: lleft = False
If KeyCode = vbKeyRight Then Label4.ForeColor = &H0&: output = output - 8: right = False
Label6.Caption = output 'This is only for debugging. This is the value that is output to the parallel port
DlPortWritePortUchar address, output 'The command to output to the parallel port
End Sub

Private Sub Form_Load()
'Just setting stuff up:
address = 888 'Parallel port address. Change to whatever it needs to be.
'Note: 888 in decimal is 0x378 in hex. Other popular addresses are 658 and 956.
output = 0 'starts output off at 0
Label6.Caption = output
DlPortWritePortUchar address, 0 'makes sure nothing it being output to the parallel port as soon as the program starts.

End Sub

'you can change hotkeys according to your need

Edited by santoshaxl: extra coding not suitable

0

'Inp and Out declarations for port I/O using inpout32.dll.

Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" _
(ByVal PortAddress As Integer) _
As Integer

Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" _
(ByVal PortAddress As Integer, _
ByVal Value As Integer)


'add module to above coding

0

you can download Wndlpt to control the output of the lpt port but the problem is the control botton is not the letters q,a,s,d instead its 1,2,3,4,5,6,7,8,9,0,-,=

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.