A basic Arduino OS simulation.Link:https://wokwi.com/projects/439988644143816705

I make a basic OS simulation for Arduino Uno.
2 Replies
Maverick
Maverick3w ago
Can you share the code here? Maybe a demonstration?
helloworld
helloworldOP3w ago
Yes! Code: #include <EEPROM.h> // // Used in calculating free memory. // extern unsigned int bss_end; extern void *brkval; // // Returns the current amount of free memory in bytes. // int freeMemory() { int free_memory; if ((int) brkval) return ((int) &free_memory) - ((int) brkval); return ((int) &free_memory) - ((int) &__bss_end); } String nanowrite; String nanoread; void setup() { Serial.begin(9600); Serial.println("Hello!"); Serial.println("This is Arduino OS,with CLI!"); Serial.println("Type a command and press enter!For the command list,type 'help'!");
} void loop() {
if (Serial.available() > 0) { String input = Serial.readString(); input.trim(); if (input == "neofetch") { Serial.println("OS Version:Arduino OS 1.0"); Serial.println("Microcontroller:Arduino Uno,my favorite!"); Serial.println("RAM:2 KB"); Serial.println("Memory:32 KB"); } else if (input == "help") { Serial.println("Available commands:neofetch,system_check,nano,cat_eeprom_file.txt"); } else if (input == "system_check") { Serial.println("Free memory(RAM):"); Serial.print(freeMemory()); Serial.println("Free memory(Flash):29040 bytes"); } else if (input == "nano") { while(true) { if (Serial.available() > 0) { nanowrite = Serial.readString(); for(int i = 0; i < 1024;i++) { EEPROM.update(i,255); } for(int i = 0; i < nanowrite.length(); i++){ EEPROM.write(i,nanowrite[i]); } break;

} }
} else if (input == "cat_eeprom_file.txt"){ nanoread = "";


for(int i = 0;i < 1024;i++){ if (EEPROM.read(i) == '\0'){ Serial.println(nanoread); break;

} else{ nanoread += EEPROM.read(i); } }

} } } I'm developing a new version,the Arduino OS 1.2! 1.0:The first version of Arduino OS 1.1:Optimization update 1.2:Overclocking update?

Did you find this page helpful?