I have an old wall mount thermometer that uses 3 digital segment display to display the temperature. What i want to do is to read the temperature with Arduino UNO or Mega serial.print.
When the display lights up a value, i want the Arduino to be able to read its value and display in serial.print.
My question is:
Is it possible to get the data from the display?
If so, can i connect jumpers to each pin of the display to read its output?
What code should i use?
Any direction should help. I had been trying to solve this problems for weeks.
So I have an old dual 7 segment display that displays outside temperature, what i want to do is read t
Theoretically yes, but practically it is difficult, quite difficult.
That display is multiplexed that is one digit is being displayed at any one time, and that digit is continuously changing. Each digit has an enable pin to indicate it is the one that is on. So you have to look at that and that will tell you which digit the current state of the seven segments refer to.
No that sounds easy, if it does not then stop here.
There are two big problems.
the digits being displayed can change between reading the digit enable pin and reading the segments. So this would give you a false value. So you have to read the enable pin after you read the segments to see it has not change in order to see if you have a valid reading.
this display is in a circuit and so the signals you read off it will not be logic levels, so you will need a circuit on each pin that turns what ever signal is there into logic levels.
I use jumper wire to connect digital pin 1 to 12 to each display pin. This is the arduino code.
int pin1 = 1;
int pin2 = 2;
int pin2 = 3;
int pin2 = 4;
int pin2 = 5;
int pin2 = 6;
int pin2 = 7;
int pin2 = 8;
int pin2 = 9;
int pin2 = 10;
int pin2 = 11;
int pin2 = 12;
void setup() {
// initialize the LED pin as an output:
pinMode(pin1, OUTPUT);
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
pinMode(pin5, OUTPUT);
pinMode(pin6, OUTPUT);
pinMode(pin7, OUTPUT);
pinMode(pin8, OUTPUT);
pinMode(pin9, OUTPUT);
pinMode(pin10, OUTPUT);
pinMode(pin11, OUTPUT);
pinMode(pin12, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
Why are you setting all the pins to outputs? If you are reading them they must be inputs.
Do not use pin 1 as this is used for uploading code to the board, along with pin 0.
Please read the how to use this forum sticky post, as the way you are posting code is breaking the forum rules.
your comments do not match what the code is doing.
Grumpy_Mike:
Theoretically yes, but practically it is difficult, quite difficult.
And Mike is not kidding!
Grumpy_Mike:
2) this display is in a circuit and so the signals you read off it will not be logic levels, so you will need a circuit on each pin that turns what ever signal is there into logic levels.
When you start talking about simply connecting Arduino pins to the display, you have of course, completely overlooked this critical point.
You need to use an oscilloscope to inspect exactly what voltages occur on the display pins, then design an interface circuit to suit.
The output is something like this:
0 1 0 1 0 1 0 0 0 0 0 1
No, there is no output from the sketch you posted because it will not compile:
int pin2 = 2;
int pin2 = 3;
int pin2 = 4;
int pin2 = 5;
int pin2 = 6;
int pin2 = 7;
int pin2 = 8;
int pin2 = 9;
int pin2 = 10;
int pin2 = 11;
int pin2 = 12;
I tried with a voltmeter and measure the pins. There is a voltage difference if one of the LEDs lights up. But when i connect one of the pins to the Arduino analog, it cant work.
For eg,
I tried to read 1 digit, LED diode E
Voltage meter
Pin 12 - GND
Pin 1 - VCC
Voltage difference appears in voltmeter
Arduino
Pin 12 - GND
Pin 1 - A0
The values ranges from between 0 to 5 V
Cant seems to catch the voltage
Below is the code from Arduino.
const float referenceVolts = 5.0; // the default reference on a 5-volt board
const int batteryPin = 0; // battery is connected to analog pin 0
void setup()
{
Serial.begin(9600);
}
void loop()
{
int val = analogRead(batteryPin); // read the value from the sensor
float volts = (val / 1023.0) * referenceVolts; // calculate the ratio
Serial.println(volts); // print the value in volts
delay(200);
}
I have an old wall mount thermometer which displays temperature of a person. It uses a 3 digit temperature display to display the values.
I am trying to read of the values using Arduino and display on Serial.pint. After experimenting it for a while, I realised that voltmeter can be used to measure the voltage difference of a particular LED in the digit.
For eg, 1st digit LED E (Using voltmeter)
Connection to voltmeter
Pin 12 to GND
Pin 1 to VCC
Voltmeter readings
Before lights up - 4.91 V
After Light up - 3.01 V
Using Arduino
I tried using Arduino to read the voltage difference using the following connection and code but unable to read the voltage consistently.
Connection to Arduino
Pin 12 to 3.3v
Pin 1 to A0 //analog pin 0
The readings were when LED is off or on
0.00 V
0.00 V
0.00 V
1.00 V
2.00 V
5.00 V
2.00 V
1.00 V
0.00 V
Arduino Code
const float referenceVolts = 5.0; // the default reference on a 5-volt board
const int batteryPin = 0; // battery is connected to analog pin 0
void setup()
{
Serial.begin(9600);
}
void loop()
{
int val = analogRead(batteryPin); // read the value from the sensor
float volts = (val / 1023.0) * referenceVolts; // calculate the ratio
Serial.println(volts); // print the value in volts
delay(200);
}
Is that PDF something to do with it? It seems to be a diagram showing how to make the display show numbers controlled by the Arduino. I thought you wanted to read what the display is showing.
I tried to read 1 digit, LED diode E
Voltage meter
Pin 12 - GND
Pin 1 - VCC
If those are how you set up the display then you have two things wrong:-
You have the polarity wrong to light up the segment.
You have no resistors in the circuit to limit the current in the segment so when you do get the polarity right you will probably blow the segment.
This is the problem - the voltages you are monitoring are not standard logic levels so you might want to use analog measurements, but analog reads are slow and the volltages are changing as the multiplexing occurs in a way that is difficult to synchronise.
The only pins you can use attachInterrup with are pins 2 and 3 on a Uno
However, the ISR is not doing much but setting a flag high, so it is a little useless using interrupts for that. Especially as you have a socking great delay(200) at the start of the loop. That means by the time you get to read the values from the pins the multiplexer is probably displaying another number. And anyway you are not even using the fact that the flag is set to limit what pin you read, and you are never resting the flag once you used it.
A serial print takes a long time and you make it even longer by using such a slow baud rate.
Are you actually seeing digital signals from both the anode and segment cathodes?
When writing code you should always build up the functionality slowly. Start off with just trying to detect one digit select line. Then add the code to detect a falling edge on that line. Use the state change example in the IDE to see how to do this. Then see if you can capture one segment consistently.
Then build it up to what you want.
As I said in my first post this is not easy. I also said:-
So you have to read the enable pin after you read the segments to see it has not change in order to see if you have a valid reading.
I think u hit the jackpot. I tried for hours and its almost there. But i've hit the wall.
If my display shows 35.7, my serial.println shows
3
3
5
7
7
3
3
Also, i have 3 flags for each segment. Flag1 detects segment1/digit1, flag2 detects segment/digit2 and so on. I realised that flag2 display 2 numbers as shown above, 5 and 7 if its 35.7 whereas flag 1 shows 3. Flag 3 is not showing anything.
I want the value displayed on serial.print to be 35.7.
Will you be kind enough to point me the correct direction or how to start reading 1 digit at a time? Any code samples? Should i still use the attachInterrupt to get each digital and its data even if i set the sock delay to delayMicroseconds(400)? How about setting baud to faster rate? Will it be fast enough to capture each segment data?
When writing code you should always build up the functionality slowly. Start off with just trying to detect one digit select line. Then add the code to detect a falling edge on that line. Use the state change example in the IDE to see how to do this. Then see if you can capture one segment consistently.
Then build it up to what you want.
Mike already told you why your code is not working. If there was something you did not understand, you shold ask about it, not ignore it, which you seem to be doing.
and its data even if i set the sock delay to delayMicroseconds(400)?
I think you are not understanding the word socking. It is an adverb describing the size of the delay you have as being very large.
Why do you have this delay anyway? It is not needed at all and is only going to make your code not work.
Your code is a bit of a nonsense at the moment. There is no way anyone is going to follow that with all he commented out code. And what did I tell you about the interrupts? You seem to be ignoring everything I told you.
Forget about trying to decode the digit at the moment, just try to gather all the segment values when you see a rising edge on one enable pin. Just one for the moment you are making a big mess.
#include <Keyboard.h>
And why are you including this but never using it?