5

As CrossRoads says, there really isn't any such thing as analog output on an Arduino. (Any Arduino unless it has a built-in DAC.) It uses pulse-width modulation to vary the "duty cycle" of the output from 100% on to 0% on, which simulates an analog voltage. If you drive an LED with PWM (and the required current limiting resistor) your eyes will not see the ...


3

You can use the output of your regulator as the reference voltage for your analog readings. That way, no matter what the voltage you voltage divider for the thermistor uses, the "upper" voltage that the ADC uses is always the same as the thermistor's voltage. Simply connect the output of the regulator to the AREF pin, and set the ADC to use the external ...


3

The problem seems to be clear to you: for slow systems a pwm signal can be considered analog, but measuring at higher rates and without a filter reveales the digital nature behind pwm and all you see is either logic high (1023) or low (0). Possible solutions are: apply a filter in hardware (LC low-pass) apply a filter in software (e.g. by calculating a ...


3

The ESP8266 is an incredibly (electrically) noisy environment. Because you can't use anything except the internal voltage reference, which is in turn driven from the internal noisy power, you can't get anything even vaguely approaching stable readings. It is recommended to disable the WiFI completely ("Modem Sleep") when doing ADC readings to reduce noise....


3

On an ATmega2560, can ports have some pins used for analog inputs but others as digtial i/o? Yes, the ADC MUX controls the selection of the pin that is connected to the converter. This is independent of the digital pin control. Cheers! PS: See the Arduino core source code for further details on the ADC MUX control registers.


3

An electret microphone is like a resistor which changes its value according to the sound. To use it you must form a voltage divider with it, as if it were half of a potentiometer. Thus you add a resistor to +5V (which is already on the board). This means that when it is silent the voltage you get is the ratio of the resistor and the resistance of the ...


3

The PWM output pin does not vary voltage - it only outputs 0, or 5V. The amount of time that 5V is on, from 1/255 of about a 2mS period, to 255/255 of the same period, determines how bright the LED is perceived to be. You really need a current limit resistor in series with the LED to keep from burning out the uC output pin, or from burning up the LED.


3

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 can reliably get when you turn it to its stops? Use those in place of '0' and '1023' in your map() function. Improving the noise is only slightly more involved....


3

First, let me give a couple of suggestions on the programming style. There is no point in defining your own variables for accessing the hardware registers: the avr-libc does that for you, you just have to #include <avr/io.h>. Actually, you don't have to #include anything: the Arduino IDE automatically #includes Arduino.h, which in turn #includes avr/io....


2

With a 100 kΩ resistor to GND, it is not guaranteed that the value will be zero. If a (servo)motor is connected, it might get some noise. The pull down resistor can be any value, because it is possible to calculate the value of the photoresistor. There is an alternative solution. I think that all the analog pins of the Arduino Mega 2560 are digital pins as ...


2

As you can see in Arduino.h, the analogRead() has uint8_t as parameter. You can define them as byte or uint8_t and you don't have to use the sizeof(). The type of A0 is defined in the file pins_arduino.h: #define PIN_A0 (14) static const uint8_t A0 = PIN_A0; Nevertheless, what you have with integers is 100% okay as well. When you don't have a Arduino ...


2

Take the regulator output to another analog input. Read that just before you read the thermistor. Use that voltage in your voltage divider calculation. The buzzer activity should be the same (ideally, off) during both readings.


2

You can't magic more resolution out of thin air (well, you can, but it slows down your sampling - you would "oversample" and average a number of sequential samples). Instead you need to boost your signal before it gets to the ADC using an op-amp. The simplest circuit (which also inverts the signal, but you don't really care about that I suspect) is: ...


2

If you want to measure a pin (i.e. defined as input pin, either digital or analog), you have to use a pull up or pull down resistor (either internal or external depending on what the MCU GPIOs have). This resistor makes sure in case there is nothing attached, that the (mostly high ohm) resistor will make sure the nonconnected pin will either give a LOW or ...


2

There are many ways to remove noise, below are some ways: Only change the value when it differs enough. Assume the range is 0-1023. Than only change the value if the input value differs more than a constant value (like 5 or 10, experiment with this to find a good value for your pot meter). Another way is to use the average of the last x readings, You can ...


2

The 9V wall adapter is in most cases a switched power regulator with a high frequency. That's like a radio transmitter direct beside the wire. So there is nothing mystical, when the smooth USB Voltage does not show problems but the "radio transmitter" does. There are two ways the power supply can impact: over radio wave or as ripples over the regulated ...


2

What you are looking for is called the Thévenin equivalent source. For the schematic you are showing, and assuming you can neglect the output resistance of the battery itself, the output resistance of the voltage divider is the same as the two resistors in parallel. If you want the maximum allowed resistance (minimum current) you have then to solve: 1/R1 + ...


1

The AOUT pin of that device is no more than an amplified audio signal. It is AC coupled, and that means that it is a small signal varying around 0v. It is not suitable for feeding directly into an ADC. The AC coupling capacitor will be being charged up by the DC offset it is there to remove, and the lack of any drain on that capacitor while the ADC is not ...


1

Note that the Arduino function "map" is really this: long map(long x, long in_min, long in_max, long out_min, long out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } ...so, if you pass a "minimum from" value which is less than the actual value you are mapping from you will get a negative number given your "minimum out" ...


1

I solved the problem by adding 3 capacitors: 220uF on the Arduino power supply. 100uF on TL431 output. 1uF on A0 input. I also increased the sampling rate to 128 times (and removed the delay). Here's the result, as accurate as my multimeter: There's still 2mV difference in higher voltages which is because of my 2.5V reference voltage and Arduino ADC ...


1

Doing that calculation from EEPROM is exactly the same as doing it from any other source. You have a count so you know where the EEPROM data ends. You know where the EEPROM data starts. You know how to read a number out of EEPROM. What is stopping you from creating a for loop to read the i'th address from EEPROM and add all those numbers together just ...


1

I guess that you are showing the voltages there directly calculated from analogRead() and that you connected the AC voltage directly to the analog input (and it's ground with the Arduino's ground). The reference for every communication/voltage measurement/digital input is ground. Naturally the Arduino can only measure voltages inside of it's own supplied ...


1

You have nothing in your setup loop. You need to set up all the inputs as inputs. You setup() should look like this: void setup() { Serial.begin(9600); for (int i = 0; i < 5; i++); { pinMode(input[i], INPUT); } } The code cycles through your array "input", setting all the pins as inputs. Try that.


1

Your approach is globally sound. However, the code that measures the input frequency is very time sensitive. Thus, you have to make sure this piece of code is never delayed by anything else. This means that everything in your sketch should be fast and non-blocking. I see a few instances of blocking behaviour you should get rid of: the call to delay() and ...


1

OK, I am unable to leave a comment (< 50) so... Use this link to learn about the AREF pin on the Arduino, this may not be your problem but it is good to know about anyway: what is arduino adc reference? Your pot MAY be broken. Measure the resistance of the pot with an ohm meter, from the center pin to either of the side pins. Verify when you turn it the ...


1

Yes that is possible, you can even use as many Arduino's as you want and send the information to one 'master' Arduino to process the data. What you need is a way to communicate between them. Depending on distance, speed and reliability, you can chose for Serial, I2C, SPI or more 'exotic' solutions like CAN(bus), RS485 or even wireless methods (with nRF ...


1

Yes of course you can. Better to use digitalRead() than analogRead() however. You just need to tie the grounds of the 2 Arduinos together, and set up the pin on the Arduino you want to sense the input as INPUT or INPUT_PULLUP. Then do a digitalRead on the pin. It will return LOW if the other Arduino is setting the pin LOW, and HIGH if the other Arduino is ...


1

The general idea of your code looks OK, but consider using a hardware timer rather than the for loop for data acquisition. The sampling rate will be much more accurate and uniform because you eliminate (possibly cumulative) errors in timing. See this post for an example. Do you know how the FFT.MajorPeak function works? If it simply finds the frequency ...


1

The reason this doesn't work is that PB5 is pulled high (as it's used as -RESET pin on the board). The code can be rewritten to use only one ADC pin though.


1

Your calculation will be correct for num_analog_pins, however it's convention to use the type of the array like so int num_analog_pins = sizeof(analog_pins) / sizeof(int); As @Jot noted, you'd save much space by declaring your array using uint8_t like so uint8_t analog_pins[] = {A0, A1, A2, A3}; uint8_t num_analog_pins = sizeof(analog_pins) / sizeof(...


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