Day 11 & 12: Double Feature! Unveiling the Power of Arduino and a DIY Calculator.

Day 11 & 12: Double Feature! Unveiling the Power of Arduino and a DIY Calculator.

Hello, incredible LinkedIn community! I'm back with an exciting update on my 100 Days of Coding challenge. Days 11 and 12 have been a fascinating exploration of Arduino and a journey into building a basic calculator. Let's dive into the highlights! ??


Day 11: Battery LED Indicator with Arduino

I began Day 11 by crafting an Arduino program to create a Battery LED Indicator. ??? This code monitors a light sensor to simulate charging a battery and features an RGB LED that changes colors based on the battery's charge percentage. From glowing green for a full battery to blinking pink for a charge cycle, it's a visual delight! ??

Here's a sneak peek at the code:

// Function to display battery charge percentage and control LED color
void ShowBatteryPercentage() {
  // Calculate the charge percentage with a custom function
  percentFull = getBatteryPercentage();

  if(ticks % 1000 == 0) {
    // Print the elapsed time
    Serial.print((ticks/1000));
    Serial.print(" seconds  --->  charge at ");
    // Print the percent charge
    Serial.print(percentFull);
    // Print a percent character and line return
    Serial.println("%");
  
    // Set the LED color based on charge percentage
    if (percentFull >= 0 && percentFull <= 25) {
      RGB(125, 0, 0); // Red
    }
    else if (percentFull > 25 && percentFull <= 75) {
      RGB(255, 140, 0); // Orange
    }
    else if (percentFull > 75 && percentFull < 100) {
      RGB(0, 128, 0); // Green
    }
  }
  else {
    return;
  }
}        

Day 12: Crafting a DIY Calculator

Day 12 was all about challenging my coding skills with a DIY Calculator. ?? Armed with a 4x4 keypad, I designed an Arduino program to perform basic calculations. While it's still a work in progress (decimal calculations are on my to-do list), it's a fantastic step in the right direction. ??

Take a look at a snippet of the code:

char buttons[ROWS][COLS] = {
  {'1', '2', '3', '+'},
  {'4', '5', '6', '-'},
  {'7', '8', '9', '*'},
  {'0', '.', '=', '/'}
};

Keypad myPad = Keypad(makeKeymap(buttons), rowPins, colPins, ROWS, COLS);

void setup() {
  Serial.begin(9600);
  Serial.println("===============================");
  Serial.println("\tCalculator");
  Serial.println("===============================");
   // Print the button layout
  for (int i = 0; i < ROWS; i++) {
    for (int j = 0; j < COLS; j++) {
      Serial.print(buttons[i][j]);
      Serial.print('\t');
    }
    Serial.println();
  }
  Serial.println("===============================");
}

void loop() {
  char resultChar = myPad.getKey();

  if (resultChar) {
    Serial.print(resultChar);

    if (resultChar == '+' || resultChar == '-' || resultChar == '*' || resultChar == '/') {
      operatorChar = resultChar;
      num1 = userInput.toInt();
      userInput = ""; // Clear userInput for the next number input
    } else if (resultChar == '=') {
      num2 = userInput.toInt();
      calculateResult();
    } else if (resultChar != '.') {
      userInput.concat(resultChar);
    }
  }
}        

?? TikTok Adventures: Coding in Action

But that's not all! I've also started sharing my coding journey on TikTok, offering bite-sized glimpses of these exciting projects in action. ?? If you're curious about how these codes work or want to see them in real time, check out my TikTok videos!


?? Let's Connect:

I'm thrilled to be part of this vibrant coding community, and I invite you to join the conversation. Whether you have coding insights to share, questions to ask, or just want to say hello, feel free to drop a comment or DM. Together, we're unlocking the power of code! ??

Stay Pushing and Keeop Coding,

Antoine


#100DaysOfCode #Arduino #DIYCalculator #CodingCommunity #LearningThroughCode

要查看或添加评论,请登录

Antoine Gaton的更多文章

  • Day 10: A Dive into Linear Search

    Day 10: A Dive into Linear Search

    Hello, my wonderful #LinkedInCommunity! Today marks Day 10 in my 100 Days of Code journey, and I'm thrilled to share…

  • Day 9 - Let There Be Light

    Day 9 - Let There Be Light

    Hello #LinkedInCommunity! Antoine Gaton here, and I'm thrilled to bring you another exciting update from my 100 Days of…

    4 条评论
  • Day 8: Unleashing the Power of Control with Switches, LEDs, and TikTok?!

    Day 8: Unleashing the Power of Control with Switches, LEDs, and TikTok?!

    Starting back on my 100-day journey now that I am feeling better and tonight I'm done with Day 8. Today, I delved into…

  • Day Oh_No: Overcoming Setbacks

    Day Oh_No: Overcoming Setbacks

    Hello wonderful #LinkedInCommunity! Missed me? The past few days have been a rollercoaster of unexpected events…

    1 条评论
  • Day 7: Fueling My Learning Journey with Udemy

    Day 7: Fueling My Learning Journey with Udemy

    Hello, incredible #LinkedInCommunity! As week one comes to a close I find myself invested in my growth by embracing the…

  • Day 6: Unraveling More with Scrapy and Embracing Learning through Reading

    Day 6: Unraveling More with Scrapy and Embracing Learning through Reading

    Hello, fantastic #LinkedInCommunity! Another day done and here to bring you up to speed on Day 6 of my enthralling 100…

  • Day 5: Unleashing the Power of Web Scraping

    Day 5: Unleashing the Power of Web Scraping

    Hello again incredible #LinkedInCommunity! ?? Another day has come to an end and I am here to share my journey of Day 5…

  • Days 3 and 4: A Double Feature! Learning GUI Development with Tkinter

    Days 3 and 4: A Double Feature! Learning GUI Development with Tkinter

    Hello, amazing #LinkedInCommunity! ?? I'm thrilled to share an exciting update on my ongoing 100 Days of Coding…

  • Day 2: Embracing Challenges

    Day 2: Embracing Challenges

    Hello everyone! I know it's a late post but here I am excited and comitted to share the latest update on my 100 Days of…

  • Day 1: My To-Do List App!

    Day 1: My To-Do List App!

    For the first official day of my 100-Days Coding Challenge, there has been a lot of excitement, and posting, happening…

社区洞察

其他会员也浏览了