Hi there!
I am having some issues with a circuit I made to display the gear of my transmission in my car onto an 8x8 max 7219 matrix. To detect the position of the gearstick I am using 4 hall sensor modules connnected to an arduino nano. The sensors recieve 5V and pull a signal pin to ground whenever a magnetic field is detected. I have also wired up everything onto a PCB:
Wiring diagram:
The PCB from the top and bottom
I made the PCB just for securing the arduino and having tidy wiring. It was easier to make large GND and 5V connections (/ "rails") than soldering a bunch of wires together. I also checked for shorts in the PCB multiple times. If there are flaw in my desing please comment, this is the firs time Im doing this.
Now I am having multiple issues:
- Sensor 1 is beeing activated randomly.
- If i activate Sensor 3, the lights of seonsors 2 and 4 are also dimmly glowing (--> they activate).
- These problems seem to happen, even with the sonsors disconnected, so it has to be the PCB assembly.
I have also switched the seonsors around many times, so they shouldn't be the problem.
Since the sensors activate when pulled to GND, I had the idea that there is not enough power beeing supplied to the sensors. Since Sensor 4 is the las one on the 5V rail, maybe it doesn't recieve enough current and if sensor 2 is beeing activated it "steals" the power from the other ones ... ??
I have noticed these issues before, but thought I dealt with them by adding the pullup resistor on the signal pins for the hall sensors into the code. Then it worked for a while, but the problems are back now.
This is my code:
#include <LedControl.h>
int DIN_PIN = 10;
int CS_PIN = 9;
int CLK_PIN = 8;
LedControl lc = LedControl(DIN_PIN, CLK_PIN, CS_PIN, 1);
void setup() {
// Initialize the MAX7219 module
lc.shutdown(0, false); // Turn on the display
lc.setIntensity(0, 15); // Set the brightness to 15 (0-15)
lc.clearDisplay(0); // Clear the display
/* Serial.begin(9600); */
pinMode(2, INPUT_PULLUP); /* Sensor left */
pinMode(3, INPUT_PULLUP); /* Sensor top */
pinMode(4, INPUT_PULLUP); /* Sensor right */
pinMode(5, INPUT_PULLUP); /* Sensor bottom */
}
/* byte ersterGang[8] = {
B00001000,
B00011000,
B00001000,
B00001000,
B00001000,
B00001000,
B00001000,
B00011100
};
byte zweiterGang[8] = {
B00111100,
B01000010,
B00000010,
B00000010,
B00011100,
B00100000,
B01000000,
B01111110
};
byte dritterGang[8] = {
B00111100,
B01000010,
B00000010,
B00011100,
B00000010,
B00000010,
B01000010,
B00111100
};
byte vierterGang[8] = {
B00000100,
B00001100,
B00010100,
B00100100,
B01000100,
B01111110,
B00000100,
B00000100
};
byte fuenfterGang[8] = {
B01111110,
B01000000,
B01000000,
B01111100,
B00000010,
B00000010,
B01000010,
B00111100
};
byte hintenGang[8] = {
B01111100,
B01000010,
B01000010,
B01111100,
B01010000,
B01001000,
B01000100,
B01000010
};
byte neutralGang[8] = {
B01000010,
B01100010,
B01010010,
B01010010,
B01001010,
B01001010,
B01000110,
B01000010
}; */
byte firstGear[8] = {
B00000000,
B00000000,
B00000000,
B10000010,
B11111111,
B10000000,
B00000000,
B00000000
};
byte secondGear[8] = {
B00000000,
B11000010,
B10100001,
B10010001,
B10010001,
B10010001,
B10001110,
B00000000
};
byte thirdGear[8] = {
B00000000,
B01000010,
B10000001,
B10001001,
B10001001,
B10001001,
B01110110,
B00000000
};
byte fourthGear[8] = {
B00000000,
B00110000,
B00101000,
B00100100,
B00100010,
B11111111,
B00100000,
B00000000
};
byte fithGear[8] = {
B00000000,
B01001111,
B10001001,
B10001001,
B10001001,
B10001001,
B01110001,
B00000000
};
byte reverseGear[8] = {
B00000000,
B11111111,
B00001001,
B00011001,
B00101001,
B01001001,
B10000110,
B00000000
};
byte neutralGear[8] = {
B00000000,
B11111111,
B00000010,
B00001100,
B00110000,
B01000000,
B11111111,
B00000000
};
void loop() {
// Display the character on the LED matrix
if(digitalRead(2) == 0 && digitalRead(3) == 0){
for (int i = 0; i < 8; i++) {
lc.setRow(0, i, firstGear[i]);
}
}else if(digitalRead(2) == 0 && digitalRead(5) == 0){
for (int i = 0; i < 8; i++) {
lc.setRow(0, i, secondGear[i]);
}
}else if(digitalRead(2) == 1 && digitalRead(4) == 1 && digitalRead(3) == 0){
for (int i = 0; i < 8; i++) {
lc.setRow(0, i, thirdGear[i]);
}
}else if(digitalRead(2) == 1 && digitalRead(4) == 1 && digitalRead(5) == 0){
for (int i = 0; i < 8; i++) {
lc.setRow(0, i, fourthGear[i]);
}
}else if(digitalRead(4) == 0 && digitalRead(3) == 0){
for (int i = 0; i < 8; i++) {
lc.setRow(0, i, fithGear[i]);
}
}else if(digitalRead(4) == 0 && digitalRead(5) == 0){
for (int i = 0; i < 8; i++) {
lc.setRow(0, i, reverseGear[i]);
}
}else{
for (int i = 0; i < 8; i++) {
lc.setRow(0, i, neutralGear[i]);
}
}
// Clear the display
lc.clearDisplay(0);
}
I would really apreciate any help here, since I am out of ideas. Feel free to ask questions if they help the troubbleshooting process.