JohnJohn20
Advanced Member level 4
- Joined
- Feb 2, 2012
- Messages
- 111
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,296
- Activity points
- 2,377
Hi. QBasic is quite dated but I hope someone out there can help me with this.
I wrote this code to toggle the caps lock LED on my computer keyboard:
100
DEF SEG=0
POKE &H417, 0
DEF SEG
LINE INPUT "Lowercase", text$
DEF SEG=0
POKE &H417, 64
DEF SEG
LINE INPUT "Uppercase", text$
GOTO 100
And it works great. Whenever I hit return it toggles between caps lock on and caps lock off.
However, when I wrote this next code to do the toggling automatically:-
100
DEF SEG=0
POKE &H417, 0
DEF SEG
PRINT "Lowercase"
CALL OneSecDelay
DEF SEG=0
POKE &H417, 64
DEF SEG
PRINT "Uppercase"
CALL OneSecDelay
GOTO 100
The LED doesn't get toggled.
I did notice that if the CAPS LOCK is on AND "Lowercase" has just appeared on the screen AND I hit any key on the keyboard then the CAPS LOCK LED will toggle. (Also will if the CAPS LOCK is off AND "Uppercase" has just appeared on the screen)
That is, it seems, for the POKE command to have an effect on the computer I need to wake it up by typing a key (mouse buttons have no effect).
What can I do to make the auto toggling code work without any user input?
FYI My plan is to use the circuit from a USB keyboard to control things like motors and lights from my computer via the usb port similar to what can be done with a parallel port. Most keyboards have the 3 leds (outputs) and lots of inputs.
Thanks.
I wrote this code to toggle the caps lock LED on my computer keyboard:
100
DEF SEG=0
POKE &H417, 0
DEF SEG
LINE INPUT "Lowercase", text$
DEF SEG=0
POKE &H417, 64
DEF SEG
LINE INPUT "Uppercase", text$
GOTO 100
And it works great. Whenever I hit return it toggles between caps lock on and caps lock off.
However, when I wrote this next code to do the toggling automatically:-
100
DEF SEG=0
POKE &H417, 0
DEF SEG
PRINT "Lowercase"
CALL OneSecDelay
DEF SEG=0
POKE &H417, 64
DEF SEG
PRINT "Uppercase"
CALL OneSecDelay
GOTO 100
The LED doesn't get toggled.
I did notice that if the CAPS LOCK is on AND "Lowercase" has just appeared on the screen AND I hit any key on the keyboard then the CAPS LOCK LED will toggle. (Also will if the CAPS LOCK is off AND "Uppercase" has just appeared on the screen)
That is, it seems, for the POKE command to have an effect on the computer I need to wake it up by typing a key (mouse buttons have no effect).
What can I do to make the auto toggling code work without any user input?
FYI My plan is to use the circuit from a USB keyboard to control things like motors and lights from my computer via the usb port similar to what can be done with a parallel port. Most keyboards have the 3 leds (outputs) and lots of inputs.
Thanks.