Pages: [1]   Go Down
Author Topic: analogWrite freezes the board  (Read 579 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ello, when I try to run any code that has an analogWrite(x,x); in it, it compiles but the code won't run. Even if my code is not going trough it, if it is present in the code, the code is not starting.
any insight on what the problem could be ?

The board is an Arduino DUE

This won't work, test will not print
  
Code:
Serial.print(" test");
  analogWriteResolution(8);
  analogWrite(11,100);
  


but this is working, test is printed correctly:

 
Code:
  Serial.print(" test");
  analogWriteResolution(8);
  //analogWrite(11,100);
 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

Did you try
Code:
pinMode(11, OUTPUT);
in your setup?
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8606
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Did you try
Code:
 pinMode(11, OUTPUT);
in your setup?

Exactly why we like to see ALL the code. But will not setting the pin to an OP kill the program?

______
Rob
« Last Edit: February 19, 2014, 04:47:03 am by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah, everything is set. I'm 100% sure it's not about the code because it is working fine on my friend's arduino
Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Firstly, delete/uninstall the Arduino IDE, re-download it and reinstall it.

Then try running the Basics->Fade example with an LED+resistor connected to pin 9 and GND. Does it work?
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nope, it compiles but it just seems to push nothing to the arduino, or the arduino can't handle it
Logged

Venezuela
Offline Offline
God Member
*****
Karma: 17
Posts: 522
Ground, ground, always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello jdorval,
Which IDE version you are using? 1.5.5-r2 or older?
Also, could you run the following code to see if the built-in led L (amber) fades?

Code:
const int ledPin = 13;

void setup() {
  pinMode(ledPin, OUTPUT); }

void loop() {
  for (int brightness = 0; brightness < 255; brightness++) {
    analogWrite(ledPin, brightness);
    delay(2);
  }
  for (int brightness = 255; brightness >= 0; brightness--) {
    analogWrite(ledPin, brightness);
    delay(2);
  }
  delay(100);
}

Regards,
Palliser
Logged

Pages: [1]   Go Up
Jump to: