Pendulum Balance Robot

Syntax

PID(&Input, &Output, &Setpoint, Kp, Ki, Kd, Direction)
Parameters

Input: The variable we're trying to control (double)
Output: The variable that will be adjusted by the pid (double)
Setpoint: The value we want to Input to maintain (double)
Kp, Ki, Kd: Tuning Parameters. these affect how the pid will chage the output. (double>=0)
Direction: Either DIRECT or REVERSE. determines which direction the output will move when faced with a given error. DIRECT is most common.

http://playground.arduino.cc//Code/PIDLibraryConstructor
m needs to be a double to work correctly with the PID library
you can cast it to an int for your stepper motor like this if you want

myStepper.step((int)m);