Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Digital Pin Configuration

Alan Yorinks edited this page Mar 11, 2019 · 13 revisions

Snap! tab location: Sensing tab.

This command block configures a digital pin for digital input or digital output mode operations.

Enter the pin number and click on the drop down list at the right side of the block to select the desired mode.

Mode Mode Type
Input Input
Output Output
PWM Output
Servo Output
Tone Output
Sonar Input

To use either Tone or Sonar, FirmataPlus is required to be uploaded to the Arduino. Instructions for installing FirmataPlus can be found here.

On the right side of the block is an Enable/Disable drop down list. These values are effective only for Input type modes. If enabled (the default), the data changes for the pin will be reported. If disabled, no data changes for the pin will be reported to the Digital Read block.

If the pin is configured for sonar input, its data values are retrieved using the Digital Read block.

IMPORTANT NOTE: The Arduino pins are described at the hardware level as being members of an 8 pin port group. Disabling or Enabling an input pin will affect all eight members of the pin's group.

SPECIAL NOTE: Configuring for Tone and Servo operation can interfere with PWM operation. Tone will interfere with PWM output on pins 3 and 11 (on boards other than the Mega). On boards other than the Mega, servo configuration will interfere with PWM functionality on pins 9 and 10. On the Mega, it may interfere with PWM on pins 10 and 11.

Debugging Values

Debugger Value Explanation
0 No Error
1-1 The pin number specified is not an integer value
1-2 The pin number specified is out of the range of valid pin numbers for the Arduino board in use
1-3 The pin specified does not support Input mode
1-4 The pin specified does not support Output mode
1-5 The pin specified does not support PWM mode
1-6 The pin specified does not support Servo mode
1-7 The pin specified does not support Tone mode
1-8 The pin specified does not support Sonar mode
1-9 Unknown mode specified
1-10 The selected mode does not support 'Disabled'