PWM signal is not working

Hello. I have a problem that I can’t get any signal from Pin 9 (Using it as PWM). I am using Arduino Uno. I tested dummy code and it works just fine. Whole code other than analogWrite works just fine. I just couldn’t figure out why this is happening. Thanks for the help!

#include <Servo.h>
Servo myservo;
int trigger = 2;
int valu = 0;
int enable = 7;
int buttonstate = 0;
int lastbuttonstate = 0;
const int pwm = 9;
const int test = 160;
void setup() {
  // put your setup code here, to run once:
  pinMode(pwm, OUTPUT) ;
  pinMode(trigger, INPUT_PULLUP);
  pinMode(enable, OUTPUT);
  digitalWrite(enable, LOW);


void loop() {
  analogWrite(9, 200) ;

  buttonstate = digitalRead(trigger);
  if (buttonstate != lastbuttonstate)

    valu = digitalRead(trigger);
    int i = 0;

    if (valu == HIGH)
    { digitalWrite(enable, HIGH);
      digitalWrite(enable, LOW);

    if (valu == LOW)
      digitalWrite(enable, HIGH);

      digitalWrite(enable, LOW);
  lastbuttonstate = buttonstate;

Read this

Then read this:

Installation & Troubleshooting
For problems with Arduino itself, NOT your project

I am sorry that I posted on wrong category, I was unable to delete/move it afterwards. My only problem is that I can't get voltage from pin 9

My only problem is that I can't get voltage from analogWrite

See Servo - Arduino Reference

On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.