To program the Arduino, we need to use Arduino programming software.
Note that the programming codes had been refined after the day that videos were shot. So, some parts of the code shown in videos are different. However, the method or idea of writing the program is consistent as shown in videos.
Attention: it's important to open the code correctly. For example, if you are using Arduino 0022 (the programming software) Click "File"-->"Open", then choose "inverted_pendulum.pde". And you should see that three .pde files will open automatically.
"inverted_pendulum.pde": the main program. Defines all the variables and do all the initial settings. In the infinite loop, the program calculates control input value and outputs to DAC circuit.
"dac.pde": controls DAC.
"encoders.pde": acquires data from two encoders using interrupt functions. And estimates angular velocity and cart velocity using timer interrupt function.
Download the Arduino code in DOWNLOAD section.