Programming with MicroPython: Sugar and Powerbrick Modules
Last updated
Last updated
Import the Sugar library to make use of its functions.
Returns a boolean value from the PIR sensor.
pin: The pin connected to the sensor.
Returns a boolean value from the Line Tracker.
pin: The pin connected to the sensor.
Returns a boolean value from the Magnet sensor.
pin: The pin connected to the sensor.
Returns a boolean value from the Button sensor.
pin: The pin connected to the sensor.
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.
Returns an analog value from the Flame sensor.
pin: The pin connected to the sensor.
Returns an analog value from the Potentiometer sensor.
pin: The pin connected to the sensor.
Returns an analog value from the Light sensor.
pin: The pin connected to the sensor.
Returns an analog value from the Soil Moisture sensor.
pin: The pin connected to the sensor.
Returns an analog value from the Water sensor.
pin: The pin connected to the sensor.
Returns a list containing the temperature and humidity readings from the Environment sensor.
Returns the distance in mm from the laser distance module.
Returns the value from the Joystick 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.
Returns the distance measured by the ultrasound sensor.
pin: The pin connected to the sensor.
Imports the RFID library.
Initiates the RFID Object.
Returns the UUID. Returns None if no card is present.
Writes data onto the RFID tag.
block: RFID Block, 0~46
data: Data to be written(string)
Reads the data from the RFID Block.
block: RFID Block, 0~46
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.
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
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)
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.
Reurns the temperature reading from the sensor.
pin: The pin connected to the sensor.