element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Blog More eyes on, to explain why
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: colporteur
  • Date Created: 3 Aug 2025 3:09 PM Date Created
  • Views 541 views
  • Likes 6 likes
  • Comments 5 comments
  • nano
  • troubleshoot
  • led_driver
Related
Recommended

More eyes on, to explain why

colporteur
colporteur
3 Aug 2025

I trying to determine why the LED's on Pin 7 & 4 do not glow as bright as the pins on 5 & 2.

image

The nano circuit is for the two floor elevator project  Going Down anyone . I've generated a PCB and during testing, the LED for the bottom floor do not glow as bright as the LED for the top floor. I don't recall this on the bread board but then again I was so excited about 3D printing the servo assembly and making the frame I didn't pay close attention.

I've done the first steps of checking components and found no differences. If I cycle the LED's using bare minimum code there is no brightness difference. If I run top elevator code and bottom independently in their own code as a single door they work. Combine them into the code I created and they glow dimmer.

#include <Arduino.h>
#include <Servo.h>
#include <SoftwareSerial.h>
#include <JQ6500_Serial.h>

uint8_t ServoA = 3;
uint8_t ServoB = 11;
int buttonPin = 6;            // Button to trigger animation
int top_elevator_Status_LED = 5;  // LEDs (via MOSFET) connected to pin 5
int top_elevator_Cabin_LED = 2;  // LEDs (via MOSFET) connected to pin 5
int bot_elevator_Status_LED = 7;  // LEDs (via MOSFET) connected to pin 5
int bot_elevator_Cabin_LED = 4;  // LEDs (via MOSFET) connected to pin 5
int busyPin = 10;             // JQ6500 BUSY connected to pin 10
int top_door_Open = 50;
int top_door_Closed = 87;
int bot_door_Open = 50;
int bot_door_Closed = 87;

float Ginc_value = .25;  // increment value to control speed of servo at gate
int posA = 50;            // variable to store the servo position
int posB = 50;

Servo servoA;  //initialize servo
Servo servoB;  //initialize servo
// Create the mp3 module object,
//   Arduino Pin 8 is connected to TX of the JQ6500
//   Arduino Pin 9 is connected to one end of a  1k resistor,
//   the other end of the 1k resistor is connected to RX of the JQ6500
//   If your Arduino is 3v3 powered, you can omit the 1k series resistor


SoftwareSerial mySerial(8, 9);  //SoftwareSerial(rxPin, txPin) as seen from Arduino
JQ6500_Serial mp3(mySerial);
unsigned int numFiles;  // Total number of files on media (autodetected in setup())
unsigned int pick;      // what sound index file to play
byte mediaType;         // Media type (autodetected in setup())

//debounce
int counter = 0;
int buttonState = 0;
int lastButtonState = 0;

int currentButtonState = 0;
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 50;

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(top_elevator_Status_LED, OUTPUT);
  pinMode(top_elevator_Cabin_LED, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  servoA.attach(ServoA, 544, 2400);//600,2200
  servoB.attach(ServoB, 544, 2400);
  servoA.write(top_door_Closed);  //default the servo before start
  servoB.write(bot_door_Closed);  //default the servo before start
  mySerial.begin(9600);
  while (numFiles == 0) {
    mp3.reset();
    mp3.setVolume(30);
    mp3.setLoopMode(MP3_LOOP_NONE);

    // Try to get the number of files on the SD Card
    numFiles = mp3.countFiles(MP3_SRC_SDCARD);

    if (numFiles) {
      // If there are SD Card files, make sure we have selected that source
      mp3.setSource(MP3_SRC_SDCARD);
      mediaType = MP3_SRC_SDCARD;
    } else {
      // If none are found, the SD Card is not present or empty, so use
      // the on board memory; Make sure we select the built in source
      mp3.setSource(MP3_SRC_BUILTIN);
      numFiles = mp3.countFiles(MP3_SRC_BUILTIN);
      mediaType = MP3_SRC_BUILTIN;
    }

    if (!numFiles) {
      Serial.println(F("Error! No files were found on the media, both SD Card and Built In memory were checked."));
      Serial.println(F("We will try again in 3 seconds."));
      Serial.println(F("If there are files there and we still can't find them, try turning everything off and on again, perhaps the module is confused."));
      Serial.println(F("I think this might happen sometimes if you insert/remove an SD Card while powered up, but not totally sure!"));
      Serial.println(F("In a real application, you might consider powering the JQ6500 module through a suitable MOSFET or BJT controlled from a pin so you can power-cycle the JQ6500 if it starts to act weird like this!"));
      delay(3000);
    }
  }
  // mitigate "pseudo random" by sampling the noise on analogue pin0 and use it as a value.
  randomSeed(analogRead(A0));
}

void loop() {
  currentButtonState = digitalRead(buttonPin);

  if (currentButtonState != lastButtonState) {
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay) {
    if (currentButtonState != buttonState) {
      buttonState = currentButtonState;
      if (buttonState == LOW) {
        seq_top_Elevator();
        delay(3000);
        seq_bot_Elevator();
      }
    }
  }
  lastButtonState = currentButtonState;
}

void seq_top_Elevator()
{digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on
        //trigger servo
        digitalWrite(top_elevator_Cabin_LED, HIGH);
        digitalWrite(top_elevator_Status_LED, HIGH);  //trigger external LED (this may be mosfet driver)
        delay(15);
        mp3.playFileByIndexNumber(1);
        for (posA = top_door_Closed; posA >= top_door_Open; posA -= 1) {  // goes from 180 degrees to 0 degrees
          servoA.write(posA);                   // tell servo to go to position in variable 'pos'
          delay(15);                           // waits 15 ms for the servo to reach the position
        }
        delay(5000);
        for (posA = top_door_Open; posA <= top_door_Closed; posA += 1) {  // goes from 0 degrees to 180 degrees
          // in steps of 1 degree
          servoA.write(posA);  // tell servo to go to position in variable 'pos'
          delay(15);          // waits 15 ms for the servo to reach the position
        }
        digitalWrite(top_elevator_Status_LED, LOW);
        digitalWrite(top_elevator_Cabin_LED, LOW);

        // pick a random file, numbered 1 to numFiles (NB: random() returns up to but not including the highest number, hence why we add 1)
        // if the file is the same as the one which was just played, pick a different one

        if (digitalRead(busyPin) == LOW) {
        }
        //servoA.write(door_Closed);
        digitalWrite(LED_BUILTIN, LOW);  // turn the LED off
        }

void seq_bot_Elevator()
{digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on
        //trigger servo
        digitalWrite(bot_elevator_Cabin_LED, HIGH);
        digitalWrite(bot_elevator_Status_LED, HIGH);  //trigger external LED (this may be mosfet driver)
        delay(15);
        mp3.playFileByIndexNumber(1);
        for (posB = bot_door_Closed; posB >= bot_door_Open; posB -= 1) {  // goes from 180 degrees to 0 degrees
          servoB.write(posB);                   // tell servo to go to position in variable 'pos'
          delay(15);                           // waits 15 ms for the servo to reach the position
        }
        delay(5000);
        for (posB = bot_door_Open; posB <= bot_door_Closed; posB += 1) {  // goes from 0 degrees to 180 degrees
          // in steps of 1 degree
          servoB.write(posB);  // tell servo to go to position in variable 'pos'
          delay(15);          // waits 15 ms for the servo to reach the position
        }
        digitalWrite(bot_elevator_Status_LED, LOW);
        digitalWrite(bot_elevator_Cabin_LED, LOW);

        // pick a random file, numbered 1 to numFiles (NB: random() returns up to but not including the highest number, hence why we add 1)
        // if the file is the same as the one which was just played, pick a different one

        if (digitalRead(busyPin) == LOW) {
        }
        //servoA.write(door_Closed);
        digitalWrite(LED_BUILTIN, LOW);  // turn the LED off
        }

I'm taking the PCB to the shop to try adding a capacitor closer to the JQ6500 and the voltage output to the servo. Shabaz had recommended a capacitor for long runs the last time I had problems and it resolved them.

I confess I'm clutching here. The caps are for power that is not Nano related. LED's glowing dimmer is because of the Nano. I'm using a lot of pins. They are not on all at the same time to create an excessive load. I wish I was working to go for coffee with the tech folks. We would napkin out a solution for this in no time.

I was hoping some eyes on the circuit and code you might see "Oh yeah you failed to do this." Off to the shop to try the soldering iron.

  • Sign in to reply

Top Comments

  • beacon_dave
    beacon_dave 1 month ago +2
    pinMode setup for the bottom elevator ?
  • JWx
    JWx 1 month ago in reply to beacon_dave +1
    only two are configured as outputs: pinMode(top_elevator_Status_LED, OUTPUT); pinMode(top_elevator_Cabin_LED, OUTPUT); and the docs say: Pins configured as OUTPUT with pinMode() are said to be in…
  • Jan Cumps
    Jan Cumps 1 month ago in reply to colporteur

    ...  telling me it took hours to find the issue and not just a mere "oh you missed the pimmode" on a cursory glance...

    That is not how the human brain works Slight smile

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • colporteur
    colporteur 1 month ago in reply to beacon_dave

    BD, salve my programming ego by telling me it took hours to find the issue and not just a mere "oh you missed the pimmode" on a cursory glance. Your answer was what the sketch was missing.

    Confession: I wrote and tested the two elevator sketch, when the video was posted for the elevator construction. I put the code aside while the modeler caught up in the work to install the elevator in the main building. I also set about creating a PCB for the project because the elevator animation had grown into two animations in different parts of the building.

    It is July and I have the PCB's and the elevators are in the tower. Where is the code? It appears I did something in git and the code is no more. There is a one elevator sketch that doesn't work. The very beginning of the project. No working two-elevator code! How hard could it be the write it again? After a marathon code writing exercise I began testing using the PCB.

    I've been working on the project off an on for few a weeks to correct issues. The weak LED was one symptom the other intermittent operation of the sound board. Sometime it worked sometime not. I shelved the weak LED to look at the sound card (i.e. the power supply suggestions I made in my post).

    Your fix eliminated the intermittent sound issue and the LED brightness.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • JWx
    JWx 1 month ago in reply to beacon_dave

    only two are configured as outputs: 

    pinMode(top_elevator_Status_LED, OUTPUT);
    pinMode(top_elevator_Cabin_LED, OUTPUT);

    and the docs say:

    Pins configured as OUTPUT with  pinMode()

    are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. ATmega pins can source (provide current) or sink (absorb current) up to 40 mA (milliamps) of current to other devices/circuits. This makes them useful for powering LEDs because LEDs typically use less than 40 mA. Loads greater than 40 mA (e.g. motors) will require a transistor or other interface circuitry.

    Pins configured as outputs can be damaged or destroyed if they are connected to either the ground or positive power rails.
    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • kmikemoo
    kmikemoo 1 month ago

    I didn't see anything in the code.

    Do the lower LEDs start out dim or are they bright then dim?  You may need to lengthen your delay to determine this.  Is the lower servo fed power or ground on a common conductor to the LEDs?  It could be a voltage drop issue.  I'm also wondering if you might have a "leaky" MOSFET.
    (I had a replacement generator controller once where OFF wasn't really OFF.  Enough current leaked through the MOSFETs that the generator would start as soon as battery power was applied to the controller.)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • beacon_dave
    beacon_dave 1 month ago

    pinMode setup for the bottom elevator ? 

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube