This webpage prototypes solutions and simulates using JavaScript. Alternative solutions can be tried, and this avoids reprogramming devices
The Digispark can be configured as a HID Keyboard. Also ATMEGA32U4 boards:- Arduino Leonardo, Bad Beetle Pro Micro, OTG connectors and cables and a Wire to disable typing, can be used. Useful for auto testing a typing app.
LeonardoAutotypeFlipFlopWiredOr.ino
My AutoTyping kit. DigiSpark, ATMEGA32U4 boards:- Arduino Leonardo, Bad Beetle Pro Micro, OTG connectors and cables and a Wire to disable typing. :-
The Digispark and Arduino Leonardo can be configured as a HID Keyboard. Useful for auto testing a typing app.
It has a USB port for the HID and three pins.
There are three pins P0, P1, P2. P1 has an LED so use as an output.
P0 and P2 also have weak pull up resistors.
We want an ASTABLE - when one end is typing, the other end backs off. Turn the LED on when Typing, if the other end has LED on, back off typing.
Also ONE_SHOT operation typing a sentence the stop.
Also CONTINUOUS typing a loop.
* * timeline:- * | pause | typing |GA| PAUSE | typing |GA| PAUSE * | typing |GA| PAUSE | typing |GA| PAUSE | typing * * LED|-----------|___________|--------------|___________|-------- * LED|___________|-----------|______________|-----------|________ * * At the end of the sentence type GA - Go Ahead to handover to the other end * ----|----|----|----|----|----|----|----|----|----|----|----| +---------+ |DigiSpark| +---------| P2 |==> USB HID keyboard | +-------| P1 LED | | | +----| P0 I/P | | | | +---------+ | | +-- /DISABLE P0 is used to disable typing | | P1 is LED output | | P2 is Fast / slow | | +-- /DISABLE | | | +---------+ | | | |DigiSpark| | | +----| P0 | +---------| P1 LED | +-------| P2 I/P |==> USB HID keyboard +---------+ enable pullups on the inputs. ----|----|----|----|----|----|----|----|----|----|----|----| The units type either fast or slow. When TYPING turn on the LED LED __^--- Start of typing - back off LED --v___ GA invitation to start typing There is a deadlock if both ends are not typing and the LED is off. So run a watch dog timer and pulse LED if it matures to kick other end. Pragmatically it is easier to let them free run. set up different text at each so the loop takes a different time. ELSE alternatively let one be the master and the other slave. On the slave enable typing when the master is not. "1" --- [ p0 master p1] --- [ p0 slave p1 ] ---
Inputs: P0 HALT - stops typing - needed for reprogramming. P2 TYPING - hold off starting typing, type to end of sentence. Output: P1 TYPING - Indicated Unit is TYPING SENTENCE. * Type till end of the sentence * Hold off starting until IDLE on P2 * If interconnected, P1 output => P2 input * Use weak pull ups on inputs. P2 HIGH when IDLE, so P1 HIGH when IDLE P0 input HALT - use to stop typing to reprogram P2 input HIGH = IDLE - default Pulled up. P1 output LED OFF when TYPING, ON WHEN IDLE modules [ holdoff logic ] states: ( not typing ),( typing ), ( handover Sequence ) [ typing engine ] - type up to GA [ UC1 ] [ UC2 ] two micro controllers programmed as HID keyboards Code expriments in JavaScript on this webpage. process1() is called on a timer tick processUC_1(), processUC_2(), processUC_wiring() is called on a timer tick
-----+-------+---- Wired OR buss using Weak Pullup resistors | | [ UC1 ] [ UC2 ] two micro controllers programmed as HID keyboards // // processUC_1 is instance 1 in one micro controller // processUC_2 is instance 2 in another micro controller // processUC_wiring is interconnect wiring // // [ processUC_1 ] , [ processUC_wiring ] , [ processUC_2 ] // ----|----|----|----|----|----|----|----|----|----|----|----| +---------+ |DigiSpark| +---------| P2 W-OR |==> USB HID keyboard | +-------| P1 LED | | +----| P0 I/P | | | +---------+ | +-- /DISABLE P0 is used to disable typing | P1 is LED output | P2 is Fast / slow | +-- /DISABLE | | +---------+ | | |DigiSpark| | +----| P0 | | +-------| P1 LED | +---------| P2 W-OR |==> USB HID keyboard +---------+ ----|----|----|----|----|----|----|----|----|----|----|----| P0 input HALT - use to stop typing to reprogram P2 Wired OR buss - Assert low while typing, Holdoff starting typing till high. P1 output LED OFF when TYPING, ON WHEN IDLE