String manipulation using Arduino and C++ -
I'm trying to manipulate strings in C ++ I'm working with an Arduino board so I what I am limited to what can I still am learning C + + (sorry for any stupid questions)
here is what I do: send me mph in 7 segment display I need so if i have a number like 17.812345, then 17 segment 7 segment display Needs to be displayed. The most effective way the first 10 times (the decimal point is to multiply the need to move to a location), then enter 178.12345 an intestine (cut decimal points). The part I am stuck on can be different from 178. In Python I can slice the string, but C ++ (or at least, I can not find the right word to search but I can not find anything)
Four 7 segment display and a 7 segment display controller. It will take measures up to a tenth of a mile per hour Thank you so much for the help and information, which you can provide me.
This will probably not be easy to convert it to a string, but to separate the digits Use arithmetic, i.e.
speed of float = 17.812345; Int display_speed = speed * 10 + 0.5; // round to national 0.1 == 178 int scores [4]; Number [3] = display_speed% 10; // == 8 points [2] = (display_speed / 10)% 10; // == 7 points [1] = (display_speed / 100)% 10; // == 1 point [0] = (display_speed / 1000)% 10; // == 0
And, as mentioned in the comments, if you need an ASCII value for each issue:
char ascii_digits [4]; Ascii_digits [0] = Points [0] + '0'; Ascii_digits [1] = Points [1] + '0'; Ascii_digits [2] = Points [2] + '0'; Ascii_digits [3] = Points [3] + '0';
Comments
Post a Comment