Hi all,

Currently trying to write a piece of code for a project at university, with very little C Compiler experience I am struggling...

Basically- we have 8 LED's, and 8 switches. We want 4 of the 8 LED's to light up at random when the program is run, that then have to be switched off in order using the corresponding switches. They must only be able to be done in order!

E.g If LED's 0,2,4,7 light up, switch 0 must be turned off in order for LED 0 to go off, and LED 2 can only be switched off if LED 0 is already turned off... etc etc.

Once all 4 are turned off in order, we need a small time delay (e.g 3 second) before the LEDs are randomized again and 4 more come on. These will need to be turned off as before... but in REVERSE order (e.g 6,5,3,1).

Any help will be much appreciated!

Cheers

mmpjb

What microcontroller?

What microcontroller?

If you're referring to what I think you are... its a PIC18F45h

If thats completely wrong... I apologise.

1. So does it have enough IO to have 8 leds and 8 switches? If not: How do yo think you should solve that?
2. you need to program a function that picks a random number between 0-8
3. You need to make a timer
4. For each button pressed, you need to check if all leds on the left of this one are dimmed.

1. So does it have enough IO to have 8 leds and 8 switches? If not: How do yo think you should solve that?
2. you need to program a function that picks a random number between 0-8
3. You need to make a timer
4. For each button pressed, you need to check if all leds on the left of this one are dimmed.

1.Yes, it does have enough IO to have 8leds and 8 switches
2. indeed i do- thanks for the link- i'll take a look
3. i think i know how to make a timer so thats ok
4. not entirely sure what you mean by this point!

many thanks for your continued help :)

mmpjb

not urgent

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.