I want to code something like;
if x key is pressed
than something happens
with arduino IDE only please ![]()
I will appriciate any answers and would love an explanision too ! thanks
I want to code something like;
if x key is pressed
than something happens
with arduino IDE only please ![]()
I will appriciate any answers and would love an explanision too ! thanks
Welcome to the forum
Is this a key on the PC keyboard or a key/button attached to the Arduino ?
Which Arduino are you using ?
hello ! I am using arduino uno
and I want to press a physical key on my keyboard attached to my laptop.
Would it be acceptable that the key pressed on the PC is the Return key or do you need to detect one of many different keypresses ?
I need more sorry
I need about 6 different ones probably
Would it be acceptable to have the user press a key followed by Enter or must the user only press a single key ?
You cannot do the latter with the Arduino Serial Monitor but you can do it with other terminal emulators. Would using a terminal emulator program on the PC be acceptable ?
char strings (one or more chars) can be passed to the Arduino from the PC using the IDE's serial monitor. but as mentioned, it only sends the string after the Enter key is pressed.
other terminal emulators available on the PC can be used that do not have this restriction. they would be run on the same com port used by the IDE and the IDE would have to be terminated when used
Hello
Try this a kickoff for you project.
void setup()
{
Serial.begin(9600);
}
void loop()
{
if (Serial.available())
{
switch (Serial.read())
{
case 'x': Serial.println(F("than something happens for x")); break;
}
}
}
Have a nice day and enjoy programming in C++ and learning.
compiled, linked and test on an Arduino Mega:
Sketch uses 1826 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 188 bytes (2%) of dynamic memory, leaving 8004 bytes for local variables. Maximum is 8192 bytes.
It would have been more helpful if you had copied the full error message using the handy button in the IDE and pasted it here in code tags
The F() macro only works on string literals. Change the line to something like:
case 'x': Serial.println('x'); break; // single character
or
case 'x': Serial.println("x"); break; // string literal
or
case 'x': Serial.println(F("x")); break; // string literal in PROGMEM
I know you said Arduino only but Processing makes this a snap and works really well. Have an old laptop lying around? The Arduino IDE was based on Processing IDE I think; in fact, it's even easier to work with (no hardware element to trip you up really).
Then just create a function called
void keyPressed(){}
and insert whatever you like, such as
if (key == '+'){
myPort.write('j');
}
and listen for it on your Uno using Robin2's receive one char method here on Arduino forum
Oh I should have kept reading down. Yeah, you'll want to use Processing for this. Then you can add in anything else, too. Gif animations, music, pictures, text, whatever.
As is almost usual here we don't actually @pinknami really wants beyond using an Arduino to detect a keypress on a PC with the stipulation
which is not possible
Using Processing would introduce a complication that I think that he/she can do without whereas downloading a simple terminal emulator such as Coolterm involves no programming after installation, merely the selection of the correct serial port and you are in business
@pinknami more details please of what you are doing and why you need to use the PC keyboard attached to your laptop when it would be easier to use a keypad directly connected to the Arduino for input or even a touch sensitive screen.
As you have stipulated that only the Arduino IDE may be used then I presume that there is no software running on the PC connected to this project
Oh, for sure UKHeliBob. I caught that stipulation, but I also am usually pretty good at getting to the root of the problem to overcome (my job depends on it). That means I often default to a parallel path/thinking outside the box because we all know what everything look likes if your only tool is a hammer. Not saying yours is by any stretch, but you know what I mean.
My input is take it or leave it, also it may provide help to someone else looking to solve a similar problem in the future as they exercise their Google Fu in frustration.
Scenario where I see Arduino IDE being the only option, given that @pinknami has already resolved to use the PC anyway: school project and this is required by the teacher. And if that's true, I say PSHAW! let's shoot for an A+ by showing the teacher something else they might not know yet is very useful.
CoolTerm is cool, for sure, it also doesn't satisfy the Arduino IDE only condition either and IMO, is no less complicated than getting Processing up and running. In fact, with Processing, you set it up, it finds the Arduino the PC has already assigned to COM port X and click run. With CoolTerm, I find it cumbersome to go between it and Arduino IDE if you make code updates and such. Plus, there's SO much more you can do with it and if you can Arduino, you already can Processing. Void loop() becomes void draw(), until you get into higher levels of complexity, the difference between working in the C++ based Arduino IDE and the Java based Processing environment are non-factor.
Lastly, there's no real installation required in Processing either. I run mine as portable all the time off a micro SD card as long as the host machine has Java installed.
So my question to @pinknami would be this: do you want to make Pong or do you want to make Doom Eternal?
Ok actually lastly, @UKHeliBob I have lots of respect for your great contributions to this forum. You clearly know your stuff, probably much more than I do. I'm not saying your solution is wrong and it may even be better in this scenario, all I'm saying is there's lots of tools out there for anyone looking to think outside their initial design idea. My current one, since it bears on this convo (and you might dig it), ultimately uses RC aircraft FPV gear to take the video (Kinect interactive game - 1/2 kung fu moves tracking, 1/2 Fruit Ninja type thing and gif animations, speech interaction, music) from
an Arduino/Processing build and transmit the Processing sketch display to a projector to create a virtual arena for a battle against a 5 foot robot armed to the teeth with Nerf in my driveway this coming Halloween, once you get that done, on to the pumping techno laser maze with interactive video elements in my garage, also a Processing/Arduino build. All using pretty much the same technique I initially described in this thread, except instead of key presses, I use sensor inputs to either the Arduino (laser maze) to trigger video display stuff and more, or the Kinect inputs to the PC to the Arduino). Where do you want to go? You want a paper airplane or a 1/6 scale Lancaster?
Oh, it fully is possible. CoolTerm is what my Fallout 3-inspired terminal does - exactly this. It sits in the back of the laser maze I mentioned. I used the Password library. @pinknami would have to find it and adapt the code below (not the doge - the terminal one -sold separately, just kidding, free as in gratis, open source and the like) - to their needs.
@pinknami
Check one of my other spam posts. Well, spam unless you find it useful which I hope you do. In case you don't, have a doge. This might be fun for some low res graphics triggered by your key press, or just a splash page in your setup(). Just a thought since I'm resting my own puzzler trying to solve my own coding dilemma, totally unrelated to this. Good luck.
/* Resource to copy and paste ASCII based artwork into Arduino Serial monitor (or better,
* another terminal emulator such as CoolTerm), for prettyprinting, low res graphical
* effects.
*
* ASCII .jpg to ASCII art conversions courtesy of glassgiant.com
* use a monospaced font, such as Courier for better appearance since all characters same width.
*
* February 09, 2020
* hallowed31
*/
void setup() {
Serial.begin(115200);
while(!Serial);
Serial.println(" asciiArt1_Animals");
fiveLine();
delay(1000);
}
void loop() {
doge();
//lambsheep();
fiveLine();
delay(10000);
}
void fiveLine(){
for(int i = 0; i < 5; i++){
Serial.println("");
}
}
void tenLine(){
for(int i = 0; i < 10; i++){
Serial.println("");
}
}
void doge(){
Serial.println(" 7 77IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII??????+++?+++++++++?????++++??7777 ");
Serial.println(" 7IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?????++=+?+?+++++++?++???++++++?777 ");
Serial.println(" 7IIIIIIIIIIII?++++?IIIIIIIIIIIIIIIIIIIIIIIIIII????+==+??I????????+++++++++++++77 ");
Serial.println(" 7IIIIIIIIIIII=~====?IIIIIIIIIIIIIIIIIIIIIIIIII????===+????????????++++++++++++?7 ");
Serial.println(" IIIIIIIIIIII+~:~===++?IIIIIIIIIIIIIIIIIIIIIIII??+====++?IIII???????+???++++++++I ");
Serial.println(" IIIIIIIIIIII=~~~===+=+?IIIIIIIIIIIIIIIIIIIIIIII?=====++??????????I??????????++++ ");
Serial.println(" IIIIIIIIIII?~~~=======++?IIIIIIIIIIIIIIIIIIIII?+===~=++????????????????????????? ");
Serial.println(" IIIIIIIIIII+~~~~~~~===~~++?IIIIIIIIIIIIIIII??+====~=+=++?????????????????III???? ");
Serial.println(" IIIIIIIIIII+~=~~~~~====~===?III?????+??+++++++++++++===+++++++++?????????????III ");
Serial.println(" IIIIIIIIIII=~=~~::~~~~==:~=====++++++++++++++++++++++++++=============+++++????? ");
Serial.println(" IIIIIIIIIII=~~=~:,,::~==~:~==~++=++++++++++===++++++????+++==================+++ ");
Serial.println(" IIIIIIIIIII+~~=~:,,:~====~~~~+++=+++++++++=====++++????????++=================== ");
Serial.println(" IIIIIIIIIII?====~:,,:~~=~~~=++++++++==++++++====+++???????????++++============== ");
Serial.println(" IIIIIIIIIIII=====~::,,~==~=++++++++++++++++++====++??????+????????+=+=========== ");
Serial.println(" IIIIIIIIIIII+~====~:,,,~=+++++++++=++++++++++=+==++?????????????????+++========= ");
Serial.println(" IIIIIIIIIII?+=~,===~~~=++++++++++==++++????++====+++????????????????+++++======= ");
Serial.println(" IIIIIIIIII??+=========++++++++++====+++?+????+=====++??++=~~+?????????+++++++=== ");
Serial.println(" IIIIIIIII??+=~~~===++++++++++=====+++++?+????+++==++++?=,:.+==??II??????????++++ ");
Serial.println(" IIIIIIIII?++=~~~==++++++++++++===+++++=++????++++++?+++=,,.,,+?II7II???I???????? ");
Serial.println(" IIIIIIII?+++=~~==++++++++++++++++==:...~,:=+++++??+???++=,::~~?III7II?????II???? ");
Serial.println(" IIIIIIII?++==~~==+++++++++++++++=~,.,,,:?~,:~==++?????++?+=~=+???I7III?????????? ");
Serial.println(" IIIIIIIII++=====++++++++++++++++++:,,...~+:,:~=++???????+????+???IIIIII????????? ");
Serial.println(" IIIIIIII?++====++++?++?????????????~,,,,=,,:===++??????????????+?IIIIII????????? ");
Serial.println(" IIIIIIII?+==+=+++++???????????????++?+===++++++++???????+?????IIIIIIIIII???????? ");
Serial.println(" IIIIIIII?++++++++????????+????????++++++++++++++????????++=~====+IIIIIII???????? ");
Serial.println(" IIIIIII?++++++++???????????????????+++++++??+??????????=:::~:,,,,,IIIIII??++???? ");
Serial.println(" IIIIIII?+++++++?????????I??I??????????????????????III?+,,,...,.,.,?III?II????+=~ ");
Serial.println(" IIIIII?+++++=++++?????????????????????????????????????=,,,....,,,++III?II??++=~~ ");
Serial.println(" IIIIII?+++++==++++????????????????????I???????????????+:,..,.,.,,,+IIIIII??+?+++ ");
Serial.println(" IIII??++++++===+++++++++?????????????????????++?????+=+=~:,,,,.,,~=???II????++?? ");
Serial.println(" IIII??++++++====++++++++++???????????????????++++++?+?++~::,,,,::~=+??III??++++? ");
Serial.println(" IIII??+++==+====+++?????++++???++++?????????++++++++?+++=::::~:~~~=+??III???++++ ");
Serial.println(" IIII?++++=======+++++??????+++++++++++?+?+++=+=++++++=+~::~:....,~+???III??+++++ ");
Serial.println(" IIII??++===+++===++?????????+++???++++++++++====++++++=~....,,,:::?I???II??+++++ ");
Serial.println(" III?++++=========+++????????????+???++++++++=~::,,,,:.,,:,,:,,::=+???IIIIIIIIIII ");
Serial.println(" II??++++=========+++++???????????????+++++?++=~~~~::::::~~~::~~=+???IIIIIIIIIIII ");
Serial.println(" II?++++=========+++++++??+++???????+++++++++++++=======++===~=+?????IIIIIIIIIIII ");
Serial.println(" II?++++===~========+++++++???????+++++++++++++++++++++++++++++???????IIIIIIIIIII ");
Serial.println(" II?++==+=============+++++++????????++++++++++++++++++++++????????????IIIIIIIIII ");
Serial.println(" I??+++=============+==+++++??++???????+++++++++++++++++????????????????IIIIIIIII ");
Serial.println(" I??+++=======~~~=====+++++++++?+???????++++++++++++++++??+++???????????IIIIIIIII ");
Serial.println(" I??++++++++========+++++++++++++????????++++++++++++++++++++???????????IIIIIIIII ");
Serial.println(" II???+++++++========++++++++++++++??+++?++++++++++++++++++++????+???????IIIIII?I ");
Serial.println(" II??++++++++++=====+++++++++?++++++++++++++++++++++++++++++?+++++???????IIII???? ");
Serial.println(" II?????????+++++++++++++++++++??++++==++++++++++++++++++++++++++?????????II????I ");
Serial.println(" II???????????????+===++++?++?+++++++++==++=++=++==++++++++++++?????????II??????I ");
Serial.println(" II?++??????????????++++?+++++++?????+++++================++++?????????III?????I7 ");
Serial.println(" 7I?+?+?????????????????++++?++++?++?????++++=====++++=++++++++??????IIIII?????77 ");
Serial.println(" 77I++?????????????????????????+++?++++?+???++++++++++++++++++??????IIIIII???777 ");
Serial.println(" 7777???????????????????????++++?????+???++++++++++=++++++++++???????IIIII?I7777 ");
Serial.println(" 777 777I???????????????????+?????+?+?+??????++++++++++++++++????????III7777 7 ");
}
void lambsheep(){
Serial.println(" ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::::::::::::::::~~~~~~~~~~~~~~~~~:::,,,,,,,,::~~~~=~~===++??IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII ");
Serial.println(" ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::::~::::::::::~~~~~~~~~~~~~~~~~~~~~~~~~~====++++++++++++++????IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII????IIIII ");
Serial.println(" .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::~~~:::::::::~~~~~~~~~~~~~~~~~~~===+++++++?????????????++????IIIIIIII???????????IIIIIIII?????????????????? ");
Serial.println(" ,..,,,,,,,:::,,,,,,,,,,,,,,,,,,,,:::::::::::::~~~~~~~~~~=~~~~====++++????????????????????+++???IIIIII??????????????????????????????????????? ");
Serial.println(" ~:::::::~~~~~~::::::,,,,,,,,,,,,::::::::::~~~=====~~~~=========++++?????????????????+++++==++????IIII??????????????????????????????????????? ");
Serial.println(" ~~~~~~~~~====~~~~~~::,,,,,,,,,::~~~~~~======++++++==~=========++++++???????+++++++++=====~==+??????????????????????????????????????????????? ");
Serial.println(" ~~~~~~~~~~~=====~~:::::~~~====+++++++++++++++++?++==~~==========+++++=======================++????????????????????????????++++++++++++++++++ ");
Serial.println(" ~~~=====~:,:~~~~~~:~==++++????????????+++++++???++==~~~~~===========================++++++++++??????????????++++++++++++++++++++++++++++++++ ");
Serial.println(" :::::~~~:,,,,:::,,~=+?????????IIIII???++++++++++++==~~~~~~~~~~~~~~~~===========+++++++++++++???????????????????????????????????????????????? ");
Serial.println(" ,,,,:~~::,,,,,,,,:=+????????????????+++===========~~~~~~~~~~~~~~~~~====++++++++++??????????????II????I????????????????????????IIIII????????? ");
Serial.println(" .....,,,,,,,,,,,:~=+?????????????+++++==~~~~~~~~~~~~::~~~~~~~~~~~~==++++?+++++++?????????????IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?????? ");
Serial.println(" ......,,,,,::,::~==++++++++++++=========~~~~~~~~::::::~~~~~~~~~~~==+++????+++++??????????????IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII??????? ");
Serial.println(" ,,,,,,,,,,,,::::~============================~~~:::::::~~~~~~~~~===++??III??+++++?????????+??IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII?????????? ");
Serial.println(" ,,,,,,,,,:::~~~~~==============+?IIII?++++++===~:::::::~~~~~~??I+I7777777777777IIIII??+++++++??IIIIIIIIIIIIIIIIIIIIIIIIIIIIIII???????+++++++ ");
Serial.println(" ,,,,,,,,::~~~==========++++++7I?+++++++++?II++==~:::~~~~~~=II777I77777777777777777I7II?=====+??IIIIIIIIIIIIIIIIIII7IIIII???????????+++++???? ");
Serial.println(" ,,,:~~:~~===+++++++++++++???II+=+==========++II=~::::~~~~?I777777777IIIIIIII777777777II=~~~~=+??IIIII??+++++=====+++I???????????????++?????? ");
Serial.println(" ,,~~=====+++++++++????????????+++==========~=++I?~~:~~=+77777777777IIIIIIII77777II77777?+====++?III+=======~===~==+++?IIII??????????????IIII ");
Serial.println(" :~=+++++++???????????????????I+++===~==~~===~=++?I+~~?777777777777III77777777777777777II7I+++?+II?+=~~=~~:~~=+=+???++I??????????????????II?? ");
Serial.println(" =+++???????????????????????????++++=+=~,,,:~~~~=+?IIII7777777777777777777777777777IIIIIII7I??77I?==~~~:,~::~+++???++??????????I????????????? ");
Serial.println(" =++??????????????????????????+??==+++===~:,..,:~=++??I77777IIIIIII77777777777IIIIIIIIIIIIII77II?+=~::...:=++?????++I????????II?????????????? ");
Serial.println(" ++++??????????++++++++++++=====+I======~~::~:~::~===I?IIIIIIII7777777777777777777???IIII??I?++++~:,,,:~=~==+++++=?I???IIIIIIIIII?????I??IIII ");
Serial.println(" ===+++++++++++++=======~~~~~~~~~=?=+==~~~~,,.,:,:~~+I==~+?IIII777777777777777777I????I?++??====~:,::::.,==+???==??IIIIIIIIIIIIIIIIIIIIIIIIII ");
Serial.println(" ~~~=============~~~~~~~~~~~~~====+?==++==~~,,.,,,.:~~,...~II7777777777777777777II???II?+~,,~?~,,,.,.::=+++??+=?IIIIIIIIIIIIIIIIIIIIII?IIIIII ");
Serial.println(" :~~~~~~~~~~~=~~~~~~~~==========+++++====~:,:~:~~~:,:~+==~=+I77777777777777777IIIIIIIII+:...:,:..,.,,:~==++++=?IIIIIIIIIIIIIIIIIIIIIIIIIIIIII ");
Serial.println(" ::~~~~~~~====~~~=======++++++++++++++?=+========~~~~=???I??+?7777777777777777III???II+~,,.~,:~:~~===~:=+??=?IIIII?IIIIIIIIIIIIIIIIIIIIIIIIII ");
Serial.println(" ~~~~~========~~~==+++++++++++++++++++=+++++++===~=~==?III?IIII777777777777777IIII???+==++:+::::~~==+++??+?IIIII?IIIIIIIIIIIIIIIIIIIIIIIIIIII ");
Serial.println(" ~~~~======~~~~~==+++++++++++++++++++==========~~~~~=+II??II77I777777777777777III????++?++++~=????+???IIIIIIII?II?IIIIIIIIIIIIIIIIIIIIIIIIIII ");
Serial.println(" ~~~~~~~~~~~~:~~==+++++==++++++++++============~~~:=I??IIIIIII77777777777777777IIII?????++=+???++++???III?IIIII?????IIIIIIIIIIIIIIIIIIII?IIII ");
Serial.println(" ~~~~::::::::::~~=+========++++++===~~~=========~~+II?+?IIIII777777777777777777III??II???++???++++=+???IIIIII????????????IIIIIIIIIIIIII?IIIII ");
Serial.println(" ::::::::::::::~~~~=~~~~~========~~~:~~~========~~?II++??IIII777777777777777777IIII?I????++??????+=~+??IIIIII????++++++??????IIIIIII????????? ");
Serial.println(" ,::::::::::~::::~~~~~~~~~~~~~~~::::,::~~=======~=I??+=???III7777777777777777777IIIII????++~+?++?+++++????????++++====+++??????????????????++ ");
Serial.println(" :::::::::::~:~~~:~~~~~~~~~~:::::,,,,,,:~========II??++??IIIII77777777777777777II7III??++++=+?+???+++++?????+++===~~~==+++++???????++++++++== ");
Serial.println(" ,,,,:::::::~~~~~~~~~~~~~~::::,,,,,,,.,,:~~===~=?II?++++?IIIIIII77777777777777IIIIII???+?++=+++++?++++++++++============+=+==+++++++=~~==+=~~ ");
Serial.println(" ,,,:::~:::::::::~~~~~~~~~:::,,,,,,,..,::~~~~~=?I????+=+?IIIIIII777IIIIIIIIIIIIIII?????+?+++=?++++????++==~=======~~~~~====~:~=+++++++===+=~~ ");
Serial.println(" ,,,::~~:::::::::~~~~~~:::::,,.....,,,,::~~~~~~??I??+++??IIIIIII777??IIIIIII????+I???+?+?+=++??++==++++++=~~=====~~~::~~~=~:,,::=++++++++==~~ ");
Serial.println(" ,,,::~~::::::::::~~~~~::::::,,,,,,,:::::~~~~~~=???++????IIIIII7777I+:,+III?+~,.=II?+??+++====+?++==+++++++=~~~~~~:::::~~=~:,,::::=+?+++?+=~~ ");
Serial.println(" .,,,:::::::~:~~~~~~~~~~~::::::::~~=++++++++++??I?+?=???????III77777I?+??+?:.,=?+II+?+?+++++=+=+?+=~~~=++++=~:::::::::~~~~~::::::::~=+++??+=~ ");
Serial.println(" ..,,::::::::::~~~~~~~~~:~:~~~=+++++++++++++++II??+??++?????IIII777III??????++???II+++?==++=+=+??+=~~::=+===~:::,,::::~~==~:::::::::::+++??++ ");
Serial.println(" ..,::::::::::::~~~~~~~~~=====+++++++++++++++?I?????++++???????IIII???+++??????+???++++==+=+=++?++=:::::~==~~::::,,:,:~~==~::::::::,,::~++?++ ");
Serial.println(" .,,,:,:::~~:~::::~::~===+++++++++===~~~~~~=+?I???++?+++++?????I+?++++==:??++++++?+===+=+++==++?++=::::::~~~~:::::,,::~====::::::::,,,::=++?? ");
Serial.println(" ,::::::::~~~~~~~~~===+++++=====~=======~~==+?I?++?+++++??????IIII???I?+=~~=~~~==+~==~==+=++==+?++=::~~~~~::::::::::::~====::,,,,,:::::~=++?? ");
Serial.println(" ::::::::~~~~~~~=====++++==~~~~~========~=+?III???=+++?+??I????III???III??=.,:~~+=========++++??+==~:~~~~:::::::::::::~====:::::~::~==++++??? ");
Serial.println(" :::::::~~~~~~====++====~~~~~~~======+====?IIII??+++++?++??????77????II??+,:~~=?==++======~=+=?++++~~~~~~::::,::::~~~~~====~~~~~~=++++++++?++ ");
Serial.println(" ~~::,::~~:~=========~~~=~~=====+=++=+?++?IIIII??+++=+==~?+++??I7I?+??++~,~~=++?+++========~=++?+++=~~~~~::,,,::::~~~~~====~~==+++?++++==++++ ");
Serial.println(" ~~~~::~~~~=========~~~~====+???III777IIIIIII??+=~=+?++++~+==+??II?+=+=::~~~==+++=+~~~~~~~~==+?++++==~~~~:::::,::::~~~======++++++++=~~==++++ ");
Serial.println(" ~~~~~~~~==============+?II77777777777I7IIII?++===+?++==~=~=====?++===~:::~~~=?====::::::~:=+++++++====~~~~~:::::::::~==+++++++++=~~~~==++++= ");
Serial.println(" :~~~~~~=============?I7I777777IIIIIIIII7IIIIIII?+?+++===~++===+~=+=~~:::,~~~+~~~::::,,:,,:~=+?++++=====~~~~~~~~~~~~~=++++?++==~~~~~=++++==== ");
Serial.println(" :~~:~=+==+++++=+?III7777I77IIII7IIIIIIIIIII?????++==+++=+++=+~==~~~~~~~:::::,::,,,::::~,:~=+++=++++=======~~~~~==+++++++++==~~:~~==++++===== ");
Serial.println(" ~~~~=++?+?II7I7777I77777IIIIIIIIIIIIIIIIIIII???????=++++++++=+=~:~~:,,,:::,,,,,,,::~~~~~~++++?+++++=====~~~~=++++++++++===========+++=~~:~~= ");
Serial.println(" +????IIIIIII7777IIIIII?II?III?IIIIIIIIIIIIII???????=+=++?+=~+=~~==~~:~::,,,.,:.,,:::~=~:~++????++++====~~==++?+++?++=~====++++++++++~,,,::~= ");
Serial.println(" 77II777III77IIIIIIIIIIIIIIIII??I?III??IIIII??????+++~~~++++===~=~=~,~=::::.::,,,,.::~=:~=~++????+++==~~=+++++????++==~====++???++++=~~~~==== ");
Serial.println(" II77IIIIIIIIIIIIIIII7IIIII??+IIII??????IIIII??++?+~,~?+++++==~~~~,::=~:,::,,,.,:,,,:~::~====+????+++++++++???+++++++======+++???+++========= ");
Serial.println(" 7IIIIIIIIII?IIIIIIIIIIII???????????+?+??III?I?????==?=+++?++=~:~~,:~,,:::.,:,,,,,::,:~~===+?+??++++++????++++++++++========+++??++++===++=== ");
Serial.println(" IIIIIIIIIIIIIIII??????II???+=+?+?+????IIIIII?+==~~~?====+??++==~~:==:::,,~~~,,:..,,::~=~===++???+++???+++++++++=======~~~~~~=+++============ ");
Serial.println(" II??IIIIIIIIIII?I??I???I??++I??++=?+???I??II???+??+???+++~=+=~=:,,:~:::,:::.,,,,::=:~:~~===+++??++???++++++==~~====~~~~~~~~=+++=~===+++++=== ");
Serial.println(" ???IIIIIIIIII?IIIIII??I??????++==++???I??III?+++++++?==+==+=~==.::,:,,,,.,:~,~~::,:::~~=====++??++????+==~~~~~~~~::::~~~~~=++==:=++?+++++=== ");
Serial.println(" ??I??IIIIII??????II?????????+==++????????II?+?+?=+++++++=++==~~+~==~~,,,:,,::::~~,:~~=~:====+????+?????+=~~~~~~~::~~~~~~==++=~~+???+===++=== ");
Serial.println(" ??+?IIII?????+????+??????++=?+??+++?+?????????++=~=~::==:=====~+=:::,~~.~:::,~::,:~:::===~~~+????+++???++=~~~~~~~~~~~~~=++++~~=+??+=~~====== ");
Serial.println(" +?????I??????+++++???+?+++=======?+???+?++????+==+=+~==~?++~+~,====::~:.~~:::::,::,,~:~=:~~=+++?+?+=+???++==~~~~~~=~~~=+++=~~~=++=~:,::~==== ");
Serial.println(" ?I?????????+???+?+??++?++=~=+++==+=++?I????????+++?+=?=++==++~+~~~:=,,,:~~:~~,:~:~=:~=::~:~~=++???+==+++++==~~~~~~~~~=+++=~~~~~~~~::::::~~~~ ");
}
P.S., don't forget to square these lines all up neatly if the copy paste here messed them up ![]()
For those about to build, I salute you ![]()
Almost forgot, until @UKHeliBob reminded me of how the Fallout 3 inspired Terminal I made for a Hallowe'en prop in 2017 works. Uses an old microwave repurposed as a safe, an Arduino UNO (maybe two, * just checked, only the one here *I think I offloaded the LEDs in the safe itself to another UNO, it probably says in the code, or maybe not since that would be a different code) I just copied it from my sketchbook without bothering to reread it first), a servo to drive open the door (manual close by hand) and I used a separate keyboard customized to purpose and mounted in an old Dewalt drill case. Buttons and lights are also mounted as quick access to the win condition and user feedback. Works great. Good luck.
Credits to the author of the Password library, and Adafruit Industries for their "classy solution" to get the timing right. Can't remember if I just adapted a Password library example to make this work, but if I didn't, I used Robin2's serial data handling techniques to get the job done, it's an excellent resource my Arduino builds can't exist without. Cheers
/*
THIS VERSION IS FINAL, 2018 REVISION THAT
SIGNIFICANTLY IMPROVES THE USER EXPERIENCE
OVER THE 2017 VERSION. THIS VERSION IS FASTER,
SLEEKER, CLEANER, EASIER TO PICK UP AND PLAY
THIS VERSION REPLACES ALL OTHER VERSIONS
Hallowe'en 2017
REVISED OCTOBER 29, 2018
Fallout 3-inspired Terminal to hack and act as a game the kids can play to
upgrade their candy.
Enable caps lock on connected keyboard.
Special controls: '!' to reset input in event of typo
':' to call instruction set if needed
The monitor for this is a circa 1980s analog TV, connected to the PC via HDMI-to-RCA
converter box. The text is displayed over CoolTerm, the free terminal emulation software.
The settings in CoolTerm are very important for the functionality of this sketch over
CoolTerm, where a kid who sort of just mashes on the keys will cause the terminal emulator
to freak out, ruining the mystique of the prop, as well as the ability to understand and
operate it. This problem was not present while running it over the Arduino Serial Monior,
so I changed the settings in CoolTerm to get it to work nicely. I was using a 7-inch display,
so the font size itself reflects that, and the need for the text to be large enough to read.
The settings for CoolTerm are:
under Preferences:
Text Color (custom, lime greenish)
Background color, black as possible
uncheck Condense Line Spacings
Font: Fixedsys, size 36
under Options--Serial Port:
Baudrate: 9600, 8N1, no Flow Control
Password functionality derived from Password library example sketch:"Serial Monitor"
Unlike the example sketch, this auto resets the entries upon exiting either any of the
failed entry functions (terminalLocked() and wrongAnswer()), or the correct entry function
(rightAnswer()).
Servo function is as prototyped in sketch fallout3ServoPrototypeandTuning.
Servo uses pin 10.
Buttons on pins 2 through 8 call the debouncer class to create a simple interface for the kids
to enter or password and evaluate their guesses.
This is for the Uno, Mega, etc. Due Version separate, and may allow standalone
USB keyboard entry.
Written by Hallowed31
Testing and Debugging by Coltonius31
September 2017
REVISED 2018
Revisions: Mainly detached the LEDs from the buttons to allow them to run an
entertaining script instead. Also cleaned up the finicky buttons because
they were constantly missing the button presses, which ruined the game.
Now, all the buttons simply do the same thing: evaluate the password.
Also edited instruction set due to button fix.
Also added an automatic reset of keyboard entry when keyboard presses
exceed the length of the longest word in the list ("costume"). Should
cue the user not to simply button mash and crash the program. Also put
all LEDs on flashy blinky script. They just look cool, no funtionality
to the program
*/
#include <Password.h>
#include <Servo.h>
Password password = Password("CANDY");
Servo myservo; // create servo object
byte currentLength = 0; // variable to store the length of keyboard input at any given time
byte numberChances = 4;
byte thisAttempt = 4;
byte lastAttempt = 0; //this is the one that sends sketch to terminalLocked()
int pos = 0; // variable to store the servo position
void crackSafe() {
myservo.attach(10); // attaches the servo on pin 10 to the servo object
/* pop the microwave oven door */
for (pos = 0; pos <= 180; pos += 10) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 10) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
/* lets open it twice, as the microwave oven latch can be inconsistent */
for (pos = 0; pos <= 180; pos += 10) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 10) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
myservo.detach(); //cleanup before we leave, prevents servo jitter
}
/* kid wins entry to the safe, to take one beverage (Coca Cola or juice box) */
void rightAnswer()
{
//add some space to the screen
for (int h = 0; h < 4; h++) {
Serial.println();
}
Serial.print(F(" EXACT MATCH!"));
for (int h = 0; h < 4; h++) {
Serial.println();
}
delay(500);
Serial.print(F(">>>>>>>> ACCESS GRANTED "));
delay(2000);
for (int x = 0; x < 2; x++) {
Serial.println();
}
delay(1000);
quickScroll();
crackSafe();
Serial.print(F(" WELCOME TRICK OR TREATER"));
delay(3000); // added more time for kids to notice and read previous line
for (int x = 0; x < 2; x++) {
Serial.println();
}
Serial.print(F(" COMIC BOOK (1) <TAKE>"));
//hold the message for a bit...
delay(6000);
//clear the screen for the next person
for (int i = 0; i < 10; i++) {
Serial.println();
delay(200);
}
/* clean up when before we leave, reset attempts */
numberChances = 4;
thisAttempt = 4;
delay(3000);
//reset for the nest trick-or-treater
//candyState = LOW;
robcoResetProtocol();
}
class Flasher
{
// Class Member Variables
// These are initialized at startup
int ledPin; // the number of the LED pin
long OnTime; // milliseconds of on-time
long OffTime; // milliseconds of off-time
// These maintain the current state
int ledState; // ledState used to set the LED
unsigned long previousMillis; // will store last time LED was updated
// Constructor - creates a Flasher
// and initializes the member variables and state
public:
Flasher(int pin, long on, long off)
{
ledPin = pin;
pinMode(ledPin, OUTPUT);
OnTime = on;
OffTime = off;
ledState = LOW;
previousMillis = 0;
}
void Update()
{
// check to see if it's time to change the state of the LED
unsigned long currentMillis = millis();
if ((ledState == HIGH) && (currentMillis - previousMillis >= OnTime))
{
ledState = LOW; // Turn it off
previousMillis = currentMillis; // Remember the time
digitalWrite(ledPin, ledState); // Update the actual LED
}
else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime))
{
ledState = HIGH; // turn it on
previousMillis = currentMillis; // Remember the time
digitalWrite(ledPin, ledState); // Update the actual LED
}
}
};
class debouncer
{
int buttonPin; //button to enter response, ANY BUTTON (2018 revision)
boolean currentButton;
boolean lastButton;
public:
debouncer(int button, boolean was, boolean is)
{
buttonPin = button;
pinMode(buttonPin, INPUT_PULLUP); //pin is HIGH when button is not pressed, so logic is inverted
lastButton = was;
lastButton = HIGH;
currentButton = is;
currentButton = HIGH;
}
boolean debounce(boolean was)
{
boolean is = digitalRead(buttonPin);
if (was != is)
{
delay(10);
is = digitalRead(buttonPin);
}
return is;
}
void Update()
{
currentButton = debounce(lastButton);
if ((lastButton == LOW) && (currentButton == HIGH)) { //evaluate password HERE
/* FIRST THE NULL OR WRONG BUTTON PRESSES... */
/* button is reverse logic due to setup assignment of INPUT_PULLUP */
//OK, so you got it right by either the password or the correct button
if ((password.evaluate()) && (numberChances > 0)) {
rightAnswer();
}
/* if you have no chances left (numberChances), straight to terminalLocked()
with no prettyprinting */
else if (numberChances == 0) {
terminalLocked();
}
/* first answer was wrong, still have 3 chances remaining */
else if ((!password.evaluate()) && (numberChances > lastAttempt) && (numberChances == 4)) {
numberChances--;
firstWrongAnswer();
}
/* second answer was wrong, still have 2 chances remaining */
else if ((!password.evaluate()) && (numberChances > lastAttempt) && (numberChances == 3)) {
numberChances--;
secondWrongAnswer();
}
/* third answer was wrong, still have 1 chance remaining */
else if ((!password.evaluate()) && (numberChances > lastAttempt) && (numberChances == 2)) {
numberChances--;
lockoutImminent();
//thirdWrongAnswer() gives the easyPeasy game list
thirdWrongAnswer();
}
/* last chance! */
else if ((!password.evaluate()) && (numberChances > lastAttempt) && (numberChances == 1)) {
terminalLocked();
numberChances--;
}
/* if numberChances is zero, straight to locked out */
else if ((password.evaluate()) && (numberChances == 0)) {
terminalLocked();
}
/* if you tried to enter a response when already at zero chances... */
else if ((!password.evaluate()) && (numberChances == 0)) {
terminalLocked();
}
lastButton = currentButton;
}
else if ((lastButton == HIGH) && (currentButton == LOW)) {
lastButton = currentButton;
}
}
};
Flasher led1(12, 100, 400);
Flasher led2(14, 350, 350);
Flasher led3(15, 100, 400);
Flasher led4(16, 350, 350);
Flasher led5(17, 100, 400);
Flasher led6(18, 350, 350);
// Three arguments (buttonPin, was, is): 2018 revision is that all buttons simply evaluate password.
debouncer button2 (2, 1, 1);
debouncer button3 (3, 1, 1);
debouncer button4 (4, 1, 1);
debouncer button5 (5, 1, 1);
debouncer button6 (6, 1, 1);
debouncer button7 (7, 1, 1);
debouncer button1 (8, 1, 1);
void setup() {
Serial.begin(9600); // 2018 rev: Coolterm defaults to 9600 upon opening, so takes out a step and guesswork
delay(1000);
/* to do away with the leftover text from last time thhis was plugged in... */
for (int t = 0; t < 22; t++) { // 2018 revision, default 25
Serial.println();
}
robcoResetProtocol();
}
void loop() {
led1.Update();
led2.Update();
led3.Update();
led4.Update();
led5.Update();
led6.Update();
button1.Update();
button2.Update();
button3.Update();
button4.Update();
button5.Update();
button6.Update();
button7.Update();
if (Serial.available()) {
char input = Serial.read();
switch (input) {
case '!': //reset password
password.reset();
currentLength = 0;
Serial.println(" >PASSWORD RESET<");
Serial.println();
Serial.println(" ENTER PASSWORD");
break;
case '?': //evaluate password
break;
case ':': //run robcoResetProtocol in case we need the instructions
password.reset();
currentLength = 0;
robcoResetProtocol();
break;
default: //append any keypress that is not a '!' nor a '?' to the currently guessed password.
password << input;
currentLength++;
if (currentLength > 7) {
password.reset(); // to avoid button mashing
currentLength = 0;
Serial.println(" >SYNTAX ERROR<");
Serial.println();
Serial.println(" >INPUT EXCEEDS RX BUFFER<");
Serial.println();
Serial.println(" >SELECT PASSWORD FROM LIST<");
Serial.println();
delay(2500);
//wait for all the garbage
discardIncomingSerial();
quickScroll();
Serial.println(" >PASSWORD RESET<");
Serial.println();
Serial.println(" ENTER PASSWORD");
delay(2000);
buttonMashProtocol(); // reprint the word list
break; // now get outta here and try again
}
//the asterisks for textual display that some text is being typed
for (byte i = 0; i < currentLength; i++) {
Serial.print('*');
}
Serial.println();
}
}
}
/*This occurs after a successful hacked teminal, or after one
that has been locked out, or at the start of program */
void robcoResetProtocol() {
/* eight-second delay here so next kid in line has chance to step up */
delay(2000); // default 8000 for actual thing
Serial.println(); //for prettyprinting
Serial.println();
Serial.println(F(" WELCOME TO ROBCO INDUSTRIES(TM) [TERMLINK]"));
Serial.println();
delay(1000);
Serial.println(F(" >SET TERMINAL/INQUIRE"));
Serial.println();
delay(1000);
Serial.println(F(" RIT-V300"));
Serial.println();
delay(1000);
Serial.println(F(" >SET FILE/PROTECTION=OWNER:RWED /ACCOUNTS.F"));
delay(800);
Serial.println(F(" >SET HALT RESTART/MAINT"));
Serial.println();
delay(1200);
Serial.println(F(" Initializing Robco Ind(TM) MF Boot :Agent v2.3.0"));
delay(800);
Serial.println(F(" RETROS BIOS"));
delay(800);
Serial.println(F(" RBIOS-4.02.08.00 52EE5.E7.E8"));
delay(800);
Serial.println(F(" Copyright 2201-2203 Robco Ind."));
delay(800);
Serial.println(F(" Uppermem: 64KB"));
delay(800);
Serial.println(F(" Root (5A8)"));
delay(800);
Serial.println(F(" Maintenance Mode"));
Serial.println();
delay(1500);
Serial.println(F(" >RUN DEBUG/ACCOUNTS.F"));
Serial.println();
Serial.println();
Serial.println();
Serial.println();
delay(1000);
for (int i = 0; i < 15; i++) {
Serial.println();
}
Serial.println(F(" ROBCO INDUSTRIES (TM) TERMLINK :PROTOCOL"));
delay(1000);
//make room for the instructions so not overlooked
scrollUp();
Serial.println(F(" 4 ATTEMPTS AT PASSWORD"));
delay(2000);
scrollUpFewer();
Serial.println(F(" KEY IN PASSWORD"));
Serial.println();
delay(2000); //enough time to read the text //DEFAULT 7000
Serial.println();
Serial.println(F(" "));
Serial.println(F(" PRESS ANY BUTTON TO CHECK PASSWORD"));
delay(4000); //more time to comprehend the instructions DEFALUT 8000
quickScroll();
Serial.println(F(" 0xF9AC [$_:|>/>]< 0xFA78 %GHOUL</=?"));
Serial.println(F(" 0xF9B8 [$_:|>/>GH 0xFA84 ?_^#!</=FA"));
Serial.println(F(" 0xF9C4 OST:|>/>?= 0xFA90 NGS#!<:/=?"));
Serial.println(F(" 0xF9E8 #^_:|>/>]< 0xFA04 ?_^#CANDY?"));
Serial.println(F(" 0xFA30 [$_TREAT]< 0xFB20 ?_^#!<:/=?"));
Serial.println(F(" 0xFA54 [$_:|>/>]< 0xFAA8 ?_^=TRICK?"));
Serial.println(F(" 0xF9AC [$_:|>COST 0xFA9C ?_GHOUL/=?"));
Serial.println(F(" 0xF9AC UME:|>/>]< 0xFB04 ?_^#!<:/=?"));
Serial.println(F(" 0xF9E8 #^_:|>/>]< 0xFA04 ?_^#CANDY?"));
password.reset();
currentLength = 0;
}
/* For subsequent attempts after wrong answer */
void robco3Protocol()
{
Serial.println(F("ROBCO INDUSTRIES (TM) TERMLINK PROTOCOL"));
delay(500);
Serial.println();
Serial.println(F(" 3 ATTEMPT(S) REMAINING"));
Serial.println();
delay(500);
Serial.println(F(" ANY BUTTON TO ENTER PASSWORD "));
Serial.println();
delay(1000);
Serial.println(F(" ENTER PASSWORD: "));
delay(1000);
Serial.println(F(" 0xF9AC [$_:|>/>]< 0xFA78 %FANGS</=?"));
Serial.println(F(" 0xF9B8 [$_:|>/>GH 0xFA84 ?_^#!<:/=?"));
Serial.println(F(" 0xF9C4 OST:|>/>]< 0xFA90 ?_^#!<:/=?"));
Serial.println(F(" 0xF9E8 [$_:|>/>]< 0xFA04 ?_^#TRICK?"));
Serial.println(F(" 0xFA30 [$_TREAT]< 0xFB20 ?_^#!<:/=?"));
Serial.println(F(" 0xFA54 [$_:|>/>]< 0xFAA8 ?_^BONES=?"));
Serial.println(F(" 0xF9AC [$_:|>COST 0xFA9C ?_^#!<:/=?"));
Serial.println(F(" 0xF9AC UME:|>/>]< 0xFB04 ?_^#CANDY?"));
Serial.println(F(" 0xF9E8 [$_:|>/>]< 0xFA04 ?_^#TRICK?"));
password.reset();
currentLength = 0;
}
void robco2Protocol()
{
Serial.println(F("ROBCO INDUSTRIES (TM) TERMLINK PROTOCOL"));
delay(500);
Serial.println();
Serial.println(F(" 2 ATTEMPT(S) REMAINING"));
delay(500);
Serial.println();
Serial.println(F(" ANY BUTTON TO ENTER PASSWORD "));
Serial.println();
delay(1000);
Serial.println(F(" ENTER PASSWORD: "));
delay(1000);
Serial.println(F(" 0xF9AC [$_:|>/>]< 0xFA78 %FANGS</=?"));
Serial.println(F(" 0xF9B8 [$_:|>/>GH 0xFA84 ?_^#!<:/=?"));
Serial.println(F(" 0xF9C4 OST:|>/>]< 0xFA90 ?_^#!<:/=?"));
Serial.println(F(" 0xF9E8 [$_:|>/>]< 0xFA04 ?_^#TRICK?"));
Serial.println(F(" 0xFA30 [$_TREAT]< 0xFB20 ?_^#!<:/=?"));
Serial.println(F(" 0xFA54 [$_:|>/>]< 0xFAA8 ?_^BONES=?"));
Serial.println(F(" 0xF9AC [$_:|>COST 0xFA9C ?_^#!<:/=?"));
Serial.println(F(" 0xF9AC UME:|>/>]< 0xFB04 ?_^#CANDY?"));
Serial.println(F(" 0xFA30 [$_TREAT]< 0xFB20 ?_^#!<:/=?"));
password.reset();
currentLength = 0;
}
/* intended to be the robcoProtocol on last chance, so words almost all CANDY
to make it really easy, if the kids are payin' attention...
*/
void robcoProtocolEasyPeasy() {
Serial.println(F("ROBCO INDUSTRIES (TM) TERMLINK PROTOCOL"));
delay(500);
Serial.println();
Serial.println();
Serial.println(F(" 1 ATTEMPT REMAINING"));
Serial.println();
Serial.println(F(" ANY BUTTON TO ENTER PASSWORD "));
Serial.println();
delay(1000);
Serial.println(F(" ENTER PASSWORD: "));
delay(1000);
Serial.println(F(" 0xF9AC [$_:|>/>]< 0xFA78 %CDNAY</=?"));
Serial.println(F(" 0xF9B8 [$_:|>/>CA 0xFA84 ?_^#!<:/=?"));
Serial.println(F(" 0xF9C4 NDY:|>/>]< 0xFA90 ?_^#!<:/=?"));
Serial.println(F(" 0xF9E8 [$_:|>/>]< 0xFA04 ?_CANDY#@?"));
Serial.println(F(" 0xFA30 [$_CANDY]< 0xFB20 ?_^#!<:/=?"));
Serial.println(F(" 0xFA54 [$_:|>/>]< 0xFAA8 ?_^CNADY=?"));
Serial.println(F(" 0xF9AC [$_:|>>^CA 0xFA9C ?_^#!<:/=?"));
Serial.println(F(" 0xF9AC NDY:|>/>]< 0xFB04 ?_^#CANDY?"));
Serial.println(F(" 0xF9AC TPYE|>/>]< 0xFB04 ?_^#CANDY?"));
password.reset();
currentLength = 0;
}
void firstWrongAnswer()
{
//make room for the message
for (int n = 0; n < 6; n++) {
Serial.println();
}
Serial.println();
Serial.println(F(" ACCESS DENIED"));
delay(2000);
Serial.println();
//scroll up the screen quicker than rightAnswer or terminalLocked
for (int n = 0; n < 10; n++) {
Serial.println();
delay(100);
}
robco3Protocol();
}
void secondWrongAnswer()
{
//make room for the message
for (int n = 0; n < 6; n++) {
Serial.println();
}
Serial.println();
Serial.println(F(" ACCESS DENIED"));
delay(2000);
Serial.println();
//scroll up the screen quicker than rightAnswer or terminalLocked
for (int n = 0; n < 10; n++) {
Serial.println();
delay(100);
}
robco2Protocol();
}
void thirdWrongAnswer()
{
//make room for the message
for (int n = 0; n < 6; n++) {
Serial.println();
}
Serial.println();
Serial.println(F(" ACCESS DENIED"));
delay(2000);
Serial.println();
//scroll up the screen quicker than rightAnswer or terminalLocked
for (int n = 0; n < 10; n++) {
Serial.println();
delay(100);
}
robcoProtocolEasyPeasy();
}
/* last chance before being locked out, ie third wrong answer here's a warning... */
void lockoutImminent() {
//make room for the message
for (int n = 0; n < 6; n++) {
Serial.println();
}
Serial.println(F(" WARNING: LOCKOUT IMMINENT!!!!"));
Serial.println();
Serial.println();
delay(1500);
Serial.println(F(" WARNING: LOCKOUT IMMINENT!!!!"));
delay(500);
Serial.println();
Serial.println();
//scroll up the screen quicker than rightAnswer or terminalLocked
for (int n = 0; n < 10; n++) {
Serial.println();
delay(300);
}
}
/* kid still gets consolation candy, I mean I'm not an ogre */
void terminalLocked() {
//Clear the screen for the locked message
for (int i = 0; i < 15; i++) {
Serial.println();
}
Serial.println(F(" Terminal Locked "));
Serial.println();
Serial.println(F(" Check With Administrator "));
Serial.println(); // 3 BLANK LINES TO VERTICALLY CENTER THE TEXT
Serial.println();
Serial.println();
/* clean up when before we leave, reset attempts */
numberChances = 4;
thisAttempt = 4;
delay(10000);
//clear the screen for the next person
//scroll up the screen
for (int t = 0; t < 10; t++) {
Serial.println();
delay(200);
}
//reset for the nest trick-or-treater
robcoResetProtocol();
}
void scrollUp() {
for (int n = 0; n < 9; n++) {
Serial.println();
delay(300); //makes it look legit
}
}
void scrollUpFewer() {
for (int n = 0; n < 4; n++) {
Serial.println();
delay(300); //makes it look legit
}
}
void quickScroll() {
for (int q = 0; q < 9; q++) {
Serial.println();
delay(30);
}
}
void discardIncomingSerial() {
while (Serial.available())
Serial.read();
}
void buttonMashProtocol() {
Serial.println(F(" 0xF9AC [$_:|>/>]< 0xFA78 %FANGS</=?"));
Serial.println(F(" 0xF9B8 [$_:|>/>GH 0xFA84 ?_^#!<:/=?"));
Serial.println(F(" 0xF9C4 OST:|>/>]< 0xFA90 ?_^#!<:/=?"));
Serial.println(F(" 0xF9E8 [$_:|>/>]< 0xFA04 ?_^#TRICK?"));
Serial.println(F(" 0xFA30 [$_TREAT]< 0xFB20 ?_^#!<:/=?"));
Serial.println(F(" 0xFA54 [$_:|>/>]< 0xFAA8 ?_^BONES=?"));
Serial.println(F(" 0xF9AC [$_:|>COST 0xFA9C ?_^#!<:/=?"));
Serial.println(F(" 0xF9AC UME:|>/>]< 0xFB04 ?_^#CANDY?"));
Serial.println(F(" 0xFA30 [$_TREAT]< 0xFB20 ?_^#!<:/=?"));
}
For those about to build, I salute you ![]()
Please illustrate how a keypress on the PC can trigger an action on the Arduino
Noting
An example sketch would be appreciated
For sure, see my Terminal sketch just ^ there. It works in Arduino Serial monitor too, but looks better on CoolTerm. uses the Password library, which I didn't write, but it works great. See any Youtube video for hacking Fallout 3/4 terminals to see what the sketch does. Simulates that using old microwave oven outfitted with a servo to pop the door open upon password entry