# Urgent help needed for a school project

I have a 12 pin 4 digit seven segment display and i hope to have four switches attached to the circuit also, this is so that every time switch 1 is pressed, the first digit will increase by 1, every time switch 2 is pressed the second digit will increase by 1 and so on. I am starting from scratch and i am a bit of a newbie to coding so any help would be appreciated.

1. Find the specs on your 7 segment display. Read all material from your class instructor as well (I assume this came from the school - so they probably gave you some information on how to connect it so as not to trash it)

2. Make enough of an attempt so that you can ask a question and show the code you have, and a schematic showing how it's wired.

This is not a scary project.

I wasnt given any material from a teacher and had to order my arduino myself, i have the display wired up with sega=6, segb=7, segc=8, segd=9, sege=10, segf=11, segf=12, segg=13, digit1=2, digit2=4, digit3=3, digit4=5

Elliottchandler: I wasnt given any material from a teacher and had to order my arduino myself, i have the display wired up with sega=6, segb=7, segc=8, segd=9, sege=10, segf=11, segf=12, segg=13, digit1=2, digit2=4, digit3=3, digit4=5

Where are you from? Those teachers though...

AWOL:

Resistors are attached to each of the digit pins

Could i get any help with the code??

I originally made a single digit counter and have tried to adapt it to display a counter on the first digit, but keep getting the
"a function-definition is not allowed here before ‘{’ token+ error message

This is the code:

int a = 6;
int b = 7;
int c = 8;
int d = 9;
int e = 10;
int f = 11;
int g = 12;
int p = 13;
// set the anode interface
int d4 = 2;
int d3 = 4;
int d2 = 3;
int d1 = 5;
byte numbers[10] = {
B11111100, B01100000, B11011010, B11110010, B01100110,
B10110110, B10111110, B11100000, B11111110, B11100110
};
long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 50; // the debounce time; increase if the output flickers

void setup()
{
pinMode(d1, OUTPUT);
pinMode(d2, OUTPUT);
pinMode(d3, OUTPUT);
pinMode(d4, OUTPUT);
pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
pinMode(p, OUTPUT);

int counter = 0;
bool go_by_switch = true;
int last_input_value = LOW;

void loop();
{
if(go_by_switch) {
if(last_input_value == LOW && switch_input_value == HIGH) {
{digitalWrite(d1, HIGH);}
counter = (counter + 1) % 10;
}
if (last_input_value = switch_input_value) {
lastDebounceTime = millis();
}

if ((millis() - lastDebounceTime) > debounceDelay) {
if (last_input_value = switch_input_value) {
last_input_value = switch_input_value;
}
} else {
delay(500);
counter = (counter + 1) % 10;
}
}
}
void writeNumber(int number) {
if(number < 0 || number > 9)
return;

for(int i = 6; i <= 12; i++) {
else digitalWrite(i,LOW);
}
}

First problem

void loop()[u];[/u] his will stop anything at all happening...! Remove the semicolon, and let the loop() tie-in to the {...} block

Driving the LEDs directly from the board is not really a good idea. You really need digit drive transisistors to manage the higher current of multiple segments that may be turned on at a single time (there are ways around this - but beyond your entry-level status).

You're missing a } to close setup()

And move these to before setup() so they can be used in loop()

int counter = 0; bool go_by_switch = true; int last_input_value = LOW;

And by the way.

Go and read the instructions, then go back and modify your post (use the "More --> Modify" option to the bottom right of the post) to mark up the code as such so we can examine it conveniently and accurately.

Because if you do not do this, your code may well be meaningless to read.

Note: Also mark up any data in the same way. This includes error output that you get from the IDE.