I'm using an Arduino Nano 33 BLE and a L293D motor driver to control a three-wheeled RC robot. The sketch I'm using worked fine with my Uno Rev3, but I've moved to the Nano for size/weight reasons, and it's no longer working. Whenever I turn the power on, the motor I'm using to test spins clockwise at what appears to be full-speed, without considering the receiver's signal at all. I actually removed the wires from the receiver and the motor just kept on spinning.

I tried looking at the serial plotter, but it appears that the Nano is disconnecting itself from my laptop whenever I turn the RC transmitter on, so I haven't been able to get any information that way.

I've troubleshooted to the best of my limited ability, and the problem seems to be with the Nano not processing the signals from the receiver. Beyond that, though, I don't have the first clue what the root of the problem is. I'm pretty new to Arduino & coding haha.

I followed this YouTube tutorial for the process of reading the RC values, and the variables with color names are referring to the motors. Here's the sketch:

//set the port speed for host communication
#define SERIAL_PORT_SPEED 115200

#include <math.h>
#define RC_CH1 0 //right stick LR
#define RC_CH2 1 //right stick UD
#define RC_CH1_INPUT 2 //pin 2 on arduino
#define RC_CH2_INPUT 3 //pin 3 on arduino

// Set up some arrays to store our pulse starts and widths
volatile uint16_t RC_SHARED[RC_NUM_CHANNELS];

const int enable_pink = 13; //pin that enables pink motor
const int enable_blue = 12;
const int enable_yellow = 11;

int dead_zone = 10; //within 10 of 0, motor will not move
const int error_pin = 4; //this lights up when something unexpected happens
int UD;
int RL;
double pi = 3.1415926; 

int pink; // analog value out of 255 for the pink motor
const int pink_cw = 5; // pin that signals pink motor to move clockwise
const int pink_ccw = 6; //pin signals counterclockwise
int blue; 
const int blue_cw = 7;
const int blue_ccw = 8;
int yellow; 
const int yellow_cw = 9;
const int yellow_ccw = 10;

void setup() {
  // set the speed to communicate with the host PC:

  //set pin modes to input for reciever
  pinMode(RC_CH1_INPUT, INPUT);
  pinMode(RC_CH2_INPUT, INPUT);
  //attach interrupts to these pins
  attachInterrupt(digitalPinToInterrupt(RC_CH1_INPUT), READ_RC1, CHANGE);
  attachInterrupt(digitalPinToInterrupt(RC_CH2_INPUT), READ_RC2, CHANGE);
  //set pin mode for error pin
  pinMode(error_pin, OUTPUT);

  //set all green wires (motor-enabling wires) to OUTPUT
  pinMode(enable_pink, OUTPUT);
  pinMode(enable_blue, OUTPUT);
  pinMode(enable_yellow, OUTPUT);

  //set all motor signal outputs to OUTPUT
  pinMode(pink_cw, OUTPUT);
  pinMode(pink_ccw, OUTPUT);
  pinMode(blue_cw, OUTPUT);
  pinMode(blue_ccw, OUTPUT);
  pinMode(yellow_cw, OUTPUT);
  pinMode(yellow_ccw, OUTPUT);
  //enable all motors
  digitalWrite(enable_pink, HIGH);
  digitalWrite(enable_blue, HIGH);
  digitalWrite(enable_yellow, HIGH);


void loop() {
  // read the values from our RC reciever

  //map RC values to analog scale
  UD = map(RC_VALUES[RC_CH1], 800, 2200, -100, 100);
  RL = map(RC_VALUES[RC_CH2], 800, 2200, -100, 100);

  //output raw RC input to serial plotter
  Serial.print(UD); Serial.print(",");

  //do the math to calculate wheel vectors
  pink = RL;
  blue = (UD/(cos(pi/3))) + (RL/(sin(pi/3)));
  yellow = -(UD/(cos(pi/3))) - (RL/(sin(pi/3)));
  //now map the wheel vectors to analog scale:
  blue = map(blue, -800, 800, -255, 255);
  yellow = map(yellow, -800, 800, -255, 255);

  //now, output each value to each motor
  set_color(pink, pink_cw, pink_ccw);
  set_color(blue, blue_cw, blue_ccw);
  set_color(yellow, yellow_cw, yellow_ccw);

  //output pink blue and yellow values to serial plotter:
  Serial.print(pink); Serial.print(",");
  Serial.print(blue); Serial.print(",");


//create function to give the signals to the motors
void set_color(int color, int color_cw, int color_ccw) { 
  if (color > dead_zone) { 
    analogWrite(color_cw, color);
  } else if (color <-(dead_zone)) { 
    analogWrite(color_ccw, abs(color));
  } else if (color <= dead_zone && color >= -(dead_zone)) {
  } else {
    digitalWrite(error_pin, HIGH);

// These 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);

// 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;

// this function pulls the current values from our pulse arrays for us to use. 
void rc_read_values() {
  memcpy(RC_VALUES, (const void *)RC_SHARED, sizeof(RC_SHARED));

any help would be greatly appreciated, I'm truly stumped here

  • a smaller Uno is a classic Nano. Nano 33 BLE is very different and uses Mbed OS.
    – Juraj
    Jun 9, 2023 at 8:56
  • The "nano" is basically form factor + pinout, 33 in the board name means it's 3.3V only board (usually has ARM mcu) and being said nano 33 ble has mbed-os which means your code will be interrupted by other threads (unless it has higher priority than other threads)
    – KIIV
    Jun 9, 2023 at 11:31


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.