pleasedontcode

Serial Navigator rev_01

Sep 28th, 2025
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: Serial Navigator
  13.     - Source Code NOT compiled for: Arduino Pro Mini 5V
  14.     - Source Code created on: 2025-09-28 13:27:30
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Make a Personal Portfolio Website */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23.  
  24. /* START CODE */
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <Arduino.h> // Arduino core
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32. void printSection(int idx);
  33. void initPortfolio();
  34.  
  35. /* Pin definitions for portfolio navigation */
  36. const int BUTTON_PIN = 2; // Next section button
  37. const int LED_PIN = 13;   // Built-in LED for feedback
  38.  
  39. const int NUM_SECTIONS = 4;
  40. const char* section_titles[NUM_SECTIONS] = {
  41.     "About Me",
  42.     "Projects",
  43.     "Skills",
  44.     "Contact"
  45. };
  46.  
  47. // state
  48. int currentSection = 0;
  49. bool buttonState = HIGH;
  50. bool lastButtonState = HIGH;
  51. unsigned long lastDebounceTime = 0;
  52. const unsigned long debounceDelay = 50; // milliseconds
  53.  
  54. /*
  55.   Prints the content for the given portfolio section on the Serial Monitor.
  56.   This emulates a simple textual portfolio view suitable for plain serial output.
  57. */
  58. void printSection(int idx){
  59.     Serial.println();
  60.     Serial.println("=================================");
  61.     Serial.print("Section: ");
  62.     Serial.println(section_titles[idx]);
  63.     Serial.println("---------------------------------");
  64.     switch(idx){
  65.         case 0:
  66.             Serial.println("Hello! I'm a passionate embedded systems developer.");
  67.             Serial.println("I create Arduino-based prototypes, wearable electronics, and IoT demos.");
  68.             Serial.println("Key focus: reliability, clean code, and compact hardware design.");
  69.             Serial.println("Experience: C/C++, AVR, debugging, and problem solving.");
  70.             break;
  71.         case 1:
  72.             Serial.println("Projects:");
  73.             Serial.println("- Sensor Logger: collects data from peripherals (demo)." );
  74.             Serial.println("- LED Matrix Demo: displays patterns on a small LED matrix.");
  75.             Serial.println("- Button Studio: interactive UI with a push button and serial output.");
  76.             break;
  77.         case 2:
  78.             Serial.println("Skills:");
  79.             Serial.println("C/C++, Arduino programming, Microcontroller peripherals, Debugging.");
  80.             Serial.println("Electronics, soldering, and PCB design fundamentals.");
  81.             break;
  82.         case 3:
  83.             Serial.println("Contact:");
  84.             Serial.println("Email: [email protected]");
  85.             Serial.println("Website: not provided in this demo");
  86.             break;
  87.         default:
  88.             Serial.println("Welcome to the personal portfolio simulation.");
  89.             break;
  90.     }
  91.     Serial.println("=================================");
  92.     Serial.println();
  93. }
  94.  
  95. void initPortfolio(){
  96.     // Initialize Serial and pins
  97.     Serial.begin(115200);
  98.     // Allow time for Serial Monitor to initialize
  99.     delay(2000);
  100.     pinMode(BUTTON_PIN, INPUT_PULLUP);
  101.     pinMode(LED_PIN, OUTPUT);
  102.     digitalWrite(LED_PIN, LOW);
  103.     // show initial section
  104.     currentSection = 0;
  105.     printSection(currentSection);
  106. }
  107.  
  108. void setup(void)
  109. {
  110.     // put your setup code here, to run once:
  111.     initPortfolio();
  112. }
  113.  
  114. void loop(void)
  115. {
  116.     // put your main code here, to run repeatedly:
  117.     int reading = digitalRead(BUTTON_PIN);
  118.     if (reading != lastButtonState) {
  119.         lastDebounceTime = millis();
  120.         lastButtonState = reading;
  121.     }
  122.     if ((millis() - lastDebounceTime) > debounceDelay) {
  123.         if (reading == LOW && buttonState == HIGH) {
  124.             // button pressed
  125.             buttonState = LOW;
  126.             currentSection = (currentSection + 1) % NUM_SECTIONS;
  127.             Serial.println();
  128.             digitalWrite(LED_PIN, HIGH);
  129.             delay(50);
  130.             digitalWrite(LED_PIN, LOW);
  131.             printSection(currentSection);
  132.         } else if (reading == HIGH) {
  133.             buttonState = HIGH;
  134.         }
  135.     }
  136.     // minimal loop delay to avoid flooding serial with prints
  137.     delay(10);
  138. }
  139.  
  140. /* END CODE */
  141.  
Advertisement
Add Comment
Please, Sign In to add comment