Lesson goal: Turn an LED on or off using the mouse and the distance formula

Home

This lesson will allow you to experiment with the mouse, some LEDs and the distance formula.

Let's draw a circle at some random position on the screen. If we move the mouse cursor within the circle, let's turn an LED on. If we move outside of the circle, let's turn it off.

You'll have to think about what it means for an $(x,y)$ point (the position of the mouse cursor) to be inside of a circle.
mousex() and mousey()
Move the mouse over a dotted box for more information.

Now you try. Can you figure out how to turn the LED on and off by moving the mouse inside and outside of the circle?

Type your code here:


See your results here: