Codi:bit MicroPython API documentation
π Documentation Structureβ
This documentation is organized using the DiΓ‘taxis framework, which provides four types of documentation for effective technical writing:
π― Tutorialsβ
Purpose: Learning - Complete learning paths that users can follow from start to finish
- Getting Started: Introduction to Codi:bit, first program, basic concepts
- Basic Projects: LED control, button handling, display usage
- Sensor Projects: Light detection, sound sensing, environment monitoring
- Advanced Projects: Multi-sensor applications, interactive projects
π§ How-to Guidesβ
Purpose: Tasks - Specific methods for performing particular tasks
- Button Usage: How to detect button presses and handle user input
- Light Change Detection: How to detect and respond to light level changes
- Microphone Usage: How to use the microphone sensor for sound detection
π Referenceβ
Purpose: Information - API and technical details
- Built-in Sensors API: Complete API documentation for all built-in sensors
- Hardware Reference: Pin assignments, specifications, power management
- System Reference: MicroPython and ESP32 related information
π Explanationβ
Purpose: Understanding - Concepts and background knowledge
- Concepts: Sensor principles, communication protocols, programming concepts
- Architecture: Library structure, hardware architecture, performance optimization
- Education: Educational philosophy, STEM education
π Getting Startedβ
Quick Startβ
from codibit import *
# Display text
display.draw_text("Hello Codi:bit!", 0, 0)
display.show()
# Read button state
if button_a.is_pressed():
print("Button A is pressed!")
# Read light sensor
light_level = light.read_level()
print(f"Light level: {light_level}")
# Read microphone
sound_level = microphone.get_level()
print(f"Sound level: {sound_level}")
Hardware Overviewβ
Codi:bit is an ESP32-based educational microcontroller board with:
- Display: SH1106 OLED (128x64 pixels)
- Sensors:
- MMC5603NJ magnetometer
- QMI8658C 6-axis IMU (accelerometer, gyroscope)
- ALS-PT19 light sensor
- Microphone sensor
- I/O:
- WS2812B RGB LED
- Buzzer
- 2 buttons (A and B)
- Connectivity: WiFi, Bluetooth
π Documentation Sectionsβ
Tutorials (Learning)β
- Getting Started: Hardware introduction and first program
- Basic Projects: LED blinking, button response, display usage
- Sensor Projects: Light detection, sound sensing, environment monitoring
- Advanced Projects: Multi-sensor applications, interactive projects
How-to Guides (Tasks)β
- Button Usage: Detect button presses and handle user input
- Light Change Detection: Detect and respond to light level changes
- Microphone Usage: Use microphone sensor for sound detection
Reference (Information)β
- Built-in Sensors API: Complete API documentation for all sensors
- Hardware Reference: Pin mappings and specifications
- System Reference: MicroPython and ESP32 details
Explanation (Understanding)β
- Concepts: Sensor principles and programming concepts
- Architecture: Library design and hardware architecture
- Education: Educational approach and STEM learning
π― Learning Pathβ
For Beginnersβ
- Start with Getting Started
- Learn Button Usage for user input
- Explore Light Change Detection for sensor usage
- Try Microphone Usage for sound detection
For Developersβ
- Check Built-in Sensors API for function details
- Review hardware specifications for pin assignments
- Understand library architecture for system design
For Educatorsβ
- Read educational philosophy and STEM concepts
- Explore tutorials for classroom activities
- Use examples for hands-on learning
π Quick Linksβ
- Built-in Sensors API: Complete API reference
- Button Usage Guide: How to use buttons
- Light Detection Guide: How to detect light changes
- Microphone Usage Guide: How to use microphone
- Examples: Code examples
π Code Examplesβ
Button Exampleβ
from codibit import *
import time
while True:
if button_a.is_pressed():
print("Button A pressed!")
if button_b.is_pressed():
print("Button B pressed!")
time.sleep(0.1)
Light Sensor Exampleβ
from codibit import *
import time
while True:
level = light.read_level()
print(f"Light level: {level}")
time.sleep(1)
Microphone Exampleβ
from codibit import *
import time
while True:
if microphone.is_loud():
print("Loud sound detected!")
time.sleep(0.1)
π Additional Resourcesβ
- GitHub Repository: Source code and issues
- MicroPython Documentation: MicroPython reference
- ESP32 Documentation: ESP32 technical details
Start Learning: Begin with Getting Started to learn about Codi:bit hardware and create your first program!