You can’t avoid capital gains tax if you sell a capital asset intending to give the proceeds to charity. The increase in value will likely produce a capital gain which will result in increased taxes for you or your business. If you donate the depreciated asset directly, you'll only receive a deduction for the decrease in value.