Go Down

### Topic: Searching for a Random Number and Blinking LED (Read 809 times)previous topic - next topic

#### mtnB1ker

##### Apr 23, 2015, 10:41 pm
I want to create a sketch that creates an array of random integers between 1 and 50 and the size of the array should be 20 integers. So 20 random integers between 1 and 50.

Then I want the sketch to search for a particular value in that array. So let's say the value of 25. If the value is found in the array then I need the LED on pin 13 to blink 3 times. And if the value does not occur in the array, turn the pin 13 LED on for two seconds.

Delay for three seconds and then the process should repeat from the beginning.

#### PaulRB

#1
##### Apr 23, 2015, 10:50 pmLast Edit: Apr 23, 2015, 10:52 pm by PaulRB
Wierd! Is this a school/college assignment?

How does the sketch know what value to search for?

#### mtnB1ker

#2
##### Apr 24, 2015, 12:38 am
I am trying to first figure out how to create an array with a length of 20 integers that selects random numbers. I am very new to Arduino, but I have something like this:

randNumber = random(1,50);
int myArray[20] = {randNumber};

will that give me an array of 20 ingegers from 1-50?

#### siutoejai

#3
##### Apr 24, 2015, 06:49 amLast Edit: Apr 24, 2015, 06:52 am by siutoejai
Quote
Returns

a random number between min and max-1 (long)
1,50

only from 1 to 49

try it out

use Serial.println to print your array

you will see the result

#### JimboZA

#4
##### Apr 24, 2015, 07:25 am
You might like to look at the use if the for loop wrt arrays, here.
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)

#### AWOL

#5
##### Apr 24, 2015, 08:38 am
Cross-posts deleted - DO NOT CROSS-POST, CROSS-POSTING WASTES TIME.

#6