Potentiometer

Basic circuit layout

Connect the two outside pins to power (5V, +) and ground (GND, -). It does not matter which. The middle pin connects to one of the “analong inputs” A0 through A5. Memorize this setup.

Basic coding

The analog reading () :: #468cfc reporter block gets a number from 0 to 1023 for your program, based on the voltage of the input you select.

I will use the value :: variables reporter for the variable that holds the reading from the potentiometer. You should name the variable whatever makes sense for you. Sometimes “brightness” is a good name.


when green flag clicked
forever
  set [the value v] to (analog reading (2) :: #468cfc) 
  say (the value) for (0.5) seconds
  set pin (9 v) to value ((the value) / (4)) :: #468cfc