Controlling LEDs with Gyroscope

Hi all! I'm about to begin working on a project and I'm not sure where to start with the code.

The project is just a an umbrella/sunshade with RGB LEDs on it that will be controlled by an accelerometer/gyroscope (for nighttime illumination). What I want is for Z axis rotation from spinning the umbrella to control brightness (like turning a volume knob), and for movement from waking and waving the thing around to cause color to shift. The hardware is easy enough for me to visualize (battery, arduino, mpu6050, LEDs), and without getting too detailed here's my plan of attack for the code:

Setup - define inputs, outputs, variables, initial data, etc. as usual.

Loop - 1) retrieve z axis rotation data from mpu6050, use this to set a brightness 'cap' as some value between 0 and 255 where every five degrees of rotation or so would add or subtract 1 to whatever the cap is.
2) retrieve other motion data from mpu6050, use this to change color values for the leds. add or subtract a little from red, green, and blue, then map these values to adjust to the brightness cap defined before.
3) Analog write to the rgb pins, loop back to beginning.

The way I picture this working is that moving about with the umbrella will cause acceleration along x y z axes and cause colors to change a little without brightness changing, since it's capped. Then, spinning the umbrella will change the brightness cap and since the rgb values are mapped to the cap, they will 'expand' along with the cap without really changing color or hue. Of course I'll need to include some way to keep the rgb values from all dropping, maybe by maintaining the sum of rgb values at 500 or something.

I hope I've made this clear enough. Any suggestions on code (or hardware!!) are welcome and appreciated!!