GoForSmoke:
Try running some known-good examples. If the hardware or IDE is faulty it might show up quick.
OK. Found out what is causing it but I don't know why it caused it. I was using const int variable. If I drop the const then the program behaves as expected. Since pin numbers don't change I guess that seemed like a logical thing to do and I don't know why adding Serial.something altered the behavior though. But, I'm a newb.
outofoptions:
GoForSmoke:
Try running some known-good examples. If the hardware or IDE is faulty it might show up quick.
OK. Found out what is causing it but I don't know why it caused it. I was using const int variable. If I drop the const then the program behaves as expected. Since pin numbers don't change I guess that seemed like a logical thing to do and I don't know why adding Serial.something altered the behavior though. But, I'm a newb.
Your conclusion don't sound very convincing. Can you post short sketches showing one working and one not working using or not using the const pin assignment?
Lefty
retrolefty:
outofoptions:
GoForSmoke:
Try running some known-good examples. If the hardware or IDE is faulty it might show up quick.
OK. Found out what is causing it but I don't know why it caused it. I was using const int variable. If I drop the const then the program behaves as expected. Since pin numbers don't change I guess that seemed like a logical thing to do and I don't know why adding Serial.something altered the behavior though. But, I'm a newb.
Your conclusion don't sound very convincing. Can you post short sketches showing one working and one not working using or not using the const pin assignment?
Lefty
Straight from the examples bundled with the Arduino environment.
If I change
int led = 13;
to
const led = 13;
the led says on.
If I add Serial.begin(9600); it begins blinking.
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
/////////////const int led = 13;
// the setup routine runs once when you press reset:
void setup() {
///////////Serial.begin(9600);
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
const led = 13;
Is not a legal statement, no type specified.
I loaded the example blink sketch and changed
int led = 13;
to
const int led = 13;
And it complies, uploads, and runs just fine.
Your comment on that?
Lefty
retrolefty:
const led = 13;
Is not a legal statement, no type specified.
OK. Simply my bad on that. What I used was in the code posted.
retrolefty:
I loaded the example blink sketch and changed
int led = 13;
to
const int led = 13;
And it complies, uploads, and runs just fine.
Your comment on that?
Lefty
Well, you aren't the only one it ran for without the Serial.whatever so I guess it is either my UNO which is without a revision number or something in my local libraries. This board is borrowed and I have ordered one of my own, Rev 3. If the problem goes away with the new board then I'll chalk it up to some flakiness in the current board. If it continues after that I'll suspect a corrupt package from my Linux distro.
I don't know why the "const" makes a difference on mine.
I don't know why the "const" makes a difference on mine.
It shouldn't. I'm a windows user, but have read of very strange arduino sketch problems if your Linux machine is using it's own gcc complier/linker version rather then the one that comes from the arduino distribution. But I would have to let other arduino Linux gurus look into if that could be your problem or not and if so how to fix it.
Lefty
retrolefty:
I don't know why the "const" makes a difference on mine.
It shouldn't. I'm a windows user, but have read of very strange arduino sketch problems if your Linux machine is using it's own gcc complier/linker version rather then the one that comes from the arduino distribution. But I would have to let other arduino Linux gurus look into if that could be your problem or not and if so how to fix it.
Lefty
Thanks. It is somehow reassuring to know that I simply wasn't misusing "const" I guess. I don't see it in much of the example code.
outofoptions:
I don't see it in much of the example code.
The example code is not the best it could be.
int ledpin = 13; // there are less than 256 pins, use a byte instead, save a byte in RAM
int pinArray[ 8 ]; // because a habit is a habit
GoForSmoke:
The example code is not the best it could be.
int ledpin = 13; // there are less than 256 pins, use a byte instead, save a byte in RAM
This I get.
GoForSmoke:
int pinArray[ 8 ]; // because a habit is a habit
This? Not so much unless you mean it as an example of what NOT to do?
outofoptions:
GoForSmoke:
The example code is not the best it could be.
int ledpin = 13; // there are less than 256 pins, use a byte instead, save a byte in RAM
This I get.
GoForSmoke:
int pinArray[ 8 ]; // because a habit is a habit
This? Not so much unless you mean it as an example of what NOT to do?
Exactly. It is the same mistake multiplied 8 times in 1 line most often out of the habit of typing i-n-t.
I decided to download the source and compile to see what would happen. The download page gave me the binary instead. I started it up, tested, works as expected. Had I known earlier that the binaries were already compiled.....
Kinda makes me wonder how they got screwed up in the package. Oh well, put this one to rest......