2n2222 transistor PWM attiny85 without CAP or DIODE

i know im supposed to have the cap in between GND and VCC of the Attiny85 to protect it and a diode protect as well. I dont have any of those yet (they are ordered). Here is my question, when I tell the attiny to send a PWM signal to transistor it actually turns on the dc motor (Micro dc motor probably for vibration). but when i send a low signal it doesnt turn it off. I know the cap and diode are there to protect but right now im in an experimental stage just trying to figure out how everything works and why it works. i have a nice collection of 2n2222 transistors and attiny85's. so i dont mind if it burns out just wondering why it turns it on and doesnt turn it off. As i understand it should turn it off but then burn out the ic, am i correct? btw i use the same code with an led and took out the trans and the ic works as it should...

It is best to show us the schematic and an image of your circuit.

still trying to figure out fritzing.... i have everything wired right im 100% on that let me try and come up with a decent fritz

Wesley5n1p35:
still trying to figure out fritzing.... i have everything wired right im 100% on that let me try and come up with a decent fritz

Ever heard of a pencil and paper?
Fritzing diagrams are rubbish! Mostly useful for those who can't be bothered learning schematic symbols.
Nothing beats a neatly-drawn and labelled schematic diagram.

As i understand it should turn it off but then burn out the ic, am i correct?

I don't get this at all.

Better show us both the schematic and your code. (Between code tags, needless to say.)
Then we might be able to understand the situation.

OldSteve:
Ever heard of a pencil and paper?
Fritzing diagrams are rubbish! Mostly useful for those who can’t be bothered learning schematic symbols.
Nothing beats a neatly-drawn and labelled schematic diagram.
I don’t get this at all.

Better show us both the schematic and your code. (Between code tags, needless to say.)
Then we might be able to understand the situation.

#include <Manchester.h>

const int RX_PIN = 0; //= pin 5
uint8_t moo = 1;
const int DCmotor = 1; //=pin6
const int led = 4;// pin3

int pwmPower = 150;// PWM integer

const int button = 3;//pin2
int buttonPushCounter = 0;
int buttonState = 0;
int lastButtonState = 0;

byte state = 0;



void setup() {
pinMode(DCmotor, OUTPUT);
pinMode(3,INPUT_PULLUP);
digitalWrite(DCmotor, LOW);
pinMode(led,OUTPUT);


man.setupReceive(RX_PIN, MAN_1200);
man.beginReceive();
}

void loop() {

{
  buttonState = digitalRead(button);
  if (buttonState != lastButtonState)
  {
    if (buttonState == LOW)
    {
      state++;
      if (state > 3)
      {
        state = 0;
      }
    }
    switch (state)
    {
      
      case 0:
       digitalWrite(led, HIGH);  
  delay(10);              
  digitalWrite(led, LOW);    
  delay(10);  
  digitalWrite(led, HIGH);  
  delay(10);              
  digitalWrite(led, LOW);    
  delay(10);  
  digitalWrite(led, HIGH);  
  delay(10);              
  digitalWrite(led, LOW);    
  delay(10);        
  digitalWrite(led, HIGH);  
  delay(10);              
  digitalWrite(led, LOW);              
        pwmPower = 50;
        break;
        
        //////
        
      case 1:
      digitalWrite(led, HIGH);  
  delay(100);              
  digitalWrite(led, LOW);        
        pwmPower = 100;
        break;

        ////////////
        
      case 2:
      digitalWrite(led, HIGH);  
  delay(500);              
  digitalWrite(led, LOW);    
  
        pwmPower = 150;
        break;

        /////////
        
      case 3:
       digitalWrite(led, HIGH);  
  delay(800);              
  digitalWrite(led, LOW);    
  
       pwmPower = 255;
        break;

      
    }
   
  }
  lastButtonState = buttonState;



  

if (man.receiveComplete()) {
uint16_t m = man.getMessage();

man.beginReceive(); //start listening for next message right after you retrieve the message
moo = ++moo % 2;
if (m==2761)

{analogWrite(DCmotor,pwmPower);}

if (m==4000){digitalWrite(DCmotor,LOW);}

 
}
}
}

my main question is… Is my project not working correctly (by not working I mean the motor will turn on, on command and not turn off on command) but it will work correctly without transistor and just LED in place of it.
and btw the led and motor both turn on based on PWM outputs that i have set based on how many times i press a button.
or is it not working because i dont have a diode

Wesley5n1p35:
or is it not working because i dont have a diode

Without your schematic, we have no way of knowing what's going on. It takes only minutes to draw a schematic then scan or photograph it.
Saying that you're using a transistor says virtually nothing. How exactly do you have it connected?
Just draw the thing, rather than waste more time.

And you should do none of this without decoupling caps and a protection diode, especially if you're not using a separate supply for the motor.
Impatience is not a virtue.


this is the diagram i am following if it helps.

We need to confirm your wiring.
Are you able to show us an actual image of the wiring?

Your transistor may not be fully turning on.
What is the current needed by the motor? Data sheet is needed.
When the Arduino output turns the transistor on, what is the collector to emitter voltage?

With that circuit, 'digitalWrite(pin,0)' or 'analogWrite(pin,0)' should turn the motor off.

but when i send a low signal it doesnt turn it off ...... As i understand it should turn it off but then burn out the ic, am i correct?

And I don't know why you think this. There's no reason to think that the IC should die when you turn off the motor. Or if you mean because there's no protection diode, that could kill the transistor, but not the ATtiny85.

You should wait until you get some diodes and decoupling caps anyway.

What you should do, to isolate the problem, is write a short program that only controls the motor and nothing else. Then, once you have that working successfully, work on the larger program.

Are you sure that you're actually getting the value 4000 here:-

if (m == 4000)
    digitalWrite(DCmotor, LOW);

"moo" doesn't appear to do anything at all either. The only reference to it in the whole program is here:-

moo = ++moo % 2;

Gotta love your descriptive, well-chosen variable names.

Gotta love your descriptive, well-chosen variable names.

Do I detect a hint of sarcasm ?

@OP,
As OldSteve said, you should NOT be screwing around with this circuit without the diode .
You have been warned.

raschemmel:
Do I detect a hint of sarcasm ?

Who, me? :smiley:

Moo me?

LarryD:
Moo me?

I'm a bit slow today - this should have been my reply in my last post. :slight_smile:

You boys having fun?

BUSTED ! (OFF TOPIC VIOLATION !)
Get back to work.

Just taking a MOOment off.
You know what happens when there is MOOmentum.