Lets say I want to have a function, that somehow modifies an inputted speed and sets an inputted motor to that speed. Instinct tells me it would be something similar to
However, I’ve tried that and it doesn’t seem to work. The motors just don’t spin. I’m assuming it is because when you read pwm01, it gives you the current speed that pwm01 is running at. So Drive(pwm01, 100) is similar to, say, Drive(127, 100)
What is the cause of this problem? How can I fix it?
I think that you are mixing C++ with C. in C++, “int&” is a pass by reference. In C there is no pass by reference only pass by value and a pointer is the only way to do it.
Mike
To All,
Mark’s post is correct. Please read K&R chapter 5 before sliding down the perilous and provocative path of pointers.