Last active
December 1, 2023 17:15
-
-
Save codekoriko/2bf0d0133687211d9bf5278a8ff0c172 to your computer and use it in GitHub Desktop.
Arduino - snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
const int analogVoltagePin = A0; // Analog input pin for voltage measurement | |
void setup() | |
{ | |
Serial.begin(9600); // Initialize serial communication | |
} | |
void loop() | |
{ | |
int sensorValueVoltage = analogRead(analogVoltagePin); // Read the analog input for voltage | |
// Convert the sensor value to voltage (assuming a 5V reference for the ADC) | |
float voltage = sensorValueVoltage * (5.0 / 1023.0); // 5.0V is the reference voltage, 1023 is the maximum value for a 10-bit ADC | |
Serial.print("Voltage: "); | |
Serial.print(voltage); | |
Serial.println(" V"); | |
delay(1000); // Delay for readability, adjust as needed | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "FS.h" | |
String realSize = String(ESP.getFlashChipRealSize()); | |
String ideSize = String(ESP.getFlashChipSize()); | |
bool flashCorrectlyConfigured = realSize.equals(ideSize); | |
void setup() { | |
Serial.begin(115200); | |
if(flashCorrectlyConfigured) SPIFFS.begin(); | |
else Serial.println("flash incorrectly configured, SPIFFS cannot start, IDE size: " + ideSize + ", real size: " + realSize); | |
bool format_success = SPIFFS.format(); | |
if(format_success) Serial.println("formating was successful"); | |
else Serial.println("formating failed"); | |
} | |
void loop() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment