Greetings from WPI! Here’s a video:
Desperate times call for desperate measures. I recently found out that a club at my school is essentially a hackerspace equipped with 3D printers so I could finally print enclosures for the PiPlanter and the DSFU. But that means I would need to finial the designs for both of them. I needed to find a way to interface with this thing here. So being the idiot that I am, I forgot a USB keyboard, I forgot an analog video cable, I forgot a monitor for the pi and forgot to update the Pi to the latest Raspian build.
What I did bring was an Easy Cap Capture Card in addition to my standard idea-kit which among other things consists of an Arduino Micro, some buttons, some resistors, and wire.
Essentially all I needed to do was connect the Pi to the EasyCap, and be able to send 4 different phrases to it over the keyboard. I needed to be able to send ‘pi’,’password’ (not my actual password), ‘ifconfig’ and enter. I realized that I could easily send this data to the Pi via the Micro as it has the Keyboard. functions built in.
As you can see in the video it worked! And I’m kind of stunned that it did. I can now SSH into the Pi.
Here’s the code for the Arduino:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
int uname = 3; int pass = 4; int command = 5; int enter = 6; int green = 7; int red = 8; void setup(){ pinMode(3, INPUT); pinMode(4, INPUT); pinMode(5, INPUT); pinMode(6, INPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); Serial.begin(9600); Keyboard.begin(); } void loop(){ if (digitalRead(uname) == HIGH){ Serial.print("1"); Keyboard.print("pi"); digitalWrite(green, HIGH); digitalWrite(red, LOW); delay(1000); } else { Serial.print("0"); digitalWrite(green, LOW); digitalWrite(red, HIGH); } Serial.print(","); if (digitalRead(pass) == HIGH){ Serial.print("1"); Keyboard.print("password"); digitalWrite(green, HIGH); digitalWrite(red, LOW); delay(1000); } else { Serial.print("0"); digitalWrite(green, LOW); digitalWrite(red, HIGH); } Serial.print(","); if (digitalRead(command) == HIGH){ Serial.print("1"); Keyboard.print("ifconfig"); digitalWrite(green, HIGH); digitalWrite(red, LOW); delay(1000); } else { Serial.print("0"); digitalWrite(green, LOW); digitalWrite(red, HIGH); } Serial.print(","); if (digitalRead(enter) == HIGH){ Serial.print("1"); Keyboard.press(KEY_RETURN); delay(10); Keyboard.releaseAll(); digitalWrite(green, HIGH); digitalWrite(red, LOW); delay(1000); } else { Serial.print("0"); digitalWrite(green, LOW); digitalWrite(red, HIGH); } Serial.println(""); delay(10); } |
Thanks for Reading!
Hi!
I am wanting to something like this now, when you have a moment do you think you could post a few pictures of how it’s all wired? It would be very much appreciated 🙂
Thanks,
Robbie
Thank you for your post.
At 2:46 in your video, you unplug the USB-A connector from your laptop and plug it into something labeled “DYNEX” which is plugged into the R-Pi.
I searched https://www.dynexproducts.com but didn’t find anything like it.
Can you explain what the part is or provide a link to it?
Hi! The Dynex device is an SD card reader, and I’m not plugging the keyboard into that, I’m plugging it into the USB port on the Raspberry Pi. Make sense?
I have a question I wonder if you might be able to help me with: I am trying to get a key command into a Pi to advance videos in VLC, using an Adafruit Itsy Bitsy (Ardruino Micros were out of stock). The key commands are working just fine when the board is plugged into my laptop, but the Pi doesn’t seem to be receiving them. Any idea why that might be? Thanks!
Very weird. I did some googling and found this link, maybe try some of the suggestions here? http://mheironimus.blogspot.com/2015/09/linux-support-for-arduino-leonardo.html