peripheral vision enhancer

Hay, my son and I are doing a class prodject for a peripheral eye enhancer. What it will consist of is a board with 10 - 16 LED lights in a circle, an LED is lit and you push a button it goes out and another one lights up at random and you push that button and it goes out and another randomly lights up, and so on... we are very new to this have done lots of the prodjects but can't figure this out. cked online found some programs that were close but can't seem to make any work. Can anyone help with our prodject?
Thanks.

but can't seem to make any work.

Show us your work.

here is what I have so far. it is something I coppied on line, and tryed to modify but doesn’t work. maybeyou can see it.
thanks

const int buttonPin = 9; // the number of the pushbutton pin

// variables will change:
int buttonState = 0; // Variable for reading the pushbutton status
int ledPin = 5;
int loopwait = 0;
//int ledPin = random(5); // Sets a Random LED as active

void setup() {
pinMode(ledPin, OUTPUT); // Initialize the LED pin as an output:
pinMode(buttonPin, INPUT); // Initialize the pushbutton pin as an input:
}

void loop(){
buttonState = digitalRead(buttonPin); // read the state of the pushbutton value:
if (loopwait == 0) {
if (buttonState == HIGH) { // check if the pushbutton is pressed.
// turn LED on:
if (random(10) < 60){
ledPin = 2;
} else if (random(10) < 70){
ledPin = 3;
} else if (random(10) < 80){
ledPin = 4;
} else if (random(10) < 90){
ledPin = 5;
} else if (random(10) < 94){
ledPin = 6;
} else if (random(10) < 98){
ledPin = 7;
} else if (random(10) < 101){
ledPin = 8;}
digitalWrite(ledPin, HIGH);
loopwait = 1;}
else {
if (buttonState == LOW){
loopwait = 0;
digitalWrite(ledPin, LOW); // turn LED off:
}
}
}
else {
if (buttonState == LOW){
loopwait = 0;
digitalWrite(ledPin, LOW); // turn LED off:
}
}
}

if (random(10) < 60)

random(10) will always be less than 60. Actually, the 10 means it will always be less than 10.

hay thanks, it works only problem is the LEDs are dim and it is only random for about the first 4 LEDs the others rarely light up.

here are the changes I made;

const int buttonPin = 9; // the number of the pushbutton pin

// variables will change:
int buttonState = 0; // Variable for reading the pushbutton status
int ledPin = 10;
int loopwait = 0;
//int ledPin = random(10); // Sets a Random LED as active

void setup() {
pinMode(Pin, OUTPUT); // Initialize the LED pin as an output:
pinMode(buttonPin, INPUT); // Initialize the pushbutton pin as an input:
}

void loop() {
buttonState = digitalRead(buttonPin); // read the state of the pushbutton value:
if (loopwait == 0) {
if (buttonState == HIGH) { // check if the pushbutton is pressed.
// turn LED on:
if (random(100) < 20) {
ledPin = 2;
} else if (random(100) < 40) {
ledPin = 3;
} else if (random(100) < 60) {
ledPin = 4;
} else if (random(100) < 70) {
ledPin = 5;
} else if (random(100) < 94) {
ledPin = 6;
} else if (random(100) < 98) {
ledPin = 7;
} else if (random(100) < 101) {
lePin = 8;
}
digitalWrite(ledPin, HIGH);
loopwait = 1;
}
else {
if (buttonState == LOW) {
loopwait = 0;
digitalWrite(ledPin, LOW); // turn LED off:
}
}
}
else {
if (buttonState == LOW) {
loopwait = 0;
digitalWrite(ledPin, LOW); // turn LED off:
}
}

If you want to randomly light an LED on a random pin, why aren't you just setting ledPin to a random pin number in the range of pins you are using?

ledPin = random(2, 9);
if (random(100) < 20) {
        ledPin = 2;
      } else if (random(100) < 40) {
        ledPin = 3;
      } else if (random(100) < 60) {
        ledPin = 4;
      } else if (random(100) < 70) {
        ledPin = 5;
      } else if (random(100) < 94) {
        ledPin = 6;
      } else if (random(100) < 98) {
        ledPin = 7;
      } else if (random(100) < 101) {
        lePin = 8;
      }

I wouldn’t expect the last few to light up very often. Look at the ranges of numbers they accept vs the first few. What’s the probability of a true random number less than 100 being 99, or 100? That’s a 2% chance for pin 8.

all right, here is what i have. It works ok but like I said we are not experianced with this stuff and have to research everthing. it is fun and learning alot. didn’t exactly know how to apply what cr0sh said. but my LEDs are still dim. we appreciate everything from all, so more detail would be welcome. someday hope to be helping others too.

const int buttonPin = 9; // the number of the pushbutton pin

// variables will change:
int buttonState = 0; // Variable for reading the pushbutton status
int ledPin (10);
int loopwait = 0;
//int ledPin = random(10); // Sets a Random LED as active

void setup() {
pinMode(ledPin, OUTPUT); // Initialize the LED pin as an output:
pinMode(buttonPin, INPUT); // Initialize the pushbutton pin as an input:
}

void loop() {
buttonState = digitalRead(buttonPin); // read the state of the pushbutton value:
if (loopwait == 0) {
if (buttonState == HIGH) { // check if the pushbutton is pressed.
// turn LED on:
if (random(100) < 20) {
ledPin = 2;
} else if (random(100) < 21) {
ledPin = 3;
} else if (random(100) < 23) {
ledPin = 4;
} else if (random(100) < 24) {
ledPin = 5;
} else if (random(100) < 25) {
ledPin = 6;
} else if (random(100) < 26) {
ledPin = 7;
} else if (random(100) < 80) {
ledPin = 8;
} else if (random(100) < 99) {
ledPin = 12;
}
digitalWrite(ledPin, HIGH);
loopwait = 1;
}
else {
if (buttonState == LOW) {
loopwait = 0;
digitalWrite(ledPin, LOW); // turn LED off:
}
}
}
else {
if (buttonState == LOW) {
loopwait = 0;
digitalWrite(ledPin, LOW); // turn LED off:
}
}
}

Why do you keep running random(100) over and over ? Each time you call it (type it in the arduino IDE like that) it will run again, and give a new value.

Run it once per iteration, save the single value and compare that.

Have you read http://www.arduino.cc/en/Reference/Random ?

If you do, you’ll see how: else if (random(100) < 101) is (at the least) redundant.

like this? sorry I guess I’m way over my head.

const int buttonPin = 9; // the number of the pushbutton pin

// variables will change:
int buttonState = 0; // Variable for reading the pushbutton status
int ledPin (10);

int loopwait = 0;
//int ledPin = random(10); // Sets a Random LED as active

void setup() {
pinMode(ledPin, OUTPUT);
pinMode(A4, OUTPUT);

pinMode(A5, OUTPUT); // Initialize the LED pin as an output:
pinMode(buttonPin, INPUT); // Initialize the pushbutton pin as an input:
}

void loop() {
buttonState = digitalRead(buttonPin); // read the state of the pushbutton value:
if (loopwait == 0) {
if (buttonState == HIGH) {
// check if the pushbutton is pressed. // turn LED on:
if (random(100) < 101)
ledPin = 2,3,4,5,6,7,8,
digitalWrite, (ledPin, HIGH);
loopwait = 1;
}
else {
if (buttonState == LOW) {
loopwait = 0;
digitalWrite(ledPin, LOW); // turn LED off:
}
}
}

else {
if (buttonState == LOW) {
loopwait = 0;
digitalWrite(ledPin, LOW); // turn LED off:
}
}
}

It would appear yes, you’re over your head, on it’s own each learning step isn’t that hard, but there are quite a few step to overcome. I’d suggest perhaps starting with something easier first…

But anyways, I’ll try to explain it

The function ‘random(100)’ ‘returns’ a random number between 0 and 100.

The conditional statement ‘if (random(100) < 101)’ asks:

‘is the number from random(100) less than 101?’ if so, run the following code between the curly braces.

Can you see how random(100) is always less than 101 ?

Next, what was your goal here:

ledPin = 2,3,4,5,6,7,8, digitalWrite, (ledPin, HIGH); ?

I’m not even sure why that compiles.

There are other parts that might, due to the oddities of the IDE language ‘work’ (do something defined, but unlikely to be what you wanted though). Anyways, if clear communication of your intent is a concern - and it should be, especially if you’re posting it publicly and asking for help with it - ask yourself, do I know (or at least have an idea of) what I just typed should actually do?