Implementing differentiation and integration in a digital control system?
Integration is easy especially if each sample is the same time apart, just keep adding each new sample to the integration value. Note you may need to deal with integral wind-up where your integral gets massive. This is especially true if you are doing a PID controller.

For the differential taking the difference between sample n and sample n-1 is the very first step. You may need to consider noise though, if you have a lot or your system is to sensitive you may wish to filter it.