|
The source code of all examples can be downloaded from a link in the right side bar. Overview
|
Function | Pins N | Method call | Capabilities |
Digital in | 0, 1, 2, 8, 12, 16 | pinN.read_digital() | Pulldown 10 kOhm |
Digital in | 0, 1, 2, 8, 12, 16 | pinN.isTouched | Pullup 10 kOhm |
Digital out Hi | 0, 1, 2, 8, 12, 16 | pinN.write_digital(1) | Max drive current 5 mA |
Digital out Lo | 0, 1, 2, 8, 12, 16 | pinN.write_digital(0) | Max sink current 5 mA |
Pins for analog-in:
Function | Pins N | Method call | Capabilities |
Analog in | 0, 1, 2 | pinN.read_analog() | Input impedance 10 MOhm |
Maximum voltage range when pin is used as input: -0.3V .. 3.9V (avoid overshoot with inductive loads as speakers, motors, piezo sounder)
Pins for PWM
Function | Pins N | Method call | |
Puls-width modulation (PWM) | 0, 1, 2 | pinN.write_analog(duty) pinN.set_analog_period(period) |
duty = 0.0 ... 1023.0 (100%) period in Milliseconds |
Pins not available for general GPIO use:
Display mode
P3, P4, P6, P7, P9, P10
After calling display.off(), these pins can be used for general input/output, but for some unknown reason the interpreter prompt is unavailable after an exception is raised (firmware flash necessary). Workaround: Execute error-prone code in a try-except block.
try:
error-prone code, e.g. pin3.read_digital()
except Exception as e:
print("Exception raised: " + str(e))
Button mode
P5, P11, pullup 10 k, buttons connects to GND
may be uses externally
SPI mode
P13, P14, P15
may be used externally
I2C mode
P19, P20, pullup 10 k
may be used externally, but accelerometer stops to work
Due to the small driving capacity in digital or analog output mode, it is highly recommended to use a simple transistor amplifier that is easy built on an edge connector (e.g. from Kitronik, Code: 5601B). A clamp diode also eliminates harm from inductive feedback voltage of solenoid-like devices. Plug pins may be soldered to make connection easy and adaptable using jumper cables.
Schematics
|
Wiring
|
Remarks:
The cathode of the diode has a black label and is connected to the + strip. A resistor has no polarity. Check the data sheet of your transistor to find the wires C, B and E.
Example: Connection a small speaker
PHOTO TODO
Example 1: Blinking LED, Beeping Buzzer |
Aim: Wiring: Program:
Remarks:
|
Example 2: Detect broken wire |
Aim: Wiring: Program:
Remarks:
|
Example 3: Generate Morse code |
Aim: Wiring: Program:
Remarks: A Python dictionary is convenient to map letters to Morse code.
|