Bit V2.2 Expansion Board Holder
Overview
Bit V2.2 Expansion Board Holder
Overview
Bit V2.2 Expansion Board Holder is suitable for a wide range of IoT projects, including |
45mm x 35mm x 15mm (L x W x H)
Durable plastic
10g
Micro | Bit V2.2 microcontroller board |
-20C to 70C
-40C to 85C
Applications
Bit V2.2's features, the Micro | Bit V2.2 Expansion Board Holder is an essential component for anyone looking to develop innovative IoT projects. |
Micro:Bit V2.2 Expansion Board Holder Documentation
The Micro:Bit V2.2 Expansion Board Holder is a versatile component designed to connect and interface with the Micro:Bit V2.2, a popular microcontroller used in various Internet of Things (IoT) projects. This holder provides a secure and reliable connection for the Micro:Bit V2.2, enabling users to expand its capabilities with external components and sensors.
Technical Specifications:
Compatible with Micro:Bit V2.2
2x20 pin edge connector for secure Micro:Bit connection
Breadboard-compatible pins for easy connection to external components
Durable and compact design for various project applications
Code Examples:
### Example 1: Basic Connection and LED Control
In this example, we will demonstrate how to connect the Micro:Bit V2.2 to the expansion board holder and control an external LED using the Micro:Bit's GPIO pins.
Hardware Requirements:
Micro:Bit V2.2
Micro:Bit V2.2 Expansion Board Holder
Breadboard
LED
Resistor (1k)
Jumper wires
Code:
```python
import microbit
# Initialize the Micro:Bit
microbit.init(display=microbit.Display.ACTION_BAR)
# Set pin 0 as an output
microbit.pin0.write_digital(1)
while True:
# Toggle the LED connected to pin 0
microbit.pin0.write_digital(1 - microbit.pin0.read_digital())
microbit.sleep(500)
```
Explanation:
In this example, we initialize the Micro:Bit and set pin 0 as an output using the `write_digital()` method. We then enter an infinite loop, toggling the LED connected to pin 0 by writing the opposite digital value (1 or 0) using the `write_digital()` method. The `sleep()` function is used to add a 500ms delay between each toggle.
### Example 2: Reading Analog Sensor Data
In this example, we will demonstrate how to connect an analog sensor to the expansion board holder and read sensor data using the Micro:Bit's analog-to-digital converter (ADC).
Hardware Requirements:
Micro:Bit V2.2
Micro:Bit V2.2 Expansion Board Holder
Breadboard
Analog sensor (e.g., LDR, potentiometer)
Jumper wires
Code:
```python
import microbit
# Initialize the Micro:Bit
microbit.init(display=microbit.Display.ACTION_BAR)
# Set pin 1 as an analog input
microbit.pin1.set_analog_period(10)
while True:
# Read the analog sensor value
sensor_value = microbit.pin1.read_analog()
# Print the sensor value
microbit.display.scroll(str(sensor_value) + " ")
# Wait for 100ms before reading again
microbit.sleep(100)
```
Explanation:
In this example, we initialize the Micro:Bit and set pin 1 as an analog input using the `set_analog_period()` method. We then enter an infinite loop, reading the analog sensor value using the `read_analog()` method and printing it to the Micro:Bit's display using the `scroll()` method. The `sleep()` function is used to add a 100ms delay between each reading.
### Example 3: I2C Communication with External Modules
In this example, we will demonstrate how to connect an I2C-enabled module (e.g., LCD display, temperature sensor) to the expansion board holder and communicate with it using the Micro:Bit's I2C interface.
Hardware Requirements:
Micro:Bit V2.2
Micro:Bit V2.2 Expansion Board Holder
Breadboard
I2C-enabled module (e.g., LCD display, temperature sensor)
Jumper wires
Code:
```python
import microbit
# Initialize the Micro:Bit
microbit.init(display=microbit.Display.ACTION_BAR)
# Initialize the I2C interface
i2c = microbit.I2C(microbit.pin19, microbit.pin20)
# Set the I2C address of the external module
i2c_addr = 0x27
while True:
# Write a command to the external module
i2c.write(i2c_addr, b'x01x02x03')
# Read data from the external module
data = i2c.read(i2c_addr, 2)
# Print the received data
microbit.display.scroll(str(data) + " ")
# Wait for 100ms before sending the next command
microbit.sleep(100)
```
Explanation:
In this example, we initialize the Micro:Bit and the I2C interface using the `I2C()` constructor. We set the I2C address of the external module using the `i2c_addr` variable. We then enter an infinite loop, writing a command to the external module using the `write()` method and reading data from it using the `read()` method. The received data is printed to the Micro:Bit's display using the `scroll()` method. The `sleep()` function is used to add a 100ms delay between each communication cycle.