Can you help me writing a code for this question guys?? You have an Arduino Uno with 8 LEDs connected to digital pins 2 to 9. Create an array of 8 elements. Fill it with random numbers between 2 and 9 (all inclusive) Write a program which determines the greatest number among them. Save this number in a variable named max. Print this number on serial monitor. Blink the LED connected to this number. Let the delay time be 0.5 second.
Note that the random function may result in duplicate numbers generated. For example, the generated array may be {3,4, 4, 7,6, 2,5,7}
The maximum number will be 7.Since it occurred twice in the array, then you should blink it twice ^_^ It the maximum number occured 3 times in the array, then you should blink it 3 times, and so for any number of occurrences
I have written this so far but I'm sure it's all wrong
int pins[8]={2, 3, 4, 5, 6, 7, 8,9};
void setup()
{
pinMode(pins[8], OUTPUT);
}
void loop()
{
x=random(0, 8);
digitalWrite(pins[x], HIGH);
delay(1000)
digitalWrite(pins[x], LOW);
delay(1000)
}