#include <psram.h>
const int potPin = 34;
void setup() {
Serial.begin(115200);
if (!psramFound()) {
Serial.println("PSRAM not available");
while (true);
}
}
void loop() {
// Read analog data from potentiometer connected to pin 34
int sensorValue = analogRead(potPin);
// Allocate memory in PSRAM
char *psramData = (char *)ps_malloc(sizeof(int));
// Check if allocation was successful
if (psramData != NULL) {
// Copy analog data to PSRAM
memcpy(psramData, &sensorValue, sizeof(int));
// Do something with the data in PSRAM
Serial.println("Analog data stored in PSRAM: " + String(sensorValue));
// Free allocated memory
free(psramData);
} else {
Serial.println("Failed to allocate PSRAM");
}
//delay(1000); // Adjust delay as needed
}