| Controlling a robot with the arrow keys through the paralleput function? 
 
	 
	
		| Author | Message |   
		| kinian 
 
 
 
 
 | 
			
				|  Posted: Mon May 19, 2008 10:32 am    Post subject: Controlling a robot with the arrow keys through the paralleput function? |  |   
				| 
 |  
				| I have been assigned a project to control a robot with two motors which are connected to the computer with the parallel port cable. 
 I must find a way to control the robot with the arrow keys, (so forward, back, left, right, and a combination of those).
 
 I need some help corresponding the parallelput function with user-input arrow keys (this would be implemented into the GUI) . How would I go about creating something like this?
 
 Thank you for your help in advance.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| kinian 
 
 
 
 
 | 
			
				|  Posted: Wed May 21, 2008 5:10 pm    Post subject: Re: Controlling a robot with the arrow keys through the paralleput function? |  |   
				| 
 |  
				| bump |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| HeavenAgain 
 
  
 
 
 | 
			
				|  Posted: Wed May 21, 2008 5:27 pm    Post subject: RE:Controlling a robot with the arrow keys through the paralleput function? |  |   
				| 
 |  
				| i am assuming you would use 4 pins from your cable to set this up 
 that being said, you need to understand how does parallelput work in binary, which i think is 8 bits of info (for 8 pins) and you will need 4 of those, you could set it up like
 
 where L is left, R is right, F is forward and B is backward	  | code: |  	  | 0000 00 00
LL RR
 0000 00 00
 FB FB
 | 
 
 the rest all comes down to your coding, with loop and ifs, just like how you normally make a game (if you've never made a game with arrow keys, look up on the submission or tutorial to help you out)
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| kinian 
 
 
 
 
 | 
			
				|  Posted: Sat May 24, 2008 8:24 pm    Post subject: Re: Controlling a robot with the arrow keys through the paralleput function? |  |   
				| 
 |  
				| I don't really understand what you meant by your code, could you elaborate a bit? 
 This is what I have so far, I've decided to use the Input.KeyDown (key) command, but I can't seem to correspond it to the "KEY_UP_ARROW" :
 
 	  | code: |  	  | 
setscreen ("graphics:max;max;title:The Robot Vehicle Controller")
 setscreen ("nocursor")
 
 var key : array char of boolean
 var answer : string
 var font : int
 
 font := Font.New ("serif:42")
 Draw.Text ("Welcome to the Turing Robot Controller Program", 100, 800, font, magenta)
 delay (700)
 font := Font.New ("serif:30")
 Draw.Text ("Use the arrow keys of the keyboard to control the Robot", 200, 750, font, magenta)
 
 Input.KeyDown (key)
 
 if key (KEY_UP_ARROW) then
 
 | 
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| richcash 
 
 
 
 
 | 
			
				|  Posted: Sun May 25, 2008 3:28 pm    Post subject: Re: Controlling a robot with the arrow keys through the paralleput function? |  |   
				| 
 |  
				| Is your Input.KeyDown inside a loop? If you want it to continuously check for input it has to be in a loop. |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| kinian 
 
 
 
 
 | 
			
				|  Posted: Sun May 25, 2008 6:18 pm    Post subject: Re: Controlling a robot with the arrow keys through the paralleput function? |  |   
				| 
 |  
				| Yes, thanks I just realized that, also, I would be using pins 2,3,4,5  for the two motors, which parallelput (X) corresponds to these pins? I'm kind of lost there. I'll post the code I have so far, there are many errors regarding the parallelput function I'm sure. Thanks for your help! 
 	  | code: |  	  | 
setscreen ("graphics:max;max;title:The Robot Vehicle Controller")
 setscreen ("nocursor")
 
 var chars : array char of boolean
 var answer : string
 var font : int
 
 font := Font.New ("serif:42")
 Draw.Text ("Welcome to the Turing Robot Controller Program", 100, 800, font, magenta)
 delay (700)
 font := Font.New ("serif:30")
 Draw.Text ("Use the arrow keys of the keyboard to control the Robot", 200, 750, font, magenta)
 
 loop
 Input.KeyDown (chars)
 locate (25, 25)
 if chars (KEY_UP_ARROW) then
 parallelput (1)
 put "Up Arrow Pressed  " ..
 else
 parallelput (0)
 put "                  " ..
 end if
 if chars (KEY_RIGHT_ARROW) then
 parallelput (2)
 put "Right Arrow Pressed  " ..
 else
 parallelput (0)
 put "                     " ..
 end if
 if chars (KEY_LEFT_ARROW) then
 parallelput (4)
 put "Left Arrow Pressed  " ..
 else
 parallelput (0)
 put "                    " ..
 end if
 if chars (KEY_DOWN_ARROW) then
 parallelput (8)
 put "Down Arrow Pressed  " ..
 else
 parallelput (0)
 put "                  " ..
 end if
 end loop
 
 | 
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		|  |  
 |