How to read leds of a parking sensor

Hi,

I'm junior level maker and messing with an old parking sensor just for fun and to learn new things.

I've searched through forum and found couple subjects how to read parking sensors but it's little bit complicated for me so i want to try a different approach to do so.

As you can see in picture my parking sensor has a led screen that shows you to distance of the object on the right and left

I thought i can read first LED's status to find out which sensor triggered by obstacle(It's range is 1.5 meters, when an obstacle started to get closer to the sensor first led is on and it continue as the obstacle is getting closer.).

Second picture :

So there are 7 leds but 8 pins, 8th pin is GND and the first pin is first led's VCC, when i check with multimeter in buzzer mode there are no signal (closed circuit/multimter is not beeping) between first pin and GND, but when sensor triggered first led is on and multimeter beeping (circuit is closing). Ground is connected to GND on arduino MEGA and the LED's vnc is connected to 52th port.

I thought i can read closed circuit with using "INPUT_PULLUP" method and writed my code like below;

int LEFT = 52;
void setup() 
{
Serial.begin(9600);  
pinMode(LEFT, INPUT_PULLUP);
}

void loop() 
{
int LEFTSTATUS=digitalRead(LEFT);
if (LEFTSTATUS==HIGH)  
{
Serial.print("LEFT SENSOR TRIGGERED");  
Serial.println("");
}//LEFT IS HIGH
else
{
Serial.print("IDLE");  
Serial.println("");
}
}

when there is no trigger serial output is "IDLE" but when sensor triggered monitor is going crazy as below;

IDLE
LEFT SENSOR TRIGGERED
IDLE
LEFT SENSOR TRIGGERED
IDLE
LEFT SENSOR TRIGGERED
IDLE
LEFT SENSOR TRIGGERED
IDLE
LEFT SENSOR TRIGGERED
IDLE
LEFT SENSOR TRIGGERED
IDLE
LEFT SENSOR TRIGGERED
IDLE
LEFT SENSOR TRIGGERED
IDLE
LEFT SENSOR TRIGGERED
IDLE
LEFT SENSOR TRIGGERED
IDLE
LEFT SENSOR TRIGGERED
IDLE
LEFT SENSOR TRIGGERED

It seems like somehow LED is on and off like under 1 second.

After many tries i've changed my approach to read LED's status and changed my code as below;

int LEFT = 52;
void setup() 
{
Serial.begin(9600);  
pinMode(LEFT, INPUT);
}

void loop() 
{
int LEFTSTATUS=digitalRead(LEFT);
if (LEFTSTATUS==HIGH)  
{
Serial.print("LEFT SENSOR TRIGGERED");  
Serial.println("");
}//LEFT IS HIGH
else
{
Serial.print("Im IN SPACE :)");  
Serial.println("");
}
}

Unfortunatelly it doesn't work and the serial output only says "IDLE" even if the led is on.

Also there is a buzzer on the screen, i've cutted it's cable and connected it's GND to GND on arduino MEGA and the VNC to the 52th port, when i run my code it's perfectly working, i mean if there is no obstacle it says IDLE and when there is an obstacle it says TRIGGERED, but the problem is buzzer rings when any sensor triggered, there is no way to seperate as LEFT or RIGHT.

I know i can set-up same system with using sonic sensor but as i said i'm junior level and just trying to learn new things from experienced friends & communities.

Thanks in advance any ideas will be appreciated.

Hello,

I think you have discovered that the display is multiplexed. What that means is that the display is not on all the time but turns on and off rapidly, too fast for your eyes to see but easilly slow enough for an Arduino to detect. This is common practice with LED displays, although it not always the case. Multiplexing reduces the number of wires needed to control the LEDs.
Display multiplexing
Charlieplexing

If you move your eyes rapidly past the display you might just catch the flickering multiplexing causes.

I'm trying to work out what you mean by VNC. Maybe you mean Vcc? I suspect you need to do some research on how to connect LEDs with series resistors and on driving LEDs generally.

PerryBebbington:
Hello,

I think you have discovered that the display is multiplexed. What that means is that the display is not on all the time but turns on and off rapidly, too fast for your eyes to see but easilly slow enough for an Arduino to detect. This is common practice with LED displays, although it not always the case. Multiplexing reduces the number of wires needed to control the LEDs.
Display multiplexing
Charlieplexing

If you move your eyes rapidly past the display you might just catch the flickering multiplexing causes.

I'm trying to work out what you mean by VNC. Maybe you mean Vcc? I suspect you need to do some research on how to connect LEDs with series resistors and on driving LEDs generally.

Thanks for your kind reply, you are absolutely right about "VNC" it's Vcc sorry for that. I thought the same thing about led but i wasn't know the right name of it,i've learned one thing thanks again.

Can we say that if i can replace those LEDs with standard round shaped LED can i read it via arduino ? Or if i just un-soldered those LCD indicators and solder metal pins instead can i read closed circuit ? Because as far as i understand it's rapidly turning of and on because of LED's nature ?

Can we say that if i can replace those LEDs with standard round shaped LED can I read it via Arduino?

I suppose you can say it, but it won't be true!

I think you are confusing different things, I will try to clarify. Displays (LED and otherwise) are multiplexed to reduce the number of connections required between the display and whatever is driving it. A 4 digit 7 segement display with decimal point has 32 LEDs. That's 32 connections on one side plus 4 common on the other. Using multiplexing reduces that to 12, a big saving on pins on the controller and wires in between them.

From what you have said your display seems to be multiplexed. That means the thing driving the LEDs in the 7 segment dislays is a multiplex driver of some kind. Swapping the 7 segment displays for round LEDs won't change anything about the driver, it will still be a multiplex display driver and you will still have the same thing to detect.

I've never done what you are trying to do, so I can't give you a complete answer, anyway, if I did give you a complete answer you'd have less fun experimenting. Carry on in the direction you are going but concentrate on making your program work out from the information it is getting whether the LEDs in the display are lit or not.

Alternatively, it might be the case (I really don't know) that the thing driving the LEDs is separate from the parking sensor electronics. If that's the case then the 2 are communicating with each other. Find out how they communicate and try to read the data between them.

Finally, what electronic test kit do you have? A good bench multimeter and oscilloscope are invaluable. With an oscilloscope you'd be easily able to see the multiplexing happening and get a good idea of what you are trying to read.

PerryBebbington:
I suppose you can say it, but it won't be true!

I think you are confusing different things, I will try to clarify. Displays (LED and otherwise) are multiplexed to reduce the number of connections required between the display and whatever is driving it. A 4 digit 7 segement display with decimal point has 32 LEDs. That's 32 connections on one side plus 4 common on the other. Using multiplexing reduces that to 12, a big saving on pins on the controller and wires in between them.

From what you have said your display seems to be multiplexed. That means the thing driving the LEDs in the 7 segment dislays is a multiplex driver of some kind. Swapping the 7 segment displays for round LEDs won't change anything about the driver, it will still be a multiplex display driver and you will still have the same thing to detect.

I've never done what you are trying to do, so I can't give you a complete answer, anyway, if I did give you a complete answer you'd have less fun experimenting. Carry on in the direction you are going but concentrate on making your program work out from the information it is getting whether the LEDs in the display are lit or not.

Alternatively, it might be the case (I really don't know) that the thing driving the LEDs is separate from the parking sensor electronics. If that's the case then the 2 are communicating with each other. Find out how they communicate and try to read the data between them.

Finally, what electronic test kit do you have? A good bench multimeter and oscilloscope are invaluable. With an oscilloscope you'd be easily able to see the multiplexing happening and get a good idea of what you are trying to read.

That was a really great answer, thanks for it :slight_smile: I'm doing for fun because i don't have much time to get proper education of it, i'm allready student at whole different subject(computer engineering) and in my country arduino is related to electronical engineering so they don't teach us. Most of the time on my free times, i'm blending in to their classes to learn anything that i can.

When read your first answer i thought that the issue could be related to driver but i just wanted to try my chance anyway :slight_smile:

My multimeter is MASTECH MS8236 but i don't think i can affort for an oscilloscope (they are really expensive here), i'm trying to do this because it's a challenge for me, i love to learn different things.

This is the mainboard of the system;

as you can see in the picture, there is a port which connecting to monitor to system, cable has 3 wires, RED(+) - BLACk(-) - WHITE(DATA), now i'm wondering what happens when i connect white to the arduino's digital port and try to read it ?

Long story short, my main goal is triggering the relays, when left panel lighted up i'll trigger one relay and when the right panel lighted up i'll trigger other relay.

I don't think i can afford for an oscilloscope

What about a second hand one? EBay maybe?

I'm wondering what happens when i connect white to the Arduino's digital port and try to read it?

As long as the voltages on there don't go outside the range of 0v to 3.3v or 5v (depending on which Arduino you have) then you won't harm anything by trying. The problem is you won't know how the data is encoded so decoding it will be difficult.

I'm living in Turkey so E-bay is not serving here, i did a quick search for second hands and tihs was the much chipper one Yokogawa DL750P ScopeCorder - 3.500 TL,it's arround 664 USD and as a student believe me i've never saw all 3.500 TL as together in real life :slight_smile:

I'm using arduino mega 2560, last year one of my friend gifted his old adjustable power supply to me, so i'm using as power source, and never going up from 12v on my works (i'm little bit scared from electricity, i know this kind of projects out of my league but it's itching my brain you know.

On my other tests i was able to read led's status (HIGH/LOW) on many occasions,but this one is a really hard challenge for me, as you mentioned about decoding when i connect white cable to digital port probably i'll see lots of hex codes or binary,but it's worth to try.

I thought reading the led's status would be an easy workarround.

sheshman:
I thought reading the led's status would be an easy workarround.

Actually, it may be easy, but you need to write a program on the Arduino to do it.

The multiplexed display will have a "clock" signal that times the entire operation. You need to find that signal and apply it to an Arduino pin and program so the program does nothing when the pin is low. But when the pin is high, then you can use a second digital pin to monitor a LED and see if it is high or low. IF the LED is active it will show a high at the same time the clock is high.

In other words, you can monitor any of the multiplexer signals if you only look at something during the time it is active and ignore all other times.

Paul

UPDATE - 26.01.2019

First of all i want to thank to @PerryBebbington i've learned one important thing about LED technology from you and also i've learned how a kind person should be, thanks for your patience and let me torture you with my english :slight_smile:

Also thanks to @Paul_KD7HB for his good idea i allready started my research to learn to do with your way.

Back to my project;

As soon as i understood i can't read the LED status (it's doable but remember i'm just junior level :slight_smile: ) i've changed my approach and tried to read voltage changing on LED ports.

When an object started to get closer in 1.5 meter range the first green led is on and when object getting closer other leds starting to fire up, but if object in 1.5 meters range the first green light is allways on, i've checked the voltage between GND and first led;

--No object in range : 0V

--Object in maximum range (1.5 meters): 2.9 V

--Object in minimum range (0cm): 2.9 V

As you see i have a trigger now, i can seperate right and left ports with measuring the voltage :slight_smile:

I didn't know how to measure voltage with arduino so started to research, i've found many examples but only this one fitted my situation : Measuring Voltage with Arduino

Prepared my circuit as described in the page connected GND to arduino's GND and Vcc to Analog port 0,
edited the code as below;

// number of analog samples to take per reading
#define NUM_SAMPLES 10

int sum = 0;                    // sum of samples taken
unsigned char sample_count = 0; // current sample number
float voltage = 0.0;            // calculated voltage
void setup()
{
    Serial.begin(9600);
}

void loop()
{
    // take a number of analog samples and add them up
    while (sample_count < NUM_SAMPLES) 
    {
        sum += analogRead(A0);
        sample_count++;
        delay(10);
    }
    // calculate the voltage
    // use 5.0 for a 5.0V ADC reference voltage
    // 5.015V is the calibrated reference voltage
    voltage = ((float)sum / (float)NUM_SAMPLES * 4.9) / 1023.0;
    // send voltage for display on Serial Monitor
    // voltage multiplied by 11 when using voltage divider that
    // divides by 11. 11.132 is the calibrated voltage divide
    // value
    /*Serial.print((voltageb * 11.132)/10);
    Serial.println (" V");*/
    //Serial.println(analogRead(A7)+1);
    if ((voltage * 11.132)/10<1.0)
    {
    Serial.println ("IDLE");
    }
    else
    {
     Serial.println ("OBJECT ON - [LEFT]");      
    }
    sample_count = 0;
    sum = 0;
}

When no object detected terminal output says "IDLE" and when an object entered the range terminal output says "OBJECT ON - ", now it works like a charm with one sensor :slight_smile:

What i'm struggling is to make it work with two sensors (LEFT-RIGHT),i've tried to edit code for two sensors as below ;

int sum = 0;                    // sum of samples taken
unsigned char sample_count = 0; // current sample number
float voltage = 0.0;            // calculated voltage
int sumb = 0;                    // sum of samples taken
unsigned char sample_countb = 0; // current sample number
float voltageb = 0.0;            // calculated voltage
void setup()
{
    Serial.begin(9600);
}
void loop()
{

    while (sample_count < NUM_SAMPLES) 
    {
        sum += analogRead(A0);
        sample_count++;
        delay(10);
    }
    while (sample_countb < NUM_SAMPLESB) 
    {
        sumb += analogRead(A7);
        sample_counbt++;
        delay(10);
    }
    if ((voltage * 11.132)/10<1.0)
    {
    Serial.println ("IDLE");
    }
    else
    {
     Serial.println ("OBJECT ON - LEFT");      
    }

    if ((voltageb * 11.132)/10<1.0)
    {
    Serial.println ("IDLE");
    }
    else
    {
     Serial.println ("OBJECT ON - [RIGHT]");      
    }
    sample_count = 0;
    sum = 0;
    sample_countb = 0;
    sumb = 0;
}

On this scenario left side's first led's GND to arduino 1stGND and Vcc to A0, right side's first led's GND to arduino 2ndGND and Vcc to A7.

When run the code terminal output :

--No object in range for  both sensors : IDLE

--Object in range for LEFT sensor, Object not in range for RIGHT sensor :
OBJECT ON [LEFT] 
OBJECT ON [RIGHT]
OBJECT ON [LEFT] 
OBJECT ON [RIGHT]

--Object in range for RIGHT sensor, Object not in range for LEFT sensor :
OBJECT ON [RIGHT]
OBJECT ON [LEFT] 
OBJECT ON [RIGHT]
OBJECT ON [LEFT]

As you may understand from terminal output there are no trigger for RIGHT sensor but terminal says RIGHT-LEFT triggered at the same time.

So checked with multimeter if there is voltage on the both sides at the same time ;

--Object on left sensor : Left Side : 2.9V - Right Side : 0V
--Object on right sensor : Left Side : 0V - Right Side : 2.9 V

Left and right sides are seperated and there is no voltage until it's sensor triggered with object, i think i'm doing something wrong on the code.

I've tried with 2 arduino nanos, one connected to left sensor and the other connected to right sensor, it works perfectly, what i want to do is make it work with one arduino.

What am i missing here ?

First of all i want to thank to @PerryBebbington

Thank you :slight_smile:

Thanks for your patience and let me torture you with my English.

Your English is fine!

It would help if you posted a diagram, hand drawn and photographed is fine. I think I understand how you've wired it based on your description, but a diagram would be helpful.

On this scenario left side's first led's GND to arduino 1stGND and Vcc to A0, right side's first led's GND to arduino 2nd GND and Vcc to A7.

You seem to have established that the display is multiplexed, are you sure the individual LEDs are not multiplexed? There is only 1 ground in any circuit, from your description I suspect you think the 2 LEDs have different grounds. If they are not multiplexed then this is true. If they are multiplexed then connecting them both like this is shorting out part of the multiplexing circuit. Please use your multimeter to see if they are connected to each other and to ground, or not. I mentioned a diagram above.... It's going to take a bit of effort but spend some time working out the circuit of the parking sensor, particularly how the LEDs are wired. Draw a diagram of this, it will make it a lot easier for you to see what is happening.

int sum = 0;                    // sum of samples taken
unsigned char sample_count = 0; // current sample number
float voltage = 0.0;            // calculated voltage

For what you are trying to do you don't need to take a measurement and calculate the actual input voltage from the A2D output. All you need to know is what the A2D output is for LED off and what it is for LED on. Whatever these 2 numbers are, calculate the number in between and use that as your threshold for printing ON and OFF.

Also, and this is a minor point that doesn't affect how it works, I suggest you call your variables something like sum_L and sum_R, sample_count_L and sample_count_R etc to make the code more readable.