Your motor that you linked to is a 4.5V 190~250 mA (No Load) motor. At 9v, the current probably increases. You are overdriving it by 200%. And any load/weight will cause it to increase in current requirements as well. Stall current is probably 10x that at least.
You are missing the protection diode across the motor, that can easily kill the transistor.
The Transistor you are using is a 100mA standard, 200mA Absolute Maximum. One of those motors by itself without any load, can easily kill that transistor.
The base resistor is calculated as (Base Voltage - Base-Emmiter Voltage) / Current required
. Base Voltage is the Arduino pin, so 5v, Vbe depends on the collector current which is 200 mA here, so typically 1V. Current required is calculated as Collector Current (200mA) / Hfe (From datasheet, 10~30). On the safe side, lets go with 10, so 200 / 10 = 20mA needed at the base.
(5V - 1V) / 20mA or 4V / 0.02A = 200Ω resistor. A 1kΩ resistor would only allow 4mA at the base, which times the Hfe of 10, would only allow 40mA at the collector, probably no where enough to tun on the motor.
TLDR: You need the protection diode, your 9v power source is too high, and your transistor is too weak for the motor you are using. And you need a bigger resistor at the base because the motor requires more current then you are figuring. A common 2n2222 transistor with a 470Ω resistor would do much better.
Edit: Not making the pin an output also puts a damper on things. Answer, Arduino pins default to input.
Unlike field effect transistors bipolar transistors are not controlled by a gate voltage but by a base current.
The voltage between the base and the emitter is nearly constant as long as the transistor is conducting. This means that the voltage between the base of the transistor and ground (this is the voltage drop over the "pull down" resistor) is nearly constant.
When you operate the switch in the schematic you posted the voltage drop over the "pull down" resistor will be higher than this constant voltage. This means that the voltage between the emitter and the base of the transistor (which is the voltage over the resistor R2) will be too low so no more current can flow out of the transistor's base.
Once again: When working with bipolar transistors you have to think about currents (and to forget about voltages):
You have to design the circuit in a way that current or no current flows out of the transistor's base depending on the microcontroller's software.
If you operate your microcontroller with 5 V you might try to connect the 20 kOhms resistors to the I/O pin instead of ground. Don't place any "pull down" resistor!
If the I/O pin is "low" there is a voltage difference between the transistor's base and the I/O pin. A current will flow through the resistor; this current also flows out of the base of the transistor. The transistor will be conducting.
If the I/O pin is "high" there is no voltage difference over the resistor. No current flows and the transistor will not conduct.
If you operate the microcontroller with 3.3 V things will get more complicated. The easiest way would be to modify the circuit in the schematic you posted in this case:
Put a "small" NPN transistor between the resistor and ground and operate the NPN transistor using the I/O pin:
When the NPN transistor conducts a current can flow out of the PNP transistor's base and the PNP transistor will also conduct.
When the NPN transistor does not conduct no current will flow out of the PNP transistor's base and the PNP transistor will also not conduct.
It started working when I instead used two 10kOhm resistors, putting one to ground, one to base of resistor and digital output between them. I'm now mostly curious if what I did is theoretically correct.
The 10 kOhms resistor between the I/O pin and ground should have no effect in this case.
However the effects you describe sound very strange with this configuration.
Could you measure the voltage at the I/O pin (to ensure it really switches to high/low) as well as the voltage drop over the 10 kOhms resistor between the transistor and the I/O pin?
By the way:
Some microcontrollers use an open-drain output with a pull-up resistor. In this case the microcontroller can output 0 V very easiely but there will be a voltage drop inside the microcontroller when the output is "high". In this case you have no chance to get a "high" voltage on the I/O pin when the 10 kOhms resistor between the I/O pin and ground is fitted.
According to the data sheet ATtiny 13 does not work like this but you can never know...
Best Answer
If i understand the question, you could do it like this.
simulate this circuit – Schematic created using CircuitLab
Although this seems somewhat redundant to me, as this is essentially how the ATiny works internally. A more elegant solution would seem to be connecting them together directly, like in the following diagram. The use of a discrete transistor is sometimes required, but only if it needs to sink more than the capacity of the controller, and it looks like it's only overpowering a pull-up resistor, piece of cake.
simulate this circuit
Note that this will only work if the 2 circuits are at the same ground potential, which can usually be achieved by connecting the grounds directly together.
You should also take into consideration that the 2 circuits may be running on different logic voltages, so to avoid problems there you should be setting the pin on the ATiny to a hi-z state (in arduino, "input" mode) to avoid mucking with the other circuit.