I have an Arduino Uno and I power it via my laptop's 5v usb, then I use (Analog Voltage Meter) to check the power voltage of digital pin 7
pinMode(7 , OUTPUT)
digitalWrite(7, HIGH);
I expected it to be 5V but it only shows 1.5V - 2.5V? (Other digital pins have the same value as digital pin 7)
I don't know why, can Anyone explain to me? how can i get exactly 5V from the digital pins?
(as shown below) I also want to know, is there a way to set a high (on) or low (off) value for the pin 3.3V pin, Pin 5V , Pin Vin to power an external device similar to the digital pin or not?
You cannot control the power pins (3.3V, 5V, Vin) programmatically.
Vin is not a power output.
Those measurements are done with a DMM (Digital MultiMeter)?
So all of the digital pins read 1.5V to 2.5V when the Arduino is powered with the USB port? Are those measurements are made between the pin and a ground pin with a DMM?
What does the 5V pin read (with respect to ground) with your DMM?
I am assuming the meter is set for dC. Measure the voltage of a known good battery with your meter and see what the voltage is. If that matches the battery rating your meter is probably ok. If not your Arduino is probably OK.
If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.
If the pin is configured as an INPUT, digitalWrite() will enable (HIGH) or disable (LOW) the internal pullup on the input pin. It is recommended to set the pinMode() to INPUT_PULLUP to enable the internal pull-up resistor. See the Digital Pins tutorial for more information.
If you do not set the pinMode() to OUTPUT, and connect an LED to a pin, when calling digitalWrite(HIGH), the LED may appear dim. Without explicitly setting pinMode(), digitalWrite() will have enabled the internal pull-up resistor, which acts like a large current-limiting resistor.
Finally this would go much better if you posted your code using appropriate code tags. I have no idea what your objective is? Details do matter.
After checking again this morning. I discovered that my usb cable does not have enough 5V when connected to a USB HUB (there are many devices connected to it such as mouse, keyboard, printer cable, USB Stick) and I tried connecting to the usb port on the back of PC and I checked the voltage of digital pin 7 again and it showed ~5V as expected.
Blockquote
A USB port should certainly be able to supply sufficient power to a bare Arduino UNO board.
Or do you have some other stuff connected to your board that you haven't told us about...?
I think this usb hub is too old (I bought it 5--6 years ago) and has hardware related error, sometimes it doesn't recognize usb stick or Cisco USB Console Cable,...
Blockquote
Did you use the same cable when you plugged it direct into the PC? << Yes