{"action":"created","issue":{"url":"https://api.github.com/repos/arduino/Arduino/issues/2455","labels_url":"https://api.github.com/repos/arduino/Arduino/issues/2455/labels{/name}","comments_url":"https://api.github.com/repos/arduino/Arduino/issues/2455/comments","events_url":"https://api.github.com/repos/arduino/Arduino/issues/2455/events","html_url":"https://github.com/arduino/Arduino/issues/2455","id":49137240,"number":2455,"title":"Inconsistent behaviors of analogWrite and pinMode on Due and Uno","user":{"login":"HanaJin","id":9121904,"avatar_url":"https://avatars.githubusercontent.com/u/9121904?v=3","gravatar_id":"","url":"https://api.github.com/users/HanaJin","html_url":"https://github.com/HanaJin","followers_url":"https://api.github.com/users/HanaJin/followers","following_url":"https://api.github.com/users/HanaJin/following{/other_user}","gists_url":"https://api.github.com/users/HanaJin/gists{/gist_id}","starred_url":"https://api.github.com/users/HanaJin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HanaJin/subscriptions","organizations_url":"https://api.github.com/users/HanaJin/orgs","repos_url":"https://api.github.com/users/HanaJin/repos","events_url":"https://api.github.com/users/HanaJin/events{/privacy}","received_events_url":"https://api.github.com/users/HanaJin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/arduino/Arduino/labels/Architecture:%20SAM","name":"Architecture: SAM","color":"fbca04"},{"url":"https://api.github.com/repos/arduino/Arduino/labels/Board:%20Arduino%20Due","name":"Board: Arduino Due","color":"fbca04"},{"url":"https://api.github.com/repos/arduino/Arduino/labels/Component:%20Core","name":"Component: Core","color":"009800"}],"state":"open","locked":false,"assignee":{"login":"facchinm","id":8843437,"avatar_url":"https://avatars.githubusercontent.com/u/8843437?v=3","gravatar_id":"","url":"https://api.github.com/users/facchinm","html_url":"https://github.com/facchinm","followers_url":"https://api.github.com/users/facchinm/followers","following_url":"https://api.github.com/users/facchinm/following{/other_user}","gists_url":"https://api.github.com/users/facchinm/gists{/gist_id}","starred_url":"https://api.github.com/users/facchinm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facchinm/subscriptions","organizations_url":"https://api.github.com/users/facchinm/orgs","repos_url":"https://api.github.com/users/facchinm/repos","events_url":"https://api.github.com/users/facchinm/events{/privacy}","received_events_url":"https://api.github.com/users/facchinm/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2014-11-17T19:51:56Z","updated_at":"2015-07-16T01:36:33Z","closed_at":null,"body":"I connected an RC circuit between D3 and A1 pins. Basically, D3 is connected to a 100K resistor, then to a 1uF capacitor. The voltage drop on the capacitor is measured on pin A1. \r\n\r\nWith the code below, I get reasonable readings on Uno R3. \r\n![image](https://cloud.githubusercontent.com/assets/9121904/5076367/7370cb2a-6e68-11e4-90dc-8797d86ff842.png)\r\n\r\nHowever, using a Due and the same code, after changing the pinMode to INPUT and then OUTPUT manually, analogWrite stopped working as shown below. You can rule out the malfunctioning of analogRead as I had confirmed that using a DMM.\r\n\r\n![image](https://cloud.githubusercontent.com/assets/9121904/5076436/dd49ba70-6e68-11e4-97e3-f803502efec4.png)\r\n\r\nIs this behavior expected on Due? Which mode should I set it to for PWM on the Due to make it work?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/arduino/Arduino/issues/comments/121797078","html_url":"https://github.com/arduino/Arduino/issues/2455#issuecomment-121797078","issue_url":"https://api.github.com/repos/arduino/Arduino/issues/2455","id":121797078,"user":{"login":"shimizutko","id":8579914,"avatar_url":"https://avatars.githubusercontent.com/u/8579914?v=3","gravatar_id":"","url":"https://api.github.com/users/shimizutko","html_url":"https://github.com/shimizutko","followers_url":"https://api.github.com/users/shimizutko/followers","following_url":"https://api.github.com/users/shimizutko/following{/other_user}","gists_url":"https://api.github.com/users/shimizutko/gists{/gist_id}","starred_url":"https://api.github.com/users/shimizutko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shimizutko/subscriptions","organizations_url":"https://api.github.com/users/shimizutko/orgs","repos_url":"https://api.github.com/users/shimizutko/repos","events_url":"https://api.github.com/users/shimizutko/events{/privacy}","received_events_url":"https://api.github.com/users/shimizutko/received_events","type":"User","site_admin":false},"created_at":"2015-07-16T01:36:33Z","updated_at":"2015-07-16T01:36:33Z","body":"/*\r\n Date: July.16,'15\r\n\r\n Arduino Sketch bug check: The first PWM ON duty is unstable bug TEST.\r\n This is for \"Arduino ATMega328 16MHz\" as Arduino Pro mini., UNO and others\r\n \r\n How To Test:\r\n 1) Compile & upload code to Arduino board.\r\n 2) Use oscilloscope at D3 port. Y:2V/div, X:1mS/div, +trigger. \r\n\r\n Tool chain:  Arduino softwares\r\n Command Line:   None\r\n Release 0.1\r\n */\r\n//-------------------------------------------------------------------------------------------------\r\n// Global CONSTANTS\r\n//-----------------------------------------------------------------------------\r\nconst int INL_C_PWM = 3; // PWM pin D3\r\nconst int LED = 13;\r\n//-----------------------------------------------------------------------------\r\n// Global VARIABLES\r\n//-----------------------------------------------------------------------------\r\nvoid setup()\r\n{\r\n  pinMode(INL_C_PWM, OUTPUT);\r\n  digitalWrite(INL_C_PWM, 0); // init OFF\r\n\r\n  pinMode(LED, OUTPUT);\r\n}\r\n//-----------------------------------------------------------------------------\r\n// MAIN Routine\r\n//-----------------------------------------------------------------------------\r\nvoid loop()\r\n{\r\n  digitalWrite(LED, 0);\r\n  analogWrite(INL_C_PWM, 0); // analogWrite values from 0 to 255\r\n  // digitalWrite(INL_C_PWM, 0); // port OFF\r\n  delay (100); // any delay time for retrigger\r\n  digitalWrite(LED, 1);\r\n  // The first PWM ON duty is unstable Sketch bug is here\r\n  analogWrite(INL_C_PWM, 1); // analogWrite values from 0 to 255\r\n  delay (6); // any delay time \r\n  analogWrite(INL_C_PWM, 200); // analogWrite values from 0 to 255\r\n  delay (3); // any delay time \r\n}\r\n// End Of File"}}