Arduino ServoTimer2 and VirtualWire 433MHz Receiver
by RussellM37 in Circuits > Arduino
15555 Views, 12 Favorites, 0 Comments
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
- 10K Trimpot
- 2 x Arduino Uno
- 433 MHz Transmitter & Receiver
- Servo [I have a full rotation servo]
- The usual prototyping paraphernalia - Computer, Breadboard, USB cables, Hookup wires
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.
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
Transmitter
The transmitter is the easy part.
- Read value from a Potentiometer
- Send it
Downloads
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.
Downloads
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.