-
Notifications
You must be signed in to change notification settings - Fork 0
Example 16‐EncoderMotor and LED controlled by FlySky FS‐i6X‐RemoteControl
Hans Rothenbuehler edited this page Apr 3, 2025
·
2 revisions
This example use three channel of the FlySky-RemoteControl. A joystick-axis to control the speed of a encoder motor and a switch-channel to turn a lamp on and off. The channel VrA controls the brightness of the LED If Sketch Made EASY is installed, it can be opened via menu: "File:/Example/SketchMadeEASY/Examples/16-EncoderMotorAndLedControlledByFlySky".
#include <Easy.h>
//*****************************************************************
// Parameter MotorShield L9110
#define MOTOR_PINA1 44
#define MOTOR_PINB1 46
#define MOTOR_PINA2 11
#define MOTOR_PINB2 12
// Parameter Rotary Encoder
#define ENCA 3 // (use a interrupt when RISING, read doc to attachInterupt() to get usable pins)
#define ENCB 4
// Motor N20, n=100m 6V
#define MOTOR_RPM_MAX 60
#define PPR 7
#define GEAR_RATIO 150
// Parameter of LED
#define LED_PIN 6
void setup()
{
//((*** Initialize: Configure your sketch here....
//** Define motor controlled by Axis-Joystick of RemoteControl
//* Create actuator: Encoder gear motor
Actuator* encoderMotor = new EncoderMotorL9110(MOTOR_PINA2, MOTOR_PINB2, ENCA, ENCB, PPR, GEAR_RATIO, 0);
//* Create input: Input is at RemoteControl FlySky
RemoteControl* flySky = new FlySky(scHard2);
//* Define logic with condition and relation
Relation* relationMotor = new Relation1to1(NULL, encoderMotor, flySky->getControl(rcJoystick1X));
//** Define LED controlled by a switch at RC
//* Create actuator: LED
Actuator* led = new DigitalOutput(LED_PIN);
//* Define logic with condition and relation
// Switch is on, brightness with a Poti on the RC, direct assignement without variable of the RC inputs.
Condition* conditionSwitchOn = new CompareCondition(flySky->getControl(rcSwA), OpEQ, RemoteValue::Pos1);
Relation* switchOnRelation = new Relation1to1(conditionSwitchOn, led, flySky->getControl(rcVrA));
// Switch is off
Condition* conditionSwitchOff = new CompareCondition(flySky->getControl(rcSwA), OpEQ, RemoteValue::Pos0);
Relation* switchOffRelation = new Relation1to1(conditionSwitchOff, led, FixValue::Off());
// ***))
// Initialize control
ControlManagerFactory::GetControlManager()->Setup();
}
//*****************************************************************
void loop() {
//*** Run: No additional code is required
ControlManagerFactory::GetControlManager()->Loop();
// Depending on Arduino it needs a short delay. Do not add any other delays!
delay(5);
}Wiki
Getting started
Classes
Input
- Calculate
- ConditionInput
- DependentInput
- DigitalInput
- FixValue
- Inverter
- IteratorValue
- JoystickAxis
- LoopSwitch
- MonoFlop
- Switch2Position
- Switch3Position
- Timer
- ToggleSwitch
- UltrasonicRangefinder
- VariableInput
Actuator
- ActuatorCollection
- Buzzer
- DigitalOutput
- EncoderMotorI2C
- EncoderMotorL298
- EncoderMotorL9110
- MotorI2C
- MotorL298
- MotorL9110
- MotorStepperRotate
- MotorStepperRotateI2C
- Servo360I2C
- Servo360PWM
- Servo360T1
- Servo360T2
- ServoPWM
- ServoStepperPosition
- ServoStepperPositionI2C
- ServoI2C
- ServoT1
- ServoT2
- VariableOutput
Condition
Relation
RemoteControl
Common
Sketches
Templates
Examples
- 01-Switch and Lamp
- 02-Dimming LED
- 03-Dimming LED with Switch
- 04-Blinking LED
- 05‐Motor fix speed, direction‐switch
- 06‐Motor variable speed, direction‐switch
- 07‐Motor variable speed, direction‐ and main‐switch
- 08‐Motor toggles between limit switches
- 09‐Motor toggles between limit switches, main switch
- 10‐Main Motor turns between limit switches, second follows
- 11-Two motors, one turns after the other
- 12-Servo360 controlled by a Joystick
- 13-Stepper motor with variable speed
- 14-RemoteControl of a motor with FlySky FS-i6X
- 15-RemoteControl of a motor with an App
- 16-EncoderMotor and LED controlled by FlySky-RemoteControl
- 17-Servo position in relation to a potentiometer
- 18-Stepper angle controlled by joystick
- 19-Buzzer tone in relation to distance
- 20-Dependent input
- 21-Alternate blink