Using String variable to represent Array

OK, there's a few problems with your original code.

Move Serial.begin(9600) into you setup() function where it belongs.

Even if your idea was gonna work, you mistyped an array name in one of two places, viz:

LeftOut2In1

and

  randomTime = random(501);

isn't like the other, so sometimes things really would zip… clealry you meant random(20, 501).

Other than that, using pointers was easy enough. Normally I'd let you have all the fun, so promise me you'll take a close look at this

while you hit the books on pointers. :expressionless:

Oh, also you wired your LEDs backwards. :wink:

Note: Wokwi lets you use LEDs without resistors, don't do that at home.

There's a reason that the bible The C Programming Language has

Chapter 5: Pointers and Arrays

In C and C++ pointers and arrays have an intimate relationship, it makes sense to advance your knowledge of them together, you may see.

HTH

a7

1 Like