Programming with MicroPython: Sugar and Powerbrick Modules
Import Sugar Library
Import the Sugar library to make use of its functions.
14: Sugar and Powerbrick modules
PIR Sensor
Returns a boolean value from the PIR sensor.
pin: The pin connected to the sensor.
IR Line Tracker
Returns a boolean value from the Line Tracker.
pin: The pin connected to the sensor.
(Hall Effect)Magnet Sensor
Returns a boolean value from the Magnet sensor.
pin: The pin connected to the sensor.
Button Sensor
Returns a boolean value from the Button sensor.
pin: The pin connected to the sensor.
LED Module
Sets the state of the LED module to be on or off.
Sets the LED brightness.
pin: The pin connected to the sensor.
state: on/off.
brightness: 0~100.
Flame Sensor
Returns an analog value from the Flame sensor.
pin: The pin connected to the sensor.
Potentiometer Sensor
Potentiometer Sensor Information
Returns an analog value from the Potentiometer sensor.
pin: The pin connected to the sensor.
Light Sensor
Returns an analog value from the Light sensor.
pin: The pin connected to the sensor.
Soil Moisture Sensor
Soil Moisture Sensor Information
Returns an analog value from the Soil Moisture sensor.
pin: The pin connected to the sensor.
Water Sensor
Returns an analog value from the Water sensor.
pin: The pin connected to the sensor.
Environment Sensor(Sugar)
Environment Sensor Information
Returns a list containing the temperature and humidity readings from the Environment sensor.
TOF Laser Distance Module
Returns the distance in mm from the laser distance module.
Joystick Module
Returns the value from the Joystick module.
RTC Clock Module
Sets the time on the Clock module.
Starts or stops the clock.
Syncs the clock with UTC time.(Needs network connection)
Returns a value from the clock module.
Ultrasound Sensor
Returns the distance measured by the ultrasound sensor.
pin: The pin connected to the sensor.
RFID Module
Starts the scan for RFID tag.
Stops the RFID scanning.
Returns the RFID UUID.
Writes or read the data from the RFID tag.
SECTOR: RFID sector, 1~16.
BLOCK: RFID block, 0~2.
DATA: The data to be written.
Colour and Gesture Module
Colour and Gesture Module Information
Sets the mode for the Colour and Gesture Module.
type: mode
Colour Mode: 1
Distance Mode: 2
Gesture Mode: 3
LED Mode: 4
hue = ColorGes().read(0) brightness = ColorGes().read(1)
Returns the colour values, hue and brightness, when mode is set to colour.
Returns the distance when mode is set to distance. Value ranges from 0 to 255.
Returns the last gesture when mode is set to gesture.
Sets the LED brightness and state when mode is set to LED.
LED Brightness: 0~100
LED State: 0 for off, 1 for on
MP3 Module
Sends the command to the MP3 module.
op: Command to send
MP3 play: MP3().PLAY
MP3 stop: MP3().STOP
MP3 next song: MP3().NEXT
MP3 previous song: MP3().PREV
MP3().vol(volume)
Sets the volume for the MP3 player. (0~30)
Specify the song to play by index. (The index on the SD card)
Specify the song to play by file name. (Cannot be more than 8 characters)
Environment Module(Powerbrick)
Environment Module Information
Creates a DHT11 object.
pin: The pin connected to the sensor.
dht11.measure()
Asks the sensor to measure environment data.
Returns the temperature and humidity readings from the sensor.
Water-proof Temperature Sensor
Water-proof Temperature Sensor Information
Reurns the temperature reading from the sensor.
pin: The pin connected to the sensor.
Last updated