My Project, feedback needed

Gday all,
I am studying/part time teaching C++ in an australian technical college.
I have been asked to write a problem and solution for a class of young students.
This is what i have so far:

The header file 'DIGI_O.OBJ' contains functions 'void setup(void), 'int Ain(void)' and 'void Bout(int)'. The setup() function must be used once before accessing the 8255 card to set it up. the Ain() function returns the data from port A of the 8255 card as an integer between 0 and 255. The Bout() function outputs an integer between 0 and 255 to port B.
Write a C program to count the number of pulses from a switch connected to bit 0 of port A and display the count on a seven segment display connected to port B. The 7 segment display accepts a BCD number between 0 and 9. The count must be displayed clearly in the middle of the screen. When the count reaches 10 your program should beep and reset the count to 0.


Could someone please write me their version to the solution, because i am unsure if mine is correct or if my problem is too difficult for the students.

thanks,
Daniel
We never write out full solutions, regardless of the context. It's an unwritten policy around here that we try to stick to. Sorry. If you want to check if your solution works, put it into the compiler, run the debugger, and go through it step by step. Make sure your display works.

G'day, mate!

-Ausietross
Last edited on
+1 Albatross

You could write a test implementation for void setup(), int Ain() and void Bout(int) to simulate the real device:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

int data[] =
{
    0x01, 0x02, 0x03, 0x04, ... etc ... , 0 // zero terminated
};

int index;

void setup()
{
    index = 0;
}

int Ain()
{
    if(data[index]]
    {
        return data[index++];
    }
    return 0;
}

... etc


After all, if you can't check that your *own* solution works, and you are the teacher, then how are you going to check if your students' solutions are working?


Last edited on
Topic archived. No new replies allowed.