User Manual
35
Using PiSmart Box with Python
After you log in the Rpi, Type in the command to download the python code:
git clone https://github.com/sunfounder/SunFounder_PiSmart.git
cd ~/ SunFounder_PiSmart/
ls
pismart stores Python modules
examples includes some examples for use
cd ~/ SunFounder_PiSmart/pismart
Import package: import pismart
In the pismart package, the following python modules are included:
├── pismart.py
├── adc.py
├── led.py
├── motor.py
├── servo.py
├── pwm.py
├── tts.py
├── stt.py
├── amateur.py
├── basic.py
pismart.py
This file is to control the device switching on and off of the PiSmart, read the temperature
and power, and set the speaker and pickup.
The pismart module includes one class:PiSmart instance creation, with no parameters.
from pismart.pismart import PiSmart
my_pismart = PiSmart() # creat an instance
Method functions:
servo_switch(on_off)
Switch on and off of the servo output.
Parameters: 1(PiSmart.ON), 0(PiSmart.OFF)
my_pismart.servo_switch(PiSmart.ON) # servo port on
SunFounder