need help with random functions....

New to the forum!
Ive done a few projects, mostly alarm systems using arduino mega 2560s. Im now trying to figure out a simple program, which im sure I am making more complicated than need be.

The project has a simple CB with 4 leds, each with a corresponding momentary push button. I need the arduino to randomly turn one of the four LEDs on, and put its corresponding switch to a LOW state (all other switches will be HIGH until its their turn in the sequence). once the switch is pushed, another LED will turn on, continuing the sequence infinitely. when a switch is pushed, it shorts a capacitor (on the CB), preventing its full charge. if the cap is alowed to charge, it trips a relay circuit to initiate a buzzer.

similar to many "simon" projects, but I only want one led at a time, and no increase in difficulty.

thanks in advance for any help!

Welcome to the forum.
Have you written any code yet?
It would be helpful if you could post it.

i am very new to all this myself so i cannot help you with your project. however, i came here just to make a small suggestion: edit the title of your post so that it reflects the thing you want to ask something about. something more descriptive than 'Please Help'. you have a way bigger shot at getting replies that way, because people can see at a glance whether they'll have an idea on how to help you, or not.

welcome to the community.

The project has a simple CB...

A circuit board? :smiley: A CB radio? :smiley: Usually, we write "PCB" for printed circuit board.

...with 4 leds, each with a corresponding momentary push button. I need the arduino to randomly turn one of the four LEDs on...

No problem.

... and put its corresponding switch to a LOW state (all other switches will be HIGH until its their turn in the sequence).

That's a problem. A switch is activated by the user. The Arduino cannot change the state of a switch. But of course, it can remember the last button pushed and/or take various actions depending on what switch is pushed next. Or, you can do something else (activate a buzzer) if no switch is pressed before the timeout.

And, do you want the buzzer to sound if the user pushes the wrong button? Of course, that's easy too (with an "or" statement).

...when a switch is pushed, it shorts a capacitor (on the CB), preventing its full charge. If the cap is alowed to charge, it trips a relay circuit to initiate a buzzer.

it's possible to use a resistor & capacitor as a timing circuit... I built an "analog" alarm system that way about a a milllion yoars ago... but the Arduino has a built-in clock-timer, as you probably know from the 'blink" and 'blink without delay" example programs. In your application, you need to do something similar to blink without delay, so that your program can run and watch for a button-press while the clock is '"counting-down" in the background.

first off, thank you for the responses already!

I started laying out the initial perimeters of the program.
now:
//i need to have one of the "outPins" go LOW. Pressing the button shorts out a capacitor (on an RC circuit) on a PCB , not allowing it to charge and trigger a Mosfet, which in turn will trigger a relay. When said pin goes low, I figured I would run an additional wire from the switch (now in a low state) to an "inPin" (acting as a normally open switch) , so the arduino would know it was pressed, in turn randomly turning on another outPin and allowing the pin to return to a HIGH state. i will draw up a schematic asap.

Im sorry if I am unclear on any of this, I appreciate everyone bearing with me. Thanks again!

int out1Pin=2;
int out2Pin=3;
int out3Pin=4;
int out4Pin=5;
int in1Pin=6;
int in2Pin=7;
int in3Pin=8;
int in4Pin=9;
int ledPin=10;
int beeperPin=11;
void setup()
{
pinMode (out1Pin, OUTPUT);
pinMode (out2Pin, OUTPUT);
pinMode (out3Pin, OUTPUT);
pinMode (out4Pin, OUTPUT);
pinMode (beeperPin, OUTPUT);
pinMode (in1Pin, INPUT);
pinMode (in2Pin, INPUT);
pinMode (in3Pin, INPUT);
pinMode (in4Pin, INPUT);
pinMode (ledPin, OUTPUT);
digitalWrite (out1Pin, HIGH);
digitalWrite (out2Pin, HIGH);
digitalWrite (out3Pin, HIGH);
digitalWrite (out4Pin, HIGH);
digitalWrite (in1Pin, HIGH);
digitalWrite (in2Pin, HIGH);
digitalWrite (in3Pin, HIGH);
digitalWrite (in4Pin, HIGH);
digitalWrite (ledPin,LOW);
digitalWrite (beeperPin, LOW);
}
void loop()
{
}

//I just realized I only need one "inPin" as all it will do is "reset" the function once a button is pushed ( sending the LOW signal from the button to the board)...

here's a quick illustration....