Skip to main content
Share Your Experience: Take the 2024 Developer Survey
10 votes

How do you handle sensor drift?

ok, once I got the idea I would need to do it in code, it became simpler to solve. In looking around the terms of quantization, the term thresh-holding came up, and I realized how to solve the problem....
j0h's user avatar
  • 892
8 votes

A question about resistance measurement with arduino

If you know Ohm's Law (which you should) and you realise that the ADC measures voltage, you should be able to work it out from there. But I will go into minute detail for you to ensure you understand. ...
Majenko's user avatar
  • 105k
6 votes

Why can't I use just the digital pins and a ground to use a potentiometer?

A potentiometer is an analog device, meaning it communicates its position by varying the voltage rather than sending discrete ones and zeros. If a linear potentiometer is turned half way then the ...
Joel's user avatar
  • 523
6 votes
Accepted

Powering potientiometer/button with a digital pin

You can likely use an I/O pin as an output to "power" fairly high-impedance devices such as pullup resistors for buttons, or even potentiometers of moderate to high total resistance. A ...
Chris Stratton's user avatar
6 votes

How do you handle sensor drift?

Remove the analog component from your device. Use a rotary encoder. It will sense the knob rotation digitally. One huge advantage is that you can easily select the sensitivity of the input. One click ...
jsotola's user avatar
  • 1,515
5 votes
Accepted

Getting negative results from calculations

analogRead() returns a number from 0 to 1023, and you want to convert that to a range from 0 to 255? One easy way would be to simply divide the reading by 4. On a more general note, given that the ...
John Burger's user avatar
  • 1,875
5 votes

How do you handle sensor drift?

Some methods for "dealing" with the noise: Take multiple samples. Calculate the average ("mean"). Discard the decimal. This is "oversampling" along with resolution ...
Majenko's user avatar
  • 105k
4 votes
Accepted

Multiplexing potentiometers

There are a few ways of doing what you want. One would be to use an analog multiplexer as in this answer: Expanding analog inputs to the Arduino Another would be to use digital I/O pins to control ...
Majenko's user avatar
  • 105k
4 votes
Accepted

Maximum potentiometer resistance

There is a lengthy discussion about this on the Arduino Forum. As I understand it, the input impedance is only important if you are sampling a rapidly varying signal, as it takes a finite time to ...
Nick Gammon's user avatar
  • 38.3k
4 votes

Analog output doesn't work for just 2 LEDs [Arduino Mega]

Analog pins an only read analog values, not write them. analogWrite() is a deceptive name. It should really be PWMWrite() since all it does is PWM. And that, of course, needs PWM pins.
Majenko's user avatar
  • 105k
4 votes

What difference makes resistance of thermistors?

Skip to the end to get the easy answer! Your choice of thermistor and bias resistor values depends on the following: 1. How much current do you want to spend? 2. How do you want the thermistor ...
John Taylor's user avatar
4 votes
Accepted

Digital selection for gain control not working instead showing 0

pinMode( K1, INPUT ); with if(K1 == LOW && K2 == LOW) makes no sense. K1 is a pin number. LOW is a macro for 0 (HIGH for 1). You are comparing a static pin number against a static ...
Maximilian Gerhardt's user avatar
4 votes

Potentiometer reading out letters

You need to use Serial.print instead of Serial.write.
Gerben's user avatar
  • 11.3k
4 votes
Accepted

Avoid 1-LSB noise on ADC readings

When you reduce the resolution from 10 bits to 7 bits, every possible output corresponds to an interval of inputs. If you add some hysteresis, then those intervals should overlap. Below is a ...
Edgar Bonet's user avatar
  • 43.3k
3 votes

Why can't I use just the digital pins and a ground to use a potentiometer?

I had hooked up the positive of led to a digital input of the arduino and negative to the ground of the board. You shouldn't have done that. It damages both the LED and the Arduino. The care and ...
Nick Gammon's user avatar
  • 38.3k
3 votes

Use interrupts with analog pins in arduino or another possible solution?

You are looking for the bad solution for a simple problem. As Ignacio Vazquez-Abrams puts it, the problem is you using delay(). The simplest solution is to manage the timings with millis(). See the ...
Edgar Bonet's user avatar
  • 43.3k
3 votes
Accepted

Use interrupts with analog pins in arduino or another possible solution?

Avoid delay. Very simplistic alternative: unsigned long lastLedToggleTime; unsigned long currentLedToggleInterval; void loop() { ... unsigned long now = millis(); if ( (now - ...
JimmyB's user avatar
  • 155
3 votes

Wiring a potentiometer to control a 9V battery powering 2 LEDs in series

Yes, Arduino is a 5V microcontroller, meaning it can directly control 5V circuits only. You might incur in problems also trying to deal with 3.3V circuits, even if Arduino is pretty friendly to 3.3V ...
Roberto Lo Giacco's user avatar
3 votes
Accepted

Potentiometer with switch wiring question. Not reading correctly

From your description of switch wiring, it sounds like you have one of the switch leads attached to +5 V and the other switch lead to an input. As noted in comments and answers to “Why all unset pins ...
James Waldby - jwpat7's user avatar
3 votes

What difference makes resistance of thermistors?

The standard way to measure a resistive sensor is to make a voltage divider with the sensor and a fixed resistance between Vcc and GND, like this: Vcc │ Rb │ ├─── analog input │ Rx │ GND ...
Edgar Bonet's user avatar
  • 43.3k
3 votes
Accepted

Ribbon sensor resistance slowly drops when released

The Adafruit website says this: There is a nominal 10K resistance across the two outer leads. The middle pin resistance with respect to either of the outer pins changes depending on where on the ...
VE7JRO's user avatar
  • 2,559
3 votes
Accepted

What is the lowest resistance pot that is useful with an analog input?

Assuming you wired it correctly (ie. you put the wiper to the analog input) your first setup looked like this: Your big problem here is the current flow through the pot. Using Ohms Law the current ...
Nick Gammon's user avatar
  • 38.3k
3 votes

Potentiometer reading out letters

write() is a function for binary data. I you want to print the number as text, use print() or println(). Serial.println(potentioVal);
Juraj's user avatar
  • 18k
3 votes

How to regulate a led on-board?

Pin 13, which is the on-board LED, is not a pwm pin. So you cannot Control the brightness of that LED on-board. You will have to use another LED and a PWM pin.
Kevin Coleman's user avatar
3 votes
Accepted

Trying to use an LCD 1602 to display, but I don't have a 10 KOhm potentiometer

Yes. All a potentiometer is, is two resistors end to end. The "wiper" is the join between the two resistors. It doesn't matter too much what value potentiometer (and hence what value resistors) you ...
Majenko's user avatar
  • 105k
3 votes
Accepted

I2C potentiometer mess

The registers are listed in table 4-1. Clearly enough. The command byte format is shown in chapter 6. That command byte includes the operation and the register number, as well as upper bits for ...
Majenko's user avatar
  • 105k
3 votes

PWM Control, How to stop LED from Flickering?

Your code doesn't make much sense. You set the LED to 2 different brightness values that don't have anything to do with each other: The pot brightness and the button-based brightness. You only ...
Duncan C's user avatar
  • 5,702
3 votes
Accepted

Arduino UNO - Fluctuation of inputs and outputs

You seem to be experiencing cross-talk between the analog channels. This happens because all the channels are funneled by an analog multiplexer into the same sample-and-hold capacitor. If the source ...
Edgar Bonet's user avatar
  • 43.3k
3 votes

ignoring potentiometer value variations

You have two issues going on - noise pickup, and a potentiometer with imprecise stops at one or both ends. The pot is the easiest to fix: What are the lowest low reading and highest high reading you ...
JRobert's user avatar
  • 15.3k
3 votes

How to use a potentiometer to access data within a 2 dimensional array?

Using the Arduino map() function seems a reasonable approach to this, however you have a problem with the indexing. if (numScales == 3); { Is probably not what you want, as that condition can never ...
Chris Stratton's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible