# Questions tagged [mathematics]

Mathematics is the study of quantity, structure, space, and change. Any math questions on this site should be programming related.

29 questions
22 views

### making power harmonics analyser which will measure the amplitudes of the fundamental and its multiples (like 50hz, 100hz, 150hz,200 hz,…) there are)

i have been intendng to make a power frequency harmonics analyser which will measure the amplitudes of the fundamental and its multiples (like 50hz, 100hz, 150hz,200 hz,...) there are examples for ...
51 views

### Unexpected negative values from abs() function inline with analogRead

When sampling from A0 with a 0-5V signal on an arduino micro with the code below I get some negative values. int sensor = 0; sensor = abs(analogRead(A0) - 512); Values: 77 25 -74 -58 46 113 -74 102 ...
27 views

### How to map integer values and round to a count of tens/thousands?

I'm mapping a potentiometer from 0-1023 to 1000-120000 (1 sec to 2 minutes) for a timer, like: maxDelay = map (pot2, 0, 1023, 1000, 120000); Both variables are integers. Now I would like to convert/...
308 views

### How are errors (not related to syntax) managed in arduino and in the AVR architecture in general?

I was just curious about how the AVR architecture manages errors that would cause a regular desktop program to crash. I'm talking about logical errors for example math problems that are undefined. ...
55 views

### Arduino pow() making 9's

I am having a temporary lapse of judgement, or not understanding how the power method works, but when I put 10 to the power of a number, it is that value -1. So: 10*10 = 100 Then I would assume, 10^...
70 views

### How to change the value within a variable using math? [closed]

I'm up to Lesson 11 in the TopTechBoy tutorial: https://www.youtube.com/watch?v=afurKLOqqSg Lesson 11 : http://www.toptechboy.com/arduino/lesson-11-arduino-circuit-to-dim-led-with-potentiometer/ I ...
84 views

### Is there any way to group variables like group.variable as you can in Java/Delphi

I'm writing a sketch which does some calculations on measured variables, and it's based on a similar program written in Java like c = A.Ux + B.Uz; Where A&B have various parameters Ux,Uy,Uz etc In ...
39 views

### Formula to calculate energy required to power an Arduino board

Given an Arduino board with the following specs: ATmega328 Arduino Nano AVR® ATmega MCU 8-Bit AVR Embedded Evaluation Board (link) What is the mathematical formula to calculate how much energy/power ...
30 views

### Zero-ing Compass | Following Magnet Strip Robot

So my problem is purely programming, I understand the problem but can't figure out what to do, Is there a library? should I create my own code for Zero-ing my compass so I don't have value from earth ...
109 views

### Elechouse Mo3 Shield Play Random Song

using this code to try and play a random song when someone walks by my distance sensor I get an error, the same song(track 0001) plays every time. Any advice? #include <SoftwareSerial.h> ...
205 views

### Why is this IIR Filter unstable on the Arduino Due?

I am using an Accelerometer (on the MPU6050) and connected it to the Arduino Due. In order to filter the signal I am using an IIR Filter with the following transfer function: H(z) = Y(z)/X(z) = B/A ...
8k views

### Rounding up and Down

My arduino is meisuring the tempature and gives values like: 28.58 Degrees Celcius. I would like to round this up to one decimal. I could make the variable one shorter by cutting the "8" off which ...
7k views

### Different ways (and the fastest) to compute sines (and cosines) in Arduino

I am using an Arduino Uno board to compute the angles of my system (robotic arm). The angles are actually 10 bit values (0 to 1023) from the ADC, using the full range of the ADC. I am only going to be ...
68 views

### Arduino randomly does incorrect addition

I've been trying to make an accelerometer calibration tool for my Arduino Nano and MPU6050, but the arduino seems to randomly do incorrect addition. If you look at the output of the console, it works ...
5k views

### Converting `millis()` to decimal seconds?

I would like to get my Arduino to print milliseconds as decimals of seconds. For example, instead of printing 10456, printing 10.456 I have tried to set a float value or millis, and dividing by 1000 ...
58 views

### How to calculate the time it takes before the water valve stops dispensing water in an Automatic Water level controller?

I am making a project about an automated water level controller using ultrasonic, potentiometer and Arduino board. I need a mathematical calculation on how it works. So here's a simple scenario: I ...
109 views

### It seems like the math of arduino is off

[SOLVED] By changing the offset for the incoming data into int16_t type there won't be any rounding errors and the values I'm getting are all back to zero in the sensor its base position This is my ...
1k views

### eval() function for Arduino?

I plan to do the following: void setup(){ String term = "12 + (2 * 5)"; int result = eval(term); // eval function (from Python) Serial.println(result); // expecting 22 } However there is no ...
139 views

### Arduino calculator: I'm struggling to write a sketch which parses inputted characters [closed]

I am attempting to make a calculator with arduino using a 16x2 Text-LCD and a 4x4 keypad. I've already programmed the part where the arduino board gets input from the keypad and displays characters on ...
2k views

### Is there a non-float alternative to pow()?

I've scoured the LANGUAGE REFERENCE in the Arduino web-site, and I can't find a non-Float equivalent to pow() I've got to be missing something big, but for the life of me, I'm stumped! I found pow() ...
84 views

### Performing 32-bit arithmetic on embedded device

I am at the moment working with an Arduino Uno, and am struggling to understand how I perform 32-bit arithmetic using it. The expression I have to calculate is this: √(2 n/a) in which n is an ...
197 views

### Help avoiding floating point math

I'm using a Texas Instruments DRV2605 haptic controller in my project to drive a LRA vibration motor. I would like to calculate the LRA rated voltage during run time using the formula below as ...
462 views

### Transforming from analog output to speed and acceleration with gy-61

Maybe it's a simple question but I'm unable to get what I need. My task is this: Get the acceleration and speed of each axis of the accelerometer. I thought of something like: const int VCCPin = ...
91 views

### LED bar graph script not working

I have LED bar graph on pins 2-11. Eventually I want to use a voltage divider to figure out the amount of voltage left in a power supply. Currently, this script should set the number of LEDs on the ...
36 views

### Unidentified constant value

im working on the following project kalman filter and im working to implement in arduino.. i read the entire code and i succesfully implemented it into arduino but i couldnt implement the following ...
3k views

### Avoiding float math to speed up arduino

I read and heard that the floating point math is much slower than int math. And I saw a converting process in here floath math to integer math So I want to to convert my floating math calculations ...
5k views

### Printing decimal numbers

I made simple sketch that generates three random numbers and then calculates the average of these three random numbers. It divides the total by 3 and then displays that average number with serial....