Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [mathematics]

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

0
votes
2answers
55 views

How to get average of 16bit ADC readings?

I have an Adafruit ADS1115 analog-to-digital converter, configured in single ended mode. I want to average over 3 sensor readings to increase the reading stability. //initialize variables int16_t ...
0
votes
1answer
123 views

Remove gravity from accelerometer of MPU-6050

I am currently working with MPU-6050. Now I want to minus gravity from my accelerometer's value as we minus the offset. Here is the code: #include <Wire.h> #include <MPU6050.h> //read as ...
0
votes
1answer
37 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 ...
1
vote
1answer
66 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 ...
0
votes
1answer
28 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/...
4
votes
2answers
323 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. ...
1
vote
2answers
65 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^...
-1
votes
1answer
72 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 ...
0
votes
1answer
111 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 ...
1
vote
1answer
41 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 ...
1
vote
0answers
36 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 ...
0
votes
2answers
121 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> ...
0
votes
1answer
228 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 ...
2
votes
2answers
10k 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 ...
8
votes
9answers
8k 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 ...
0
votes
1answer
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 ...
1
vote
2answers
6k 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 ...
0
votes
2answers
60 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 ...
1
vote
1answer
110 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 ...
1
vote
2answers
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 ...
0
votes
2answers
142 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 ...
9
votes
2answers
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() ...
-1
votes
2answers
85 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 ...
1
vote
1answer
205 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 ...
1
vote
0answers
484 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 = ...
1
vote
1answer
93 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 ...
0
votes
1answer
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 ...
2
votes
2answers
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 ...
-2
votes
2answers
6k 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....
1
vote
1answer
2k views

Trouble with large numbers

Probably something stupid, but I can't figure out how to work with these large numbers, then cast the result (which will be small) to an integer. I keep getting negative numbers, which I think means I'...
0
votes
1answer
568 views

Statistical Mode calculation in Arduino programme

How can I calculate the statistical mode from a set of values obtained from a distance sensor in an Arduino programme?