Using an RC Controller with an Arduino [With code and wiring]

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 มิ.ย. 2024
  • Using an RC controller with an Arduino - Part 1
    In this video I show you how to use an RC controller to send signals to an Arduino controller. I explain how interrupts work, demonstrate the serial plotter and we write the code together.
    All the code for this video is available for free on my website.
    www.andyvickers.net/2020/12/1...
    I accept no liability for any damage you do to yourself or your property. Do your research, use your common sense. This shows I assembled my machine and what worked for me. your mileage may vary
    Links
    -------------------------------------------------------------------------------------------------
    * Some of the links below are affiliate links. You pay no more, but I may earn a small amount of money to help my channel grow
    (Orange Controller) Radiolink AT10II 2.4G 12 Channels RC Transmitter and Receiver R12DS - amzn.to/31bSnfT
    R12 DS Receiver if buying separate - amzn.to/3lKzqKD
    Jumper Cables - amzn.to/39bzG0f
    Arduino Mega 2560 - amzn.to/3sl1RBE

ความคิดเห็น • 37

  • @KordiakDG
    @KordiakDG ปีที่แล้ว +1

    I was struggling with a solution which I made in my AVR for whole day, but just a few minutes of watching your video solved my problem. Thank you:)

  • @user-od8ws7vg4v
    @user-od8ws7vg4v 2 ปีที่แล้ว +5

    Finally I found what I need. Super, but part 2 is still not (The author does not abandon the topic. I really look forward to continuing. Thank you so much.

    • @AndyVickersNet
      @AndyVickersNet  ปีที่แล้ว

      Part 2 is live! I hope it gives you what you need

  • @AmitsLife
    @AmitsLife ปีที่แล้ว

    I really appreciate your clear and concise video.

  • @ayushsalunkhe504
    @ayushsalunkhe504 2 ปีที่แล้ว

    Great work sir keep it up

  • @AChi__
    @AChi__ ปีที่แล้ว +1

    Wow! You achieved superhero status with your level of crisp and crystal clear explanations. Yep, you earned yourself my humble sub as my token of thanks and appreciation. By chance, did you make the part 2 yet?

    • @AndyVickersNet
      @AndyVickersNet  ปีที่แล้ว +1

      Thank you SO MUCH for the kind feedback! Part 2 just posted! I hope it lives up to part 1!

    • @AChi__
      @AChi__ ปีที่แล้ว

      @@AndyVickersNet Yes it did. Great stuff man 👍🏽👍🏽

  • @chrisg.berdin3213
    @chrisg.berdin3213 2 ปีที่แล้ว +1

    good instructions ,i need part2 of this video

    • @AndyVickersNet
      @AndyVickersNet  2 ปีที่แล้ว

      If you have suggestions for part 2 let me know, I have been working on this video but I can certainly add more before I publish if you can think of something you would like to see!

    • @MrJohnGuthrie
      @MrJohnGuthrie 2 ปีที่แล้ว

      @@AndyVickersNet Great tutorial, thank you. I hope you continue to develop this series into a functional four wheel RC robotics platform. There are lots of impressive 4 wheel robot videos on youtube and some even use RC controls and have "skid steering" (turn in place) but I haven't seen a series that takes it from start to finish with the detail you're providing. Cheers!

  • @mertcapkin7263
    @mertcapkin7263 3 ปีที่แล้ว +1

    Great video!

  • @frankhodges6734
    @frankhodges6734 2 ปีที่แล้ว +1

    Good video and I look forward to part two.I like the plotter, hadn't seen anyone use that before. I have a project where I need to remotely control a 4000w hub motor that will be used as a winch. The motor's controller requires a 0 to 5v analog input signal to control the speed of the motor in one direction only so, I need the RC receiver PWM signal to enter the arduino nano that I have and come out as an analog signal. I understand the Nano does not have a real analog output but a pulsed output mimicking analog but, I was wondering if the tiny MCP4725 PWM to Analog module that I have could turn that into a smooth variable DC output. I've never done this sort of thing before and have spent some time scratching around the net trying to get some idea as to what code I would need and wondered if your code could be adapted. I would only be using one channel on my 3 channel receiver so would think the code would look rather spartan in comparison. Would you have any ideas on my problem please other than give-up {:-))

  • @charlmy8ightbuggy227
    @charlmy8ightbuggy227 ปีที่แล้ว

    AWESOME Thank You

  • @jeffrockow6282
    @jeffrockow6282 ปีที่แล้ว

    Very nice explanation. This is going to help me out a bunch. I realize there are 101 ways to code the same functionality, but I was wondering if you see an advantage in storing the PWM duration into RC_SHARED and then calling the rc_read_values subroutine to port the values into RC_VALUES. Why not just store the PWM duration directly into RC_VALUES and eliminate the rc_read_values subroutine altogether?

  • @crckdns
    @crckdns ปีที่แล้ว

    nice explanation,
    but does it work parallel?
    I mean, interrupt interrupts whole flow to compute a thing...
    what if at the same time second input comes in? or third? or all 4 channels?
    can it handle all 4 inputs at same time and provide proper reading/acting?

  • @samiulhoque3769
    @samiulhoque3769 ปีที่แล้ว

    This was really helpful! Any news on part 2 of this video?

    • @AndyVickersNet
      @AndyVickersNet  ปีที่แล้ว +1

      Yes! This was released, please check it out!

  • @robertmurton7373
    @robertmurton7373 2 ปีที่แล้ว +1

    Hello Andy have published part 2 yet. I was thinking of using a set frequency for pwm so I wouldn't need interrupts

    • @AndyVickersNet
      @AndyVickersNet  ปีที่แล้ว

      Second video is live! I am not sure what you mean with the set frequency. Is there a reason you want to remove the interrupts?

  • @emperortech1312
    @emperortech1312 ปีที่แล้ว

    Good

  • @hithishi5292
    @hithishi5292 2 ปีที่แล้ว

    Really helpful, thanks a lot!!
    how to control 2 DC motors (which has encoder with PWM ,DIR and A&B feedback pins) using RC receiver!!
    And Can the code support PPM
    (It would be great, Even if the video is about PPM and DIR pins only)
    thank you very much!!

    • @AndyVickersNet
      @AndyVickersNet  ปีที่แล้ว

      Part 2 has servo control in it. Setting up steppers would be very easy if you follow that example

  • @bektinurwanto
    @bektinurwanto ปีที่แล้ว

    This metode to receive Ppm output from remote sir?

  • @muratozdemir1167
    @muratozdemir1167 ปีที่แล้ว

    Can you help with a code that can drive this project with a stepper motor?

  • @Euforia706
    @Euforia706 2 ปีที่แล้ว

    I have and Arduino Nano, but it's not working, i change the pins from 18, 19, 20 and 21 to digital 8, 9, 10 and 12 but nothing- Help

    • @AndyVickersNet
      @AndyVickersNet  ปีที่แล้ว

      Only pins 2&3 are interrupts on the nano according to the arduino website:
      www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/#:~:text=Uno%2C-,nano,-%2C%20Mini%2C%20other%20328%2Dbased

  • @random_idRI
    @random_idRI ปีที่แล้ว

    How to make suspensi wit servo

  • @ARTronics-jy2gc
    @ARTronics-jy2gc 2 ปีที่แล้ว

    hi bro nice presentaion. how to do codeing for rc car using arduino uno...........

    • @AndyVickersNet
      @AndyVickersNet  ปีที่แล้ว

      Part 2 of the RC controller series is up and that shows servos so it should get you half way there!

  • @electroshiv4661
    @electroshiv4661 ปีที่แล้ว

    Hello, sir can you help me in writing a Arduino code

    • @AndyVickersNet
      @AndyVickersNet  ปีที่แล้ว

      All the code is available on my website linked in the description

  • @mohamedramdhanemesmoudi6411
    @mohamedramdhanemesmoudi6411 2 ปีที่แล้ว

    I need part 2 ????

    • @AndyVickersNet
      @AndyVickersNet  ปีที่แล้ว

      Its been released! Please check it out and let me know if it helps!

  • @argentosebastian
    @argentosebastian ปีที่แล้ว

    I'm getting a "'rc_read_values' was not declared in this scope" error. Why??
    // Set the size of the arrays (increase for more channels)
    #define RC_NUM_CHANNELS 4
    // Set up our receiver channels - these are the channels from the receiver
    #define RC_CH1 0 // Right Stick LR
    #define RC_CH2 1 // Right Stick UD
    #define RC_CH3 2 // Left Stick UD
    #define RC_CH4 3 // Left Stick LR
    // Set up our channel pins - these are the pins that we connect to the receiver
    #define RC_CH1_INPUT 18 // receiver pin 1
    #define RC_CH2_INPUT 19 // receiver pin 2
    #define RC_CH3_INPUT 20 // receiver pin 3
    #define RC_CH4_INPUT 21 // receiver pin 4
    // Set up some arrays to store our pulse starts and widths
    uint16_t RC_VALUES[RC_NUM_CHANNELS];
    uint32_t RC_START[RC_NUM_CHANNELS];
    volatile uint16_t RC_SHARED[RC_NUM_CHANNELS];
    // Setup our program
    void setup() {

    // Set the speed to communicate with the host PC
    Serial.begin(9500);
    // Set our pin modes to input for the pins connected to the receiver
    pinMode(RC_CH1_INPUT, INPUT);
    pinMode(RC_CH2_INPUT, INPUT);
    pinMode(RC_CH3_INPUT, INPUT);
    pinMode(RC_CH4_INPUT, INPUT);
    // Attach interrupts to our pins
    attachInterrupt(digitalPinToInterrupt(RC_CH1_INPUT), READ_RC1, CHANGE);
    attachInterrupt(digitalPinToInterrupt(RC_CH2_INPUT), READ_RC2, CHANGE);
    attachInterrupt(digitalPinToInterrupt(RC_CH3_INPUT), READ_RC3, CHANGE);
    attachInterrupt(digitalPinToInterrupt(RC_CH4_INPUT), READ_RC4, CHANGE);
    }
    // Thee functions are called by the interrupts. We send them all to the same place to measure the pulse width
    void READ_RC1() {
    Read_Input(RC_CH1, RC_CH1_INPUT);
    }
    void READ_RC2() {
    Read_Input(RC_CH2, RC_CH2_INPUT);
    }
    void READ_RC3() {
    Read_Input(RC_CH3, RC_CH3_INPUT);
    }
    void READ_RC4() {
    Read_Input(RC_CH4, RC_CH4_INPUT);
    }
    // This function reads the pulse starts and uses the time between rise and fall to set the value for pulse width
    void Read_Input(uint8_t channel, uint8_t input_pin) {
    if (digitalRead(input_pin) == HIGH) {
    RC_START[channel] = micros();
    } else {
    uint16_t rc_compare = (uint16_t)(micros() - RC_START[channel]);
    RC_SHARED[channel] = rc_compare;
    }
    }
    void loop() {

    // read the values from our RC Receiver
    rc_read_values();
    }
    / this function pulls the current values from our pulse arrays for us to use.
    void rc_read_values() {
    noInterrupts();
    memcpy(RC_VALUES, (const void *)RC_SHARED, sizeof(RC_SHARED));
    interrupts();
    }
    // output our values to the serial port in a format the plotter can use
    Serial.print( RC_VALUES[RC_CH1]); Serial.print(",");
    Serial.print( RC_VALUES[RC_CH2]); Serial.print(",");
    Serial.print( RC_VALUES[RC_CH3]); Serial.print(",");
    Serial.println(RC_VALUES[RC_CH4]);