I'm new to Arduino and I was wondering if there was a function or something where I could type numbers or letters on the keyboard on a laptop connected to an arduino by usb and have the arduino store those variables in real time while running its program then use them later
I looked at some of the libraries but didn't see anything
even if i had to write a function that's fine i just dont' know what I would need to include in it for it to work
If i got it right you only have to listen to the serial port and write from your laptop to your arduino using the serial monitor.
Using the SoftwareSerial library?
You don't have to import any library, it's included already:
alright so I just use the example code from that page but will it let me save any number or just one character at a time? I would like to save numbers from 0 to 180
also does anyone know if I can put on screen prompts on the laptop asking for numbers (not a screen attatched to the arduino)
The Serial.read() function reads one character at a time. If you are sending strings that constitute more than one digit numbers, you need a way of telling the Arduino that the end of the number has arrived.
The suggestion to use the Serial.read function assumes that you have some application on the PC reading the keystrokes and sending them to the serial port. The keyboard doesn't do that automatically.
Since the program running on the PC can listen to the serial port, too, the Arduino can send messages to be displayed by that application.
Alright that sounds great where can I download the application?
Alright that sounds great where can I download the application?
You don't download it. You write it.
Is there some reason that the Serial Monitor won't suffice?
Oh nope that looks like it will work
what code will I need to use the serial monitor to save values to a variable?
what code will I need to use the serial monitor to save values to a variable?
The serial monitor connects the keyboard, via the text entry area, to the serial port, and connects the serial port to the display area. It provides no way to save the data entered. Even if it did, there is no concept of saving the values to variables. That is meaningless.
If, on the other hand, you want the Arduino to read the serial data that comes in, parse it, convert the tokens to numeric values, and store those values in variables, that is step 67, and you are on step 4.
First thing to do is simply get the Arduino reading serial data and echoing what it read. The second thing to do is to look at the examples provided. The third thing to do is to exercise you google-shu and find the answers yourself. Saving serial data in variables is a topic of discussion on the forum nearly every day.
K great thanks I will research that some more I just didn't know what to look for