Stufin
Home Quick Cart Profile

Raspberry Pi Official Mouse Black

Buy Now

Dimensions

104mm x 60mm x 35mm (L x W x H)

Weight

80g

Cable length

1.8m

DPI (Dots Per Inch)1000

Operating system compatibility

Raspbian, Windows, macOS

Interface

USB 2.0

Power consumption

5V, 100mA (max)

Conclusion

The Raspberry Pi Official Mouse Black is a high-quality, ergonomic mouse designed specifically for use with Raspberry Pi single-board computers. Its precise optical sensor, three-button design, and scrolling wheel make it an ideal choice for users requiring accurate and comfortable pointing and navigation. With its compact size, durable construction, and official Raspberry Pi certification, this mouse is a great addition to any Raspberry Pi-based project or setup.

Pin Configuration

  • Raspberry Pi Official Mouse Black Pinout Documentation
  • The Raspberry Pi Official Mouse Black is a compact, three-button optical mouse specifically designed for use with the Raspberry Pi series of single-board computers. The mouse connects to the Raspberry Pi via a USB interface. Here's a detailed explanation of the pins and their connections:
  • USB Connector Pinout:
  • The Raspberry Pi Official Mouse Black uses a standard USB-A connector with the following pinout:
  • 1. Vbus (Pin 1):
  • Function: Power supply (5V)
  • Description: Provides power to the mouse from the Raspberry Pi
  • 2. D- (Pin 2):
  • Function: Data-
  • Description: Carries data transmission from the mouse to the Raspberry Pi
  • 3. D+ (Pin 3):
  • Function: Data+
  • Description: Carries data transmission from the mouse to the Raspberry Pi
  • 4. GND (Pin 4):
  • Function: Ground
  • Description: Provides a common ground connection between the mouse and the Raspberry Pi
  • 5. ID (Pin 5):
  • Function: Device identification
  • Description: Not connected (reserved for future use)
  • 6. Shield (Pin 6, 7, 8):
  • Function: Shielding
  • Description: Provides electromagnetic interference (EMI) shielding and protects the signal lines
  • 7. Vbus (Pin 9):
  • Function: Power supply (5V)
  • Description: Provides power to the mouse from the Raspberry Pi
  • 8. D- (Pin 10):
  • Function: Data-
  • Description: Carries data transmission from the mouse to the Raspberry Pi
  • 9. D+ (Pin 11):
  • Function: Data+
  • Description: Carries data transmission from the mouse to the Raspberry Pi
  • 10. GND (Pin 12):
  • Function: Ground
  • Description: Provides a common ground connection between the mouse and the Raspberry Pi
  • Connection Structure:
  • To connect the Raspberry Pi Official Mouse Black to your Raspberry Pi, follow these steps:
  • 1. Locate the USB ports on your Raspberry Pi.
  • 2. Align the USB-A connector on the mouse with one of the USB ports on the Raspberry Pi.
  • 3. Gently push the connector into the port until it clicks into place.
  • 4. Ensure the mouse is securely connected to the Raspberry Pi.
  • Important Notes:
  • The Raspberry Pi Official Mouse Black does not require any additional power supply connections, as it draws power from the Raspberry Pi via the USB connection.
  • Make sure to handle the USB connector and pins with care to avoid damage or bent pins.
  • The mouse is designed for use with the Raspberry Pi and may not be compatible with other devices.
  • By following this documentation, you should be able to successfully connect your Raspberry Pi Official Mouse Black to your Raspberry Pi and start using it for your projects.

Code Examples

Raspberry Pi Official Mouse Black Documentation
Overview
The Raspberry Pi Official Mouse Black is a high-quality, compact, and plug-and-play mouse designed specifically for use with Raspberry Pi boards. This mouse is a great addition to any Raspberry Pi project, providing a reliable and precise pointing device for interacting with your Raspberry Pi-based system.
Technical Specifications
Interface: USB
 Resolution: 1000 dpi
 Buttons: 3 (Left, Right, Middle)
 Compatibility: Raspberry Pi boards (all models)
Code Examples
### Example 1: Basic Mouse Usage with Python (Raspberry Pi OS)
This example demonstrates how to use the Raspberry Pi Official Mouse Black with Python to read mouse events and movements.
Code:
```python
import pygame
# Initialize pygame
pygame.init()
# Create a pygame window
screen = pygame.display.set_mode((640, 480))
# Get the mouse object
mouse = pygame.mouse
while True:
    # Handle events
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
        elif event.type == pygame.MOUSEMOTION:
            # Get the mouse position
            x, y = mouse.get_pos()
            print(f"Mouse moved to ({x}, {y})")
        elif event.type == pygame.MOUSEBUTTONDOWN:
            # Get the mouse button state
            button_state = mouse.get_pressed()
            if button_state[0]:  # Left button
                print("Left button pressed")
            elif button_state[1]:  # Middle button
                print("Middle button pressed")
            elif button_state[2]:  # Right button
                print("Right button pressed")
# Update the screen
    pygame.display.flip()
```
### Example 2: Using the Mouse with a Raspberry Pi-based Robot (Python)
This example demonstrates how to use the Raspberry Pi Official Mouse Black with a Raspberry Pi-based robot to control its movements.
Assumptions:
You have a Raspberry Pi-based robot with motor drivers and a USB connection to the Raspberry Pi.
 You have installed the necessary libraries for your robot's motor drivers.
Code:
```python
import RPi.GPIO as GPIO
import time
# Set up GPIO mode
GPIO.setmode(GPIO.BCM)
# Set up motor pins
left_motor_forward = 17
left_motor_backward = 23
right_motor_forward = 24
right_motor_backward = 25
# Set up mouse
mouse = pygame.mouse
try:
    while True:
        # Get the mouse position
        x, y = mouse.get_pos()
# Control the robot's movements based on mouse position
        if x > 320:  # Move forward
            GPIO.output(left_motor_forward, GPIO.HIGH)
            GPIO.output(right_motor_forward, GPIO.HIGH)
        elif x < 320:  # Move backward
            GPIO.output(left_motor_backward, GPIO.HIGH)
            GPIO.output(right_motor_backward, GPIO.HIGH)
        elif y > 240:  # Turn left
            GPIO.output(left_motor_forward, GPIO.HIGH)
            GPIO.output(right_motor_backward, GPIO.HIGH)
        elif y < 240:  # Turn right
            GPIO.output(left_motor_backward, GPIO.HIGH)
            GPIO.output(right_motor_forward, GPIO.HIGH)
# Update the motors
        time.sleep(0.1)
        GPIO.output(left_motor_forward, GPIO.LOW)
        GPIO.output(left_motor_backward, GPIO.LOW)
        GPIO.output(right_motor_forward, GPIO.LOW)
        GPIO.output(right_motor_backward, GPIO.LOW)
except KeyboardInterrupt:
    GPIO.cleanup()
```
These examples demonstrate the ease of use and versatility of the Raspberry Pi Official Mouse Black in various contexts. By following these examples, you can integrate the mouse into your Raspberry Pi-based projects and take advantage of its precision and reliability.