Hi. Yes another very basic question!!
When I flash a binary to the Electron (in my case I am doing this over serial from the CLI), is the entire program memory of the Electron “wiped” and replaced with the new binary?
I ask this question because I had a previous “blink” program compiled and loaded and successfully blinking. It looked like this:
int led1 = D0; // Instead of writing D0 over and over again, we'll write led1
// You'll need to wire an LED to this one to see it blink.
int led2 = D7; // Instead of writing D7 over and over again, we'll write led2
// This one is the little blue LED on your board. On the Photon it is next to D7, and on the Core it is next to the USB jack.
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
}
void loop() {
// To blink the LED, first we'll turn it on...
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
// We'll leave it on for 1 second...
delay(1000);
// Then we'll turn it off...
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
// Wait 1 second...
delay(1000);
// And repeat!
}
Then I coded a simple program to turn pin D6 off with no blinking in the program like this:
#define PIN D6
int state = 0;
void setup() {
//tell the device we want to write to this pin
pinMode(PIN, OUTPUT);
}
void loop() {
//Turn Pin Off
digitalWrite(PIN, LOW);
}
It successfully compiled and I flashed it, but the previous blinking D7 LED started blinking after the flash.
I had assumed my new program would overwrite the old one and the blinking LED would stop…
I suppose I am just after a bit of explanation for where I may have gone wrong either in my assumptions or programming…
Thanks.