B4R Tutorial Servo Motor controlled via IR Remote Control

Hi,

an experiment to move a Little Crane arm (used some Lego parts) up and down via IR Remote Control (Key1=UP,Key2=DOWN). When the arm moves, the Red LED lights else the Green LED is on.
The IR Remote Control key codes are depended on the Remote Control device. Initially test those via Log output in Sub Looper1. Lookup this thread. From the IRremote.zip file copy the files IRremote.cpp, IRremote.h, IRremoteInt.h to rCore folder in the B4R internal libraries folder.
The Servo Motor used is a Modelcraft Mini-Servo MC1811. The motor moves the arm between 10 and 90 degrees angle. Depending on the servo motor used, pressing multiple times the IR Remote Control button might be required to move the crane arm .
If the servo motor is not moving, its starts to jitter. To avoid jittering, the servo motor is detached and attached again when pressing a IR Remote Control Key. (there are various threads in the Arduino forums about this problem; tried several solutions where as detach and attach works best).

This experiment is just a starter and open for any creative enhancements esp using Lego Technic. More to come. Enjoy :)

Components
Arduino MEGA, Mini-Servo MC1811, SunFounder IR Receiver, LED red & green with resitors 220Ohm.

Libraries
rServo 0.9

Circuit
upload_2016-6-17_9-54-30.png

Code
The B4J documented code is attached. The wiring connections are listed in the B4R project file.

Prototype
upload_2016-6-16_12-54-32.png


v20160616
 

Attachments

  • B4RHowToServoMotorCrane.zip
    245 KB · Views: 948
Last edited:
Top