Potentiometer

Turn a dial or pinch a rectangle to send a value to the computer.

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

Last modified August 18, 2023: 2022-2023 End State (7352e87)