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
- A-G legs of 7 segment connect to (-) of Opto , ( +) leg of Opto to +5V
- common Anode leg of 7 segment (Digit) connect to (+) of Opto ,( +) leg of Opto to Gnd
- Output of Opto connect to 6-12 (A-G) legs of Arduino and Pull-up with +5V
- 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() {
Serial.begin(9600);
for (i=0; i<7; i++)
{
pinMode(buttonPins[i], INPUT);
}
pinMode(2,INPUT);
pinMode(3,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]);
EEPROM.write(0,(buttonStates[6]));
EEPROM.write(1,(buttonStates[5]));
EEPROM.write(2,(buttonStates[4]));
EEPROM.write(3,(buttonStates[3]));
EEPROM.write(4,(buttonStates[2]));
EEPROM.write(5,(buttonStates[1]));
EEPROM.write(6,(buttonStates[0]));
if (val1 == HIGH )
{
A= EEPROM.read(6);
B= EEPROM.read(5);
C= EEPROM.read(4);
D= EEPROM.read(3);
E= EEPROM.read(2);
F= EEPROM.read(1);
G= EEPROM.read(0);
total=String(A)+String(B)+String(C)+String(D)+String(E)+String(F)+String(G);
Serial.println(total);
lcd.print(total);
lcd.setCursor(0, 1);
}
}
Picture
- I tried to sent "9" to 7 segment but my program show as below.