Well I connected it the positive side to PortB and connected the other side to ground.

If I didn't use a resistor would that stop the circuit from working just wondering?