Day 11 & 12: Double Feature! Unveiling the Power of Arduino and a DIY Calculator.
Antoine Gaton
Bilingual Software Engineer [English, Spanish] | Lead Developer @ Code Monkey Studios LLC | Full Stack Development, Mobile Development
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