Mindstorms EV3 Programming Issue - Color Sensor & Variable

348 Views Asked by At

My son and I have a question that we can't figure out the solution to. We're trying to collect a reflected light intensity reading from the color sensor on our EV3 and pass it to a variable. When we do it, we can't get the variable to take the reading. It returns 0 no matter how dark or light the surface.

The first program should collect the variables:

Program: Collect Light and Dark Variables

And the second program should display the value of the "White" variable:

Program: Display Variables

We've also put the two programs together to run them in case the variables aren't global (though they should be with the EV3) and we get the same result.

We're trying to create our own line following program (I know we can find other ways on YouTube, but we really want to figure it out our way if possible). That's where this started, but we could tell the variable wasn't working by the way the program reacted, so we went to this to debug.

I know we're missing something about variables here but can't figure out what it is. If anyone out there could help, we'd really appreciate it. I'm new to StackOverflow, so please forgive me if I posted this incorrectly.

1

There are 1 best solutions below

0
On

Sorry to be so late in responding. I only saw your question this AM. The reason you get a return of 0 is that your code that displays the value on the screen executes only one when it starts and displays the initial value of White. Put that portion of your code inside a loop and it will function properly.