Advertisement
pleasedontcode

Preferences example

Aug 29th, 2024
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 0.40 KB | Source Code | 0 0
  1. #include <Preferences.h>
  2.  
  3. Preferences preferences;
  4.  
  5. void setup() {
  6.     Serial.begin(115200);
  7.     preferences.begin("my-app", false);  // Initialize preferences
  8.  
  9.     // Store data
  10.     preferences.putInt("boot_count", 42);
  11.  
  12.     // Read data
  13.     int bootCount = preferences.getInt("boot_count", 0);
  14.     Serial.println(bootCount);
  15.  
  16.     preferences.end();
  17. }
  18.  
  19. void loop() {
  20.     // Your loop code
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement