New Member – trigger->output text string w/timestamp
Hello there – new member here so please forgive any newbie errors.
No idea where to start, what to search for, or what basics I should review before posting here – so any guidance appreciated.
I am looking to create an output text string that starts after a trigger event.
This is what I wish to accomplish –
Momentary switch closes which starts a series of text strings in the following manner “s,0”, then .25 seconds later “s,.25”, then .25 seconds later “s,.50” and so on each subsequent .25 seconds until the momentary switch closes again after which is starts over “s,0”, then .25 seconds later “s,.25”, then .25 seconds later “s,.50” and so on
There are several parts to the solution.
You need to connect the switch to the Arduino. I suggest connecting the switch between a digital I/O pin and GND. (Don't use pins 0 and 1 since these are needed for serial communication.) In your sketch, enable the pull-up resistor on the I/O pin by calling digitalWrite(pin, HIGH);
You need to know when the momentary switch changes from open to closed. The state change detection example sketch shows how to do that. Each time it happens, save the current value of millis() to a global variable that tells you when it happened and reset the variables that control the timed output below.
You need to know when it is time to send your output text. Use a global variable which records the time of the last output. Initially, this will be the same as the time that the switch closed. Use the approach demonstrated in the blink without delay example to compare the current time against the time of the last output and send the next output when it exceeds your threshold.
As a rough guide, the solution will probably be a couple of dozen lines of code - you're not asking for anything complicated.
Peter thanks for the reply.
I understand your recommendations and get the process conceptually as I have some understanding of electronics. (I am not a EE by any stretch but, for reference, here is an example of something I did a few years ago - http://www.andrewvanis.com/HangGliding/HMD/HMD.html)
What I don't know and would appreciate guidance on is how to learn the language, processes, and society of arduino? For example I do not know how to interpret or implement the following parts of your suggestion -
In your sketch - what is a sketch in the arduino world
enable the pull-up resistor on the I/O pin by calling digitalWrite(pin, HIGH) - I/O pin, digitalWrite?
Use the approach demonstrated in the blink without delay example - where would I find that example?
I don't even have a clue which arduino hardware to get.
I feel like these questions are so rudimentary that I am wondering if there is a beginners guide somewhere I should be reading. Is there one?