how to check for correctness

I am a beginner on arduino as i have already programmed on 8051 in that say if i wanted to generate a PWM signal on a pin of specific duty cycle there was a simulate option there where after writing program i could verify whether or not the required pin is producing exact periodic signal as per program. But,how to ensure that correctness in arduino? I mean how to get graphical representation depending on the programing for particular pins?

Use an oscilloscope?

If you give the instruction (say) analogWrite(128); why would there be any doubt about the effect?

...R

say if i wanted to generate a PWM signal on a pin of specific duty cycle there was a simulate option there where after writing program i could verify whether or not the required pin is producing exact periodic signal as per program. But,how to ensure that correctness in arduino? I mean how to get graphical representation depending on the programing for particular pins?

Sounds like a job for an oscilloscope to me.

logic analyzer would be my advice. - https://www.saleae.com/ -

you could make a simple pulse length + ratio measure tool with a 2nd Arduino quite easily.

//
//    FILE: pulseRatioMeter.ino
//  AUTHOR: Rob Tillaart
// VERSION: 0.1.00
// PURPOSE: demo
//    DATE: 2016-01-03
//     URL: http://forum.arduino.cc/index.php?topic=369459.0
//
// Released to the public domain
//

uint32_t prevDisplay = 0;
volatile uint32_t highTime, lowTime;

void setup() 
{
  Serial.begin(115200);
  Serial.print("Start ");
  Serial.println(__FILE__);

  prevDisplay = millis();
  attachInterrupt(digitalPinToInterrupt(2), pulse, CHANGE);
}

void loop() 
{
  if (millis() - prevDisplay > 250)
  {
    prevDisplay = millis();
    noInterrupts();
    float ratio = 1.0 * highTime/(highTime + lowTime);
    Serial.print(highTime);
    Serial.print('\t');
    Serial.print(lowTime);
    Serial.print('\t');
    Serial.print(highTime + lowTime);
    Serial.print('\t');
    Serial.println(ratio, 5);
    interrupts();
  }
}

void pulse()
{
  static uint32_t last = 0;
  uint32_t duration = micros() - last;
  last = micros();
  if (digitalRead(2) == HIGH)
  {
    lowTime = duration;
  }
  else
  {
    highTime = duration;
  }
}

connect PWM signal to pin 2 (connect the GND's too)