I am building this robot, sort of like a snake but different.
Anyways, i’m using a Basic Stamp 2 and it sends out serial instructions to an SSC-32. The values are being stored in bit format to save RAM, but i have to multiply by 10 as a consequence.Also, it inverts the position of every other servo by subtracting it from 300 (the servos are mounted facing opposite directions, so it makes my life easier if i invert the values.)
the serout command looks something like this:
serout 0, 6, "#0 p", DEC e0 * 10, #1 p", DEC 300 - e1 * 10, #2 p", DEC e2 * 10, #3 p", DEC 300 - e3 * 10... etc.
there are 10 servos.
so what i was wondering was, does BEDMAS apply when doing operations on my stamp? because the servos go haywire when i try running it. i want it to subract first and then multiply by 10. pretty much i was wondering what i could do to make this code work.
I have no idea what BEDMAS is but parenthesis are your friend in mathematical equations. Currently this part of your code below, DEC 300 - e1 * 10, will multiply el by 10 and subtract the result from 300 then apply the DEC format specifier. Something like, DEC (300-(el*10)), should give you the desired result as you have explained it.
sorry, by BEDMAS i meant the order of operations (Brackets, exponents, divide/multiply, add/subtract). i dunno, something they taught in school, so i thought that it was common knowledge. my bad
you could google it and get a pretty good idea what it is
Debugging was too much work so i just rewrote the code (a luxury i won’t have when i finish my program, as it will be too long for that). now it works, so thanks. 8)