POP-a SHOT project

Hi! Im a grade 10 student, our project is to make an arcade game, what we have in mind is a pop-a-shot game (like the picture below), I know how to code the IR sensor and led but what our teacher will not teach us is the seven segment display. We have our drawn design below.

Materials (pictures below):
-4 digit 7-segment Display
-IR sensor
-arduino atmega 328
-LED

Sequence of events:

  1. 60 seconds=1 minute countdown
    2.When someone shoots is starts the countdown
  2. the IR detects the ball
    -Add 1 point
    -It shows a check
  3. there is no ball
    -It shows a X mark
  4. 60 seconds end
  5. 5 seconds it shows the score made
  6. after 5 seconds
    -The countdown is back to 60 seconds
    -the score is back to zero

Note:
-You can be the judge of what pins to use just tell
-any added info is welcome
-IF A 4 digit 7 segment code is too hard a 2 digit scorer is accepted

I foresaw the code as a bit simple but what made it hard was the segment

Images of the materials:

Images of what it looks like(NOT REALLY):

WE only have 4 days till deadline

1/ What voltage supply do you have? Each LED in your tick and cross marks will drop about 2v.

2/ Which model 7-segment display ? A link or part number.

Driving it isn't very difficult, but it matters whether it is a common-cathode or common-anode display.

You'll also need some resistors and small transistors to drive this and the tick/cross .

Allan

allanhurst:
1/ What voltage supply do you have? Each LED in your tick and cross marks will drop about 2v.

2/ Which model 7-segment display ? A link or part number.

Driving it isn't very difficult, but it matters whether it is a common-cathode or common-anode display.

You'll also need some resistors and small transistors to drive this and the tick/cross .

Allan

Will a power bank be enough? it has 5 volts of input

It is a common cathode

can you tell me what resistors an transistors you want?

P.S. Im still new to this arduino

Try something like the enclosed.

The 4-digit display will probably already have the anodes connected together as shown.

The seperate LED drivers for your tick and cross are also showm

regards

Allan

7seg.pdf (22.5 KB)

allanhurst:
Try something like the enclosed.

The 4-digit display will probably already have the anodes connected together as shown.

The seperate LED drivers for your tick and cross are also showm

regards

Allan

Im very sorry to keep you disturbing but it is the code that i need. It is ok if you do not want to entertain my request

use the search box at the top of the page with '7-seg driver ' or similar - lots of poeple have done this

Allan

You need a few things:
A font array to map the numbers you want to display to the segments being used.
Digits are like this:
a
f b
g
e c
d DP if used
declare the array before setup().

byte fontArray[] = {
0b00111111, // 0 DP-g-f-e-d-c-b-a, 1 = segment on
0b00000110, // 1
0b01011011, // 2
//etc
0b01101111, // 9
};

Then use blink without delay to multiplex the data out to the display. Every 2-3mS, set up the data and enable of the common cathode transistors.

void loop(){
currentMillis = millis(); // all time elements are type unsigned long, declare before setup()
elapsedMillis = currentMillis - previousMillis;
if (elapsedMillis >= onDuration){ //  onDuration set for 2, 3 whatever you use, up to about 8 for 30Hz refresh
previousMillis = previousMillis + onDuration; // set up for next interval
// turn off current digit drive transistor, assume using pins 15-14-13-12, set up in an array:
digitalWrite (digitPin[digitDrive], LOW);
digitDrive = digitDrive +1; // point to next digit
if (digitDrive == 4){ digitDrive = 0;} // reset to initial digit
// assume you're using 4 bits of PORTD  and 4 bits of PORTB:  7-6-5-4, and 11-10-9-8, for DP-g-f-e, d-c-b-a
// and data is stored in an array
// clear lower 4 bits of PORTB
PORTB = PORTB & 0b11110000;
// look up the font (segment mapping), mask off lower 4 bits of data, OR into output register
PORTB = PORTB | (fontArray[dataArray[digitDrive]] & 0b00001111);
// clear upper 4 bits of PORTD,
// look up the font (segment mapping), mask off upper 4 bits of data, OR into output register
PORTD = PORTD & 0b00001111;
PORTD = PORTD | (fontArray[dataArray[digitDrive]] & 0b11110000);
// turn on the transistor for the current data
digitalWrite (digitPin[digitDrive], HIGH);
}
// do whatever you do to update dataArray[0], dataArray[1], dataArray[2], dataArray[3] with data while the 2-8mS is passing by to turn on the next digit
}

Make sure you use current limit with all the output pins.
LEDs: (5V - (Vf of LED) - (Vce of transistor))/10mA
Say Vf is 2.5V and Vce is 0.5V, then (5V - 2.5V - 0.5)/.01 = 200 ohm
Transistor base resistor: (5V - Vbe)/20mA
assume Vbe = 0.7V (1 diode drop), then
(5V - 0.7V)/.02 = 215 ohm, can use 200 also]

Good luck!

Given the OP is a grade 10 student, how many marks would you give him/her as a supervisor if you saw this thread??

Allan