9 years, 6 months ago.

Set a variable from the PC

I've currently got a system where a servo moves an arm to three different predefined angles; this is governed by using assigning those angles to keys 1, 2, and 3. However I've now been asked to look at being able to type in any angle within the possible range, to two decimal places, and hit return to send it there. I've tried searching, but I suspect I just don't know the terminology to find the answer, is it a string? Do I need a buffer? What is a buffer? etc So any suggestions? Thanks Robin

2 Answers

9 years, 6 months ago.

I assume this is for study, so i will not give you direct answers.

1. Anything you pass from a keyboard to a uC will be a string.

2. You will need to pass the data to a variable that can hold that data, a buffer. Look it up try google!

3. You will need to change the data into a floating point var. Look here http://www.cplusplus.com/reference/string/stof/

4. Try to help yourself by using a search engine like google.

When you have done the above and still have problems ask a new question. Also use a link to this question.

9 years, 6 months ago.

I suggest you read up on C input and output functions.

Take a look at: http://www.studytonight.com/c/c-input-output-function.php