Using Keyboard.spin for keyboard control for robot arm
Hi all, I'm new to using Propeller and new to the spin language.
I'm trying to program the board to accept keyboard command to control my robotic arm.
the keyboard demo .spin uses tv to display the Hex of the key pressed. I'm trying to achieve not displaying but rather a conditional keypress in C it would be something like this
pseudo code:
if kpress = $C1{ ;$C1 is left ... i think
robot arm will move left
}
because i have tried many method to detect the keypress value, the one in the demo uses "term.hex(keyboard.getkey)" is there other way to get the hex value rather than going through the TV/VGA (i'm using VGA) object.
Thank you and regards.
Note: i'm using AX-12 Smart Arm
I'm trying to program the board to accept keyboard command to control my robotic arm.
the keyboard demo .spin uses tv to display the Hex of the key pressed. I'm trying to achieve not displaying but rather a conditional keypress in C it would be something like this
pseudo code:
if kpress = $C1{ ;$C1 is left ... i think
robot arm will move left
}
because i have tried many method to detect the keypress value, the one in the demo uses "term.hex(keyboard.getkey)" is there other way to get the hex value rather than going through the TV/VGA (i'm using VGA) object.
Thank you and regards.
Note: i'm using AX-12 Smart Arm
Comments
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 keyboard = 26 OBJ key : "comboKeyboard" ' Keyboard Driver PUB Main key.start(keyboard) keyboard PUB keyboard | keystroke keystroke:=0 repeat keystroke := key.key if keystroke == 107 'l 'move robotic arm left if keystroke == 114 'r 'move robotic arm right
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Visit the: The Propeller Pages @ Warranty Void.
Thank you
There are all kinds of questions like this that will pop up along the way. Probably the best place to go to get templates for all kinds of functions is Mike Green's femtobasic and Oldbit's PropDos.
Rich
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Visit the: The Propeller Pages @ Warranty Void.
I just realised that you are using combokeyboard.spin as your driver,
"comboKeyboard" ' Keyboard Driver
i tested using keyboard.spin, there was no reaction from it.
where can i get a copy combokeyboard.spin (edit, i have found the driver for combokeyboard.spin by michael green)
edit: with combokeyboard i am still unable to detect the keystroke, will post my source soon
also, how do i open propdos 1.6 or 1.7b, not the usual extention i am familiar with
Regards
Steve,
P.S in the meantime i'll venture into femtobasic codes. thanks for the recommendation
Post Edited (stevetronik) : 1/4/2010 3:51:56 AM GMT
if kb.keystate($C0) == TRUE
{ robot arm will move left }
elseif kb.keystate($C1) == TRUE
{ robot arm will move right }
...
You find a list of all the hex values at the end of the Keyboard.spin file. If you open Keyboard,spin in a Tab and click on "Documentation" under the Tabs, you get a description of all the methods and hex values.
You need this codes only for the special Keys (Cursor, FunctionKeys..), for the 'normal' Keys, you can use "x" in Spin to get the ASCII value of x:
if kb.keystate("A") == TRUE
' do something
elseif kb.keystate("Z") == TRUE
' do something
And finally: combokeyboard.spin has the same functions as keyboard.spin, but works also with a Hydra Board.
Andy
It worked.
Edit: rather than posting another notice for this small question i have.
is there anyway to split and combine hexadecimal value
example
$03 and $FF into $03FF
and
$01FF into $01 and $FF
Post Edited (stevetronik) : 1/4/2010 5:31:17 AM GMT
($03 * $100) + $FF = $03FF
or you could shift $03 to the left 8 times then add $FF
To split the bytes you can use logical AND
low byte = $10FF AND $FF = $FF
high byte = ($10FF AND $FF00) / $100 = $03
var1 := $03 var2 := $FF var3 := var1<<8 + var2 '=$03FF var3 := $01FF var1 := var3>>8 & $FF '=$01 var2 := var3 & $FF '=$FF
Andy
Steve
http://www.youtube.com/watch?v=-xU8IUJ8SD4
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
···································Fix it, if ain't broke!
D Rat
Dave Ratcliff N6YEE
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
···································Fix it, if ain't broke!
D Rat
Dave Ratcliff N6YEE
another issue i forget to mentioned about in the pm was, that keyboard control isn't the final objective, keyboard control was just something i'm trying to make the board to regconise simple inputs to do 'set task' , the actual thing would be that the board would recieve instruction from another microcontroller or pc (i've being thinking of using hyper terminal to send and recieve instruction)
thought it would be related to the idynabus mike gebhard wrote although it writte to use with BS2 code and a Board of Education BOE board. (planning to use PC and the hyper terminal apps in windows to simulate BOE)
have you used idynabus.spin?