While troubleshooting, I noticed that my program doesn't seem to be able to transition between setup() and loop(). I have a line of code that turns on an LED; if I place this line as the LAST line of setup() it runs, but if it is the FIRST line of loop() it does not run. Does anyone know why this might be happening?
works:
int p = 9; //LED pin
int b = 128; //LED brightness
void setup() {
Serial.begin(9600);
pinMode(p, OUTPUT);
digitalWrite(p, b);
}
void loop() {
//digitalWrite(p, b);
...
doesn't work:
int p = 9; //LED pin
int b = 128; //LED brightness
void setup() {
Serial.begin(9600);
pinMode(p, OUTPUT);
//digitalWrite(p, b);
}
void loop() {
digitalWrite(p, b);
...
as far as analogWrite() vs. digitalWrite(), that's just an oversight. It works enough to see whether the code is running. The point is that in the second example, the code never even runs. I'm looking to see if the problem is in the code presented and I'm just missing it.
The code "presented" doesn't compile, so cannot run, so cannot be said to work or not work, and the chances of anyone replicating your results are zero