Introduction: ARDUINO 433MHz _ SERVO.h Vs VIRTUALWIRE.h
As everyone that found this Instructable probably already knows:
The Servo Library is using the same Timer as the VirtualWire Library does, so using Servos with RemoteControlled Arduinos is not as simple as it should be.
As it took me a week of researching and testing scripts, i wanna share the output, so you can speed things up by starting with this Instructable
My approach in this Instructable is to use a third Arduino that sends the information it got from the 433Mhz Receiver via the "normal" Wire library to the Arduino that controls the Servos.
Beside the Timer Issue, i also make some room on the Arduino that drives the servos for some scripts/combination of servo signals like V-Tails (airplanes) without getting issues with receiving and decoding signals from the remote.
I personally use this to control a 1:24 MAN TGA StreetSweeper, to slow servos down, couple it to other functions, like simulated gear shifts etc, which is not possible on common model RX/TX combos.
Step 1: ARDUINO to 433 TX
I use an Arduino UNO here, as my prefered Arduino (Feather M0) cant use the virtualwire at all, which is sad to begin with :)
As you can see on the Image, wiring is pretty straight forward:
It uses a pot on analog IN to generate the values to transmit
It sends this values to the 433MHz module.
On the code side, it takes the value(s) it gets from the pot and writes it in an array.
It then sends the array to the Rx where it gets transformed back to the original values.
Step 2: 433 RX to ARDUINO to I2C
The receiver side is a bit more complicated then on the transmitter side:
The 433Mhz module gets power from the arduino micro, and sends its signal to the micro via the micros PIN 11. The Micro itself sets up an I2C line via PIN 2 (SDA) and PIN 3 (SCL) and sends the values it gets to the Featherboard.
In the attached script, it only sends the first value and keeps the other three, from the three remaining POTs, as i just needed the first value.
If you need them all, just send them all.
See the next step for I2C to Servo
Step 3: I2C ARDUINO to SERVO
In the last script, we take values that came via I2C and set the servo according.
See the script for more details.
Step 4: CONCLUSION
This Script/Instructable a huge of a walkaround for stuff that should be way more simple
I also found different (hardware) walkarounds, beside change one of the libraries, so they dont need the same timer.
- Dont use the SERVO.h library, but instead use an Adafruit PWM/servo shield.
Those shields have their own timers and run via I2C (i think thats the version i will use)
- Use a cheaper Arduino, like a trinket for decoding the 433 signals
- Make your own shield that hosts an ATiny8 and the 433 receiver out of a feather protoboard
- Dont use 433Mhz RxTx but a hobby RxTx combo.
Step 5: USED LIBRARIES
- SOME INFORMATION OF HOW TO ADAPT SKETCHES FOR M0 BOARDS
- THE RX/TX COMBO I USED