arduino would be unplugged

I wired an encoder to the arduino UNO but when I install VCC and GND of the encoder to the 5V and GND pin of the arduino , the arduino would be unplugged please help

You have made a mistake in your wiring.

What more can I say with so little detail.
Please read this:-
How to use this forum

"Plug it back in?" :stuck_out_tongue:

What Mike said. Ask again.

@koronus, do not cross-post. Thread removed. Twice.

This is a global forum. Half of us might be asleep.
You should wait at least 24hours before expecting answers.
In the mean time you could read the forum rules (link in post#1).
Explaining things in one sentence won't cut it.

All I understand is that some PC/laptop is disconnecting (not unplugging) an unspecified Arduino after you plug in an unspecified encoder.
Leo..

Wawa:
This is a global forum. Half of us might be asleep.
You should wait at least 24hours before expecting answers.
In the mean time you could read the forum rules (link in post#1).
Explaining things in one sentence won't cut it.

All I understand is that some PC/laptop is disconnecting (not unplugging) an unspecified Arduino after you plug in an unspecified encoder.
Leo..

actually when I wired VCC and GND from magnetic encoder to 5V and GND pins of the UNO arduino ,the lights of arduino would be off and the arduino would be disconnected

Check Reply #1

If you still can't spot the problem - post your wiring diagram (schematic) as an inline picture (not attachment)
((You may need to read the forum guide on posting an image.))

Well, that went well… :slight_smile:

OK, that makes no sense...
Do you have a link to the datasheet for your encoder.

If it really has 4 pins and requies 5V, it probably has some 'smarts' internally.

OK, that's a good start...

Where's the datasheet?
The encoder's +5V pin - is probably for the LEDs used within the encoder wheel.
Does it have internal current limiting, or have you cooked the internal LEDs?

Once you figure that out - you should write asimple sketch to read & display the two pin states - while you slowly turn the shaft by hand - then you can see what the encoder pins are doing.

the encoder has 6 pins but the other 2 pins are + and - of DC motor but I want to turn the shaft of the motor slowly by hand without electricity

Moderator edit: link removed

Pls put the datasheet in the thread as an attachment
I can't download it from that malware site.

ok I attached the datasheet of the encoder

775.pdf (141 KB)

Now in order to see how you have wired it we need to see a clear photograph of your wiring. Then we can check it against your diagram of how you think you have wired it.

Please do not send PMs asking technical questions.

In the datasheet -
"The output sinnal is open collector structure" is good news.
You can use INPUT_PULLUP pinMode.

I suspect the encder is not optical, but uses hall-effect sensors...
There is no reference to the encoder's specific supply voltage which is curious.

so how I should install wires of encoder? I mean which pins of the encoder to which pins of the arduino

I think your pins are probably ok - as there is no mention of the encoder's voltage requirements - so 5V, and the open-collector note suggest the hall devices are buffered internally.

Use your existing pins, but as noted earlier, write some very simple code using digitalRead() and Serial.print() to monitor those two input pins and print their real-time state to the serial monitor - then you can see what's happening.

Once you can see the alternating pin states (per the datasheet) - you can begin looking at one of 'the hundreds of encoder examples' on the forum.

koronus:
so how I should install wires of encoder? I mean which pins of the encoder to which pins of the arduino

Why will you not post a picture?

The problem is that you are causing a short circuit when you wire up the 5V and ground. This is overloading the USB bus and causing your computer to cut the power on the USB connector.

This is because you have wired it wrong. So we need to see how you have wired it.

but I sent the picture of wiring