book collections email follower instructable user

Step 10: Using the Monster Library

Now that we have the library all coded up, we can use it in a simple Arduino sketch.
We will do so by importing the library header, constructing an instance of the Monster class, and using a Timer Interrupt (from the TimerOne.h library) to call the ComputeBalance() function at a regular interval.

The implementation code is as follows:

#include "monstro.h"
#include <TimerOne.h>

Monstro meuMonstro(13, 12, 11, 3, 5, 6, 13, 12, 8, 7);

void setup()
  // COM
  // Timer Interrupt

void loop()

void BalanceRobot() {

Upload this to your Arduino, plug in the male barrel jack into the robots female barrel jack for power, and the robot should begin balancing itself.