Introduction: Arduino ServoTimer2 and VirtualWire 433MHz Receiver

The Idea:

  • Use low cost radio control components + Arduino to control the movements of a Servo

The Challenges

Other Solutions

Components

The Breakthrough

  • The Servo and Receiver do not like to play together so make them play apart.

Explanation

  • In most examples the servo is attached in the setup function. Similarly, the receiver is started in the setup function.
  • However, I guessed there might be a function to undo an attached servo and similarly to stop a receiver. A little investigation revealed that that was the case.

Step 1: Components & Code

Components

  • 10K Trimpot
  • 2 x Arduino (e.g. Uno, Duemilanove)
  • 433 MHz Transmitter & Receiver
  • Servo [I have a full rotation servo]
  • The usual prototyping paraphernalia - Computer, Breadboard, USB cables, Hookup wires

Virtual Wire

ServoTimer2

Step 2: Transmitter

The transmitter is the easy part.

  1. Read value from a Potentiometer
  2. Send it

Step 3: Receiver

NOTE: You may get a compile error that has the text:

error: conflicting declaration 'typedef uint8_t boolean'

This is easy to resolve

  • Use a Text Editor to edit ServoTimer2.h
  • Comment out the two offending lines (lines 76 and 77) and SAVE

typedef uint8_t boolean;
typedef uint8_t byte;

Change these lines to:

// typedef uint8_t boolean;
// typedef uint8_t byte;

This seems to be due to ServoTimer2 being written a while ago before those types were defined.

Step 4: Conclusion

I wasn't expecting it to be so hard to get these components to work together.

I learnt a bit about timers & libraries along the way which was interesting.

The full rotation servo that I have stutters along because it is attached & detached. I don't have any other type of servo so I'd be interested in how different types of servo respond using the same setup.