Pages: [1]   Go Down
Author Topic: How to catch 7 segment signal?  (Read 884 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello !.

              I need to read 7 segment signal of  9 digits then sent print to serial port
*7 segment , common Anode.

my circuit ****** I just test 1 digit only
1. A-G legs of  7 segment connect to  (-)  of Opto , ( +) leg of Opto to +5V
2. common Anode  leg of  7 segment (Digit)  connect to (+) of Opto ,( +) leg of Opto to Gnd
3. Output of Opto connect to 6-12  (A-G) legs of  Arduino  and Pull-up with +5V
4. Output of Opto (Common Cathod ) connect to D2 of Arduino.
This is my code but it don't work.
#include <LiquidCrystal.h>
#include <EEPROM.h>
//#include <EEPROMAnything.h>

LiquidCrystal lcd(22, 24, 26, 28, 30, 32);
int buttonPins[] = {6,7,8,9,10,11,12} ;
int buttonStates[7];      
int i;
int A=0;
int B=0;
int C=0;
int D=0;
int E=0;
int F=0;
int G=0;
String total="";

void setup() {
for (i=0; i<7; i++)
   pinMode(buttonPins[i], INPUT);    
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  lcd.begin(16, 2);


void loop() {
  val1 = digitalRead(2);  // read input value
if (val1 == LOW )

  buttonStates[0] = digitalRead(buttonPins[0]);
  buttonStates[1] = digitalRead(buttonPins[1]);
  buttonStates[2] = digitalRead(buttonPins[2]);
  buttonStates[3] = digitalRead(buttonPins[3]);
  buttonStates[4] = digitalRead(buttonPins[4]);
  buttonStates[5] = digitalRead(buttonPins[5]);
  buttonStates[6] = digitalRead(buttonPins[6]);                          
if (val1 == HIGH )
     lcd.setCursor(0, 1);


* I tried to sent "9"  to 7 segment but my program show as below.

« Last Edit: June 20, 2013, 05:18:16 am by matsuo » Logged

Massachusetts, USA
Offline Offline
Tesla Member
Karma: 212
Posts: 8975
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the refresh rate on the display?

Are the optoisolators fast enough to catch the pulses?

I suspect that the digitalReads() might be too slow to catch all of the bits before they change.  You might want to use Direct Register Access so you can grab all 8 pins at once.

You probably shouldn't use EEPROM cells for variables since they have a limited lifetime (100,000 writes?).

Your wiring will allow you to capture one digit at a time but gives you no indication of which digit you are getting.  You should probably have a separate  input pin for one of the digits so you can synchronize your (to be implemented) digit counter.

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks you johnwasser for advise to me. Now I can chatch signal 7 segment to display on my app (Visual basic)
but sometime my program wrong display as my photo, I think have noise in circuit .

This is my circuit ,Could you modify something for reduce noise ?

This is my app
« Last Edit: July 15, 2013, 05:24:55 am by matsuo » Logged

Offline Offline
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Matsuo!,

This issue is really interesting, I have the same problem when reading data from a 7 segments.
How did you fix it?
Could you share your code?

Thank you!!


Pages: [1]   Go Up
Jump to: