// Test:
// Does Wokwi use the Reset pin and can that be
// controlled from code and does the red button
// on the board work and does Wokwi preserve
// the SRAM contents ?
//
// Answer to all of that: Yes
//
// An Arduino Uno in real life keeps its unused SRAM contents,
// during a reset.
// Point to a SRAM location that is hopefully never used.
byte *pRam = (byte *) 0x0400;
byte *pCount = (byte *) 0x0401;
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println("Started");
if(*pRam == 0xAA)
Serial.println("The SRAM contents was preserved");
else
Serial.println("The SRAM contents was cleared");
Serial.print("Number of resets: ");
Serial.println((int) *pCount);
*pRam = 0xAA;
*pCount = *pCount + 1;
}
void loop()
{
for(int i=10; i>=0; i--)
{
Serial.print(".");
delay(1000);
Serial.print(i);
}
Serial.println();
Serial.println("The Reset pin is pulled low with code");
Serial.flush();
pinMode(2,OUTPUT); // set OUTPUT which is default LOW
}
Reset button ↓
Reset pin ↑