A USB power supply is an essential component in modern electronics, providing a convenient and standardized way to deliver DC power to a wide range of devices. It converts AC mains power into a lower-voltage DC output, which is accessible through one or more USB ports. Common applications include charging smartphones, tablets, and powering devices like Raspberry Pi, Arduino boards, and various USB-powered gadgets.
Pin Number | Description | Voltage/Signal |
---|---|---|
1 | VBUS (Power) | 5V |
2 | D- (Data minus) | Data |
3 | D+ (Data plus) | Data |
4 | ID (for USB OTG) | Not connected |
5 | GND (Ground) | 0V |
Note: USB-C and USB-PD have additional pins and configurations.
Q: Can I use a USB power supply with a higher current rating than my device requires?
A: Yes, the device will only draw the current it needs.
Q: Is it safe to leave the USB power supply plugged in all the time?
A: Generally, it is safe, but it's more energy-efficient to unplug it when not in use.
Q: Can I use a USB power supply in other countries?
A: Most are rated for 100-240V AC input, but check the specifications and use a plug adapter if necessary.
If you're using the USB power supply to power an Arduino UNO, you can connect it via the board's USB port. Here's a simple example of how to set up an LED blink sketch:
// Define the LED pin
const int ledPin = 13;
// The setup function runs once when you press reset or power the board
void setup() {
// Initialize the digital pin as an output.
pinMode(ledPin, OUTPUT);
}
// The loop function runs over and over again forever
void loop() {
digitalWrite(ledPin, HIGH); // Turn the LED on
delay(1000); // Wait for a second
digitalWrite(ledPin, LOW); // Turn the LED off
delay(1000); // Wait for a second
}
Note: Ensure the Arduino board's power requirements do not exceed the USB power supply's output specifications.