Really need help with Uno VS Nano

Hello Everyone! Since a couple of weeks, i desperately try to figure out a weird problem i have:

I have a Arduino Sketch for a simple RGB-LED Mixer controlled by a Windows GUI. I don’t know why, but the functionality only works with a arduino Uno or a Uno clone but not with a Nano or its Clone and i really need to know why?! When i try to test it with a Nano, the RX/TX LEDs are responding to the Input, so theres Data transceived, but it seems that the Nanos are not providing the GUI setup PWM-Rate at all.

Firstly i thought: This has to do womething with the Clone, because of the CH340 Chip, where the original Arduino Nano has a FTDI. So i bought a original Nano, but its not working either, so now i really need the experience of you educated users, since I’m out of ideas now :confused:

Overview of what i already tried:
Arduino Uno: Works
Arduino Nano: Not working
Clone Uno: Works
Clone Nano: Not working
I already tried to burn the bootloader of a Uno to a Nano with no problem, but it did not help at all.
One of my main questions is: What do you think is responsible for the problem? Is it more like the Sketch i attached, or the GUI my programmer developed? I attach you guys the Sketch, so maybe you have a little more insight.

English is not my native language, so i hope you can read everything good and understand what im talking about :slight_smile:

I really appreciate your help and would like to thank you all in advance!

Sample2.ino (4.69 KB)

The only real difference between an Uno and a Nano is the power supply.
Processors/pinout is the same.

So how is the Nano powered, and how are the LED strips and fan connected.
Post a diagram.
Leo..

Hello Leo! I’m not at home atm, but for testing purposes, I only connected a rgb led with resistors to the digital pwm pins 3, 5 and 6. Arduino is powered trough USB as it should be enough for 1 rgb led with 5mm diameter. The common cathode is connected to ground as well.

Thanks for your help so far :slight_smile:

Nobody with an idea left?

I also cannot understand why this would work on Uno and not work on Nano. So you must post the schematic and post the code in code tags as described in the forum sticky post. (Most forum members read the forum with smartphones and tablets most of the time, so cannot open a .ino attachment). Also please post pictures of the circuit using the Uno and the circuit using the Nano. Make sure they are close-up, well-lit and sharply focussed, and neat enough to see where all connections are going.

#include <math.h>
#define TRIGGER1 4
#define TRIGGER2 7
#define TRIGGER3 8
#define RED 9
#define GREEN 6
#define BLUE 5
#define FAN 11


unsigned long long i_breathe = 0;
int breathe_delay = 15;   // delay between loops
unsigned long breathe_time = millis();
char inbyte[64]; String line = "";
byte R{0}, G{0} , B{0} , ana_effect{0};
//This function splits a string tstr into array of strings str_arr with spaces
void split(String tstr , String str_ar[] , int len , char sp = ' ') {
  for (int i{0} , j{0}; i < tstr.length(); i++) {
    if (tstr[i] == sp) {
      j++;
      i++;
    }
    if (j >= len) return;
    str_ar[j] += tstr[i];
  }
}


void ana_continous(byte red , byte green , byte blue)
{
  analogWrite(RED, red); analogWrite(GREEN, green); analogWrite(BLUE, blue);
}

void ana_breath()
{
  if ( (breathe_time + breathe_delay) < millis() ) {
    breathe_time = millis();
    float val = (exp(sin(i_breathe / 2000.0 * PI * 10)) - 0.36787944) * 108.0;
    // this is the math function recreating the effect
    analogWrite(RED, (val / 253.27) * R);
    analogWrite(GREEN, (val / 253.27) * G);
    analogWrite(BLUE, (val / 253.27) * B);
    i_breathe = i_breathe + 1;
  }
}

void ana_cycle()
{
  for (int j = 0; j < 7; j++ ) {
    for (int k = 0; k < 256; k++) {
      switch (j) {
        case 0:
          ana_continous (k , k , 0);
          break;
        case 1:
          ana_continous (0 , k , k);
          break;
        case 2:
          ana_continous (k , 0 , k);
          break;
        case 3:
          ana_continous (k , 0 , 0);
          break;
        case 4:
          ana_continous (0 , k , 0);
          break;
        case 5:
          ana_continous (0 , 0 , k);
          break;
        case 6:
          ana_continous (k , k , k);
          break;
      }

      delay(3);
    }
  }
  /*for (int j = 0; j < 7; j++ ) {
    for (int k = 0; k < 256; k++) {
      switch (j) {
        case 0:
          ana_continous (k , k , k);
          break;
        case 1:
          ana_continous (0 , 0 , k);
          break;
        case 2:
          ana_continous (0 , k , 0);
          break;
        case 3:
          ana_continous (k , 0 , 0);
          break;
        case 4:
          ana_continous (k , 0 , k);
          break;
        case 5:
          ana_continous (0 , k , k);
          break;
        case 6:
          ana_continous (k , k , 0);
          break;
      }

      delay(3);
    }
  }*/
}

void ana_flicker()
{
  ana_continous(R , G , B);
  delay(50);
  ana_continous(0 , 0 , 0);
  delay(50);
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  char go = 0; int can_cont = 0;
  while (go != '%')
  { //Handshake with the software happens here
    Serial.println("Detection);
    delay(100);
    if (Serial.available())
      go = Serial.read();
  }
  Serial.println("Detection Started");
  pinMode(TRIGGER1 , OUTPUT); pinMode(TRIGGER2 , OUTPUT); pinMode(TRIGGER3 , OUTPUT);
  pinMode(RED , OUTPUT); pinMode(GREEN , OUTPUT); pinMode(BLUE , OUTPUT);
  pinMode(FAN , OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  int i = 0;
  if (Serial.available() > 0) {
    delay(10);
    inbyte[i] = Serial.read();
    while (Serial.available() && inbyte[i] != '%' && i < 62) {
      inbyte[i + 1] = Serial.read();
      i += 1;
    }
    // 1) if (i = 1 && inbyte[i] == '%') Serial.println("RainPow");
    if (inbyte[i] == '%') i -= 1;
    inbyte[i + 1] = '\0';
    line = inbyte;
  }

  if (i > 0) {
    //Process line
    Serial.print("From Ard:  ");
    Serial.println(line);

    if (line[0] == 'T' && line.length() >= 3)
    {
      //Trigger Clicked
      int trig = ((char)line[1]) - '0';
      int stat = ((char)line[2]) - '0';

      if (trig == 1) {
        digitalWrite(TRIGGER1 , stat);
        delay(200);
        digitalWrite(TRIGGER1 , LOW);
      } else if (trig == 2) {
        digitalWrite(TRIGGER2 , stat);
        delay(200);
        digitalWrite(TRIGGER2 , LOW);
      } else if (trig == 3) {
        digitalWrite(TRIGGER3 , stat);
        delay(200);
        digitalWrite(TRIGGER3 , LOW);
      }
    } else if (line[0] == 'F' && line.length() >= 2)
    {
      int spd = ((char)line[1]) - '0';
      float f_spd = ((spd * 1.0) / 9.0) * 255;
      analogWrite(FAN , f_spd);
    } else if (line[0] == 'A')
    {
      String in[5];
      split(line, in , 5);
      ana_effect = in[1].toInt();
      R = in[2].toInt(); //analogWrite(RED , R);
      G = in[3].toInt(); //analogWrite(GREEN , G);
      B = in[4].toInt(); //analogWrite(BLUE , B);
    }
    i = 0;
  }


  //Processing loop is here#
  if (ana_effect == 0)
    ana_continous(R , G , B);
  else if (ana_effect == 1)
    ana_breath();
  else if (ana_effect == 2)
    ana_cycle();
  else if (ana_effect == 3)
    ana_flicker();

}

For the Schematic, its pretty easy. Its just an RGB-LED 5mm diameter directly connected to the pins of the Arduinos. Resistor for every color Pin is 180 Ohms and they have common Cathode.

For the Schematic, its pretty easy. Its just an RGB-LED 5mm diameter directly connected to the pins of the Arduinos. Resistor for every color Pin is 180 Ohms and they have common Cathode.

Well, you just proved my point. If the led is connected directly to the pins of the Arduino, where are the resistors connected? And resistors do not have cathodes, common or otherwise. English is crap compared to a schematic, for describing a circuit.

Wawa:
The only real difference between an Uno and a Nano is the power supply.
Processors/pinout is the same.

So how is the Nano powered, and how are the LED strips and fan connected.
Post a diagram.
Leo..

Same processor on Uno and Nano but Nano pin 17 is SCK, 16 is MISO and 15 is MOSI and those are 13, 12 and 11 on Uno.

You likely need to change the pin numbers is all.

GoForSmoke:
Same processor on Uno and Nano but Nano pin 17 is SCK, 16 is MISO and 15 is MOSI and those are 13, 12 and 11 on Uno.

https://www.arduino.cc/en/uploads/Main/Arduino_Nano-Rev3.2-SCH.pdf

I think you may be confusing chip leg numbers and Arduino pin numbers. Many (but not all) Uno have the 28-pin dip chip, but the Nano (and some Uno) have the 32-pin tqfp chip. In terms of Arduino pin numbers, they are the same.

Selecting the correct board when uploading sketch? Actually uploading the sketch and not just verifying?

Can you make sure your setup with the Nanos is working by uploading something simple like Blink?

Did you solder on the headers yourself? Is your soldering skill proficient? Got pics? Are you using proper connections and not just wedging jumpers into PCB holes? (Yes, that has been the case for a few previous confused people)

I built it on a breadboard. The sketches are compiling and uploading with no problem (bytes read and written) comes at the end. Other example sketches are working without any problem, so the controller itself should be okay. I attached the schematic :slight_smile:

Does the LED light up if you use digitalWrite() to manually set pin 3, 5 and 6 HIGH?

cr4nkz:
I attached the schematic

That's not a schematic. But it is clear, so thank you. I can't see a problem with the way you connected that, if it is like your diagram. Can you post some actual pics?

Hi
Your code;

#define RED 9
#define GREEN 6
#define BLUE 5

Your image;
356.jpg
pins 3,5,6?

So which is it?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Does you protoboard have CONTINUOUS power bus lines up either side of the board?

Have you written just SIMPLE CODE just to operate the RGB LED on its own, and tried it in UNO and Nano?

In the IDE did you change the “BOARD” from UNO to NANO?

Tom… :slight_smile: