Serial write and save data

Hi,

Is it possible to send an instruction via serial and have it stay next time the arduino is booted?

Say on the blink sketch

Change the delay(1000); to Say delay(500);
But also have it save so next time its plugged in the board has updated to 500

Cheers

Yes, it is.

Thanks Paul!

Big help, Star

Maybe some pointer? Youtube? Something i can read to understand how to do it.

Yes... easiest is to store the the Arduino's EEPROM memory. This memory is saved even when power is lost.

Examples here...

Yes, indeed.
Simple question caused a simple answer!

Is this boot due to "Pressing of RESET Button" or "Power Down and Power up"?

Here's a small example.. this will get a value from the monitor and store in the EEPROM. If nothing is entered (or 0) then it will get the previous value from the EEPROM.

#include <EEPROM.h>

uint16_t value = 0;

void setup()
{
  Serial.begin(115200);
  Serial.println("Enter value: ");
  
  while (Serial.available() == 0);    // Wait til we get some input.

  value = Serial.parseInt();          // Get the value from the monitor.

  if (value == 0)                     // Use the previous value stored.
    EEPROM.get(0, value);
  else
    EEPROM.put(0, value);             // Store the new value in the EEPROM

  Serial.print("Value is ");
  Serial.println(value);
}

void loop()
{}

As per original post, try not to use delay() that will limit ‘when’ your serial command will be received and processed.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.