Code running fine on 5V 16Mhz Arduino, but not on 3.3V 8Mhz, not sure why.

I'm trying to run the following code on a Pro Mini 3.3V 8Mhz board. It's a stripped down version of the code from this project, as I don't need any of the LED features included in the original code. It runs fine on a 5V Arduino Nano, but whenever I try using it with the Pro Mini, everything else will work fine, but controllers will fail to sync.

I really need the project to be able to run off a 3-3.6V battery, so I'd like to be able to get the code working, but I can't see anything that would necessarily cause issues or know what the workaround might be.

#include <avr/sleep.h>

#define sync_pin 2 //power button repurposed for sync button (pin 5 on the module)
#define data_pin 3 //data line (pin 6 on the module)
#define clock_pin 4 //clock line (pin 7 on module) 


int sync_cmd[10] =         {0,0,0,0,0,0,0,1,0,0}; 
int turn_off_cmd[10] =     {0,0,0,0,0,0,1,0,0,1}; 

volatile boolean sync_pressed = 0;
int sync_hold_time = 0;
boolean turn_off_controllers = false;

void sendData(int command[])
{
  pinMode(data_pin, OUTPUT);
  digitalWrite(data_pin, LOW);  
  
  int previous_clock = 1;  
  for(int i = 0; i < 10; i++)
  {
    while (previous_clock == digitalRead(clock_pin)){} 
    previous_clock = digitalRead(clock_pin);
    
    digitalWrite(data_pin, command[i]);

    while (previous_clock == digitalRead(clock_pin)){} 
    previous_clock = digitalRead(clock_pin);
  }
  
  digitalWrite(data_pin, HIGH);
  pinMode(data_pin, INPUT);
  
  delay(50);
}

void wakeUp()
{
  sync_pressed = 1;
}

void sleepNow()
{
  set_sleep_mode(SLEEP_MODE_PWR_DOWN); 
  sleep_enable(); 
  attachInterrupt(0, wakeUp, LOW);
  sleep_mode();
  sleep_disable(); 
  detachInterrupt(0); 
}

void setup() 
{
  pinMode(sync_pin, INPUT);
  digitalWrite(sync_pin,HIGH);
  pinMode(data_pin, INPUT);
  pinMode(clock_pin, INPUT);
  delay(2000);
}

void loop()
{
  if(!sync_pressed)
  {
    sleepNow();
  }
  
  delay(200);
  
  if(sync_pressed)
  {    
    
    
    if(sync_hold_time >= 1000)
    {
      turn_off_controllers = true;
      sync_hold_time = 1000;
    }
    
    if (digitalRead(sync_pin))
    {
      
      if(turn_off_controllers)
      {
        sendData(turn_off_cmd);
        
        turn_off_controllers = false;
      }
      else
      {
        sendData(sync_cmd);  
      }
      
      sync_hold_time = 0;
      sync_pressed = false;
    }
    else
    {    
      sync_hold_time += 200;
    }
  }
}

Could you provide more information on the controllers? Is it possible they need to be controlled by 5V lines?

Does something like the Blink example sketch work ok on the Pro Mini?

Not sure the controllers themselves are too important, given they're wireless. The signals between the Xbox RF board and the Arduino Nano all appear to be 3.3V or thereabouts.

The Blink sketch works fine on the Pro Mini...

Well, the Nano will communicate only at 5V. The Pro Mini will depend on the voltage at the Vcc pin.

I assume the Nano is powered via USB. How are you powering the Pro Mini? What is the voltage at its Vcc pin?

Logically, if everything not involving your sensors works ok on the Pro Mini, and assuming your power isn't screwed up, then the sensors don't like the Pro Mini's 3.3V GPIO lines, assuming they are actually 3.3V. The processor should be the same on both Arduinos.

The Nano is powered by USB, not via the on board connector, but still from the 5V USB line. The Pro Mini when connected is powered from the same source, but with a couple of diodes to bring the voltage down a bit.

The RF board as I mentioned seems to be running off 3.3V, the only thing I'm not sure about would be the USB D- and D+ lines.

A Nano and a Pro Mini are not able to communicate wirelessly by themselves, so the controllers are important - somewhere in this you go from wired signals (from your Arduino) to wireless signals (that normally doesn't happen magically, but through another piece of hardware).

In short, until you give FULL details of ALL hardware you use, plus a complete schematic showing how all is connected including the various power sources and interconnections, there's not much we can do to help.

I agree. Now we have two mystery diodes to wonder about. Please post a schematic.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.