We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpElectronics,  Serial Library › Basic user input program needed...
Page Index Toggle Pages: 1
Basic user input program needed... (Read 955 times)
Basic user input program needed...
Nov 24th, 2007, 5:42am
 
I'm having a difficult time going through all the examples and learning how to simply take an integer the user types in and then sends it to Arduino.

Basically I want is: Text that says "Input voltage: ", then the user types a number (would be best if it could handle floats/decimals). Then press a button like "enter" then it take that integer/float and send it in byte format to my microcontroller code in Arduino.

So user inputs "5", then hits "Enter", then it sends 00000101 (5 in binary as a byte) to my microcontroller. this is basically all I need. Thanks for any help!
Re: Basic user input program needed...
Reply #1 - Nov 24th, 2007, 8:25am
 
please do not double post!
Re: Basic user input program needed...
Reply #2 - Nov 24th, 2007, 8:31am
 
here's an example of how to write to the serial port:

http://processing.org/reference/libraries/serial/Serial_write_.html

you can convert a string (user input) to byte[] (array) like this:

String s = "100.1";
byte[] b = s.getBytes();

F
Page Index Toggle Pages: 1