<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[calc software is not working]]></title><description><![CDATA[<p dir="auto">i made this code,</p>
<pre><code>#include &lt;Arduino.h&gt;
#include &lt;M5StickCPlus.h&gt;
#include &lt;math.h&gt;

// Define button pins (adjust if needed)
#define BUTTON_A_PIN 35
#define BUTTON_B_PIN 36

// Calculator variables
double operand1 = 0;
double operand2 = 0;
char operation = ' ';
bool newNumber = true;

void setup() {
  M5.begin();
  M5.Lcd.setRotation(3); // Adjust rotation as needed
  M5.Lcd.fillScreen(BLACK);
  M5.Lcd.setTextColor(WHITE);
  M5.Lcd.setTextSize(2);
  pinMode(BUTTON_A_PIN, INPUT_PULLUP);
  pinMode(BUTTON_B_PIN, INPUT_PULLUP);
  displayScreen();
}

void displayScreen() {
  M5.Lcd.fillRect(0, 0, 240, 135, BLACK); // Clear the screen
  M5.Lcd.setCursor(0, 0);
  M5.Lcd.print("Value: ");
  if (operation != ' ') {
    M5.Lcd.print(operand1);
    M5.Lcd.print(operation);
    M5.Lcd.print(operand2);
  } else {
    M5.Lcd.print(operand1);
  }
}

void calculate() {
  switch (operation) {
    case '+':
      operand1 = operand1 + operand2;
      break;
    case '-':
      operand1 = operand1 - operand2;
      break;
    case '*':
      operand1 = operand1 * operand2;
      break;
    case '/':
      if (operand2 == 0) {
        M5.Lcd.setCursor(0, 20);
        M5.Lcd.print("Division by 0!");
        delay(2000);
        operand1 = 0;
        operation = ' ';
        return;
      }
      operand1 = operand1 / operand2;
      break;
    case 's': // Square Root
        operand1 = sqrt(operand1);
        break;
    case '^': // Power
        operand1 = pow(operand1, operand2);
        break;
    default:
      break;
  }
  operation = ' ';
  operand2 = 0;
  newNumber = true;
}

void loop() {
  M5.update();
  if (M5.BtnA.wasPressed()) {
    if (newNumber) {
      operand1 = operand1 * 10 + 1;
    } else {
      operand2 = operand2 * 10 + 1;
    }
    displayScreen();
  }

  if (M5.BtnB.wasPressed()) {
      if (operation == ' ') {
        operation = '+';
        newNumber = false;
      } else if (operation == '+') {
        operation = '-';
        newNumber = false;
      }
      else if (operation == '-') {
        operation = '*';
        newNumber = false;
      }
      else if (operation == '*') {
        operation = '/';
        newNumber = false;
      }
      else if (operation == '/'){
        operation = 's'; // Square Root
        newNumber = false;
      }
      else if (operation == 's'){
        operation = '^'; // Power
        newNumber = false;
      }
      else if (operation == '^') {
        calculate();
      }
      displayScreen();

  }
  if (M5.BtnC.wasPressed()){
    operand1=0;
    operand2=0;
    operation=' ';
    newNumber=true;
    displayScreen();
  }
}
</code></pre>
<p dir="auto">but for some reason, it did not work at all. please help me.</p>
]]></description><link>https://community.m5stack.com/topic/7224/calc-software-is-not-working</link><generator>RSS for Node</generator><lastBuildDate>Sun, 17 May 2026 10:54:22 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/7224.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 21 Jan 2025 03:53:35 GMT</pubDate><ttl>60</ttl></channel></rss>