I trying to determine why the LED's on Pin 7 & 4 do not glow as bright as the pins on 5 & 2.
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.
Top Comments