7

I helped someone with a similar question. The results are in my github repo at https://github.com/linhartr22/count. This example uses the PWM library and includes a reference to the article I used to learn how to convert audio files to MP3 with proper settings for the PWM libary. It plays audio through an 8 ohm speaker or a piezo buzzer connected directly to ...


4

Both the ESP8266 and the Arduino have UART serial interfaces. This is by far the simplest method of communicating between two boards. Connect the TX of the Arduino, through a voltage divider to drop it to 3.3V, to the RX of the ESP8266. Connect the grounds together. That's all you need. Yes, you can connect the TX of the ESP8266 to the RX of the Arduino but ...


4

The PCMAudio example shows how to play audio data via PWM. Note that you will need to access the MCU at a low level in order to do this; the Arduino libraries don't provide enough control over the hardware.


4

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

First, I have to say I am not familiar with the Zero hardware, so I am answering in quite general terms. Hopefully you will also get some answers with hardware-specific information. That being said, here are my first thoughts: Your approach seems reasonable to me, but you are too optimistic regarding the achievable sampling rate. DACs are usually fast. It's ...


3

Arduino DUE has a built-in DAC (has two in fact) and so you can do arbitrary function generation fairly easily by just going over some arbitrary table (that sampled the function) and output that with analogWrite to the DAC channel[s]; details in this arduino.cc tutorial. They only show sine/triangle/square waves there, but if you look at Waveforms.h at the ...


3

You can generate arbitrary waveforms using either the built-in PWM and a low-pass filter or an external DAC. You won't get more than 16-bits in PWM ( or AFAIK non-audio DAC with arduino libraries ), so your e^N function will be below your resolution for most of the cycle. Alternatively, generate a saw-tooth and use an op-amp exponential function


3

They are incredibly useful. They are essentially how you deal with the analog world. For example, I'm using two of them in a project here that uses a frequency generator and a couple of op-amps to create a VSWR bridge, allowing me to figure out the resonant frequencies of an antenna... The parts with the arduino cost less than $20... Buying something that ...


3

I'd like to output something simple like a digital AC voltage to the DAC and have it convert it, but as I understand it from here, I am just using the digitalWritecommand which is basically binary. How do transfer something more complicated to have the DAC convert it? SPI is a communication protocol. It uses digital signals, coupled with time, to transfer ...


3

float pwmDelta=((255/100)*(highLim-lowLim))/(tLim); That line should be: float pwmDelta=((255.0/100)*(highLim-lowLim))/(tLim); Adding the .0 tells the compiler to do that math using floats and you get 2.55. Without it the math is done with int and the result is 1 which isn't what you want. analogWrite(motor1, 53.55); Just write 54. analogWrite only ...


3

Classical +/- 1 problem If you do this calculation by hand uint16_t temp = int(voltage * pow(2, 8) / max_VOLT); you will get temp=256 and this is a value you can not convert with a 8 bit DAC. Try uint16_t temp = int(voltage * (pow(2, 8)-1) / max_VOLT); instead. (or event better for a ┬ÁC uint16_t temp = (uint16_t) (voltage * (255 / max_VOLT));)


3

There's an easy way to achieve reading multiple pushbuttons using single analog input. All you need to do is create some voltage dividers at different voltages which can be read using analogRead. The last resistor,R6, in the diagram below ensures that the pin reads 0 when no push-button is pressed (i.e pull-down resistor). In the diagram below, connect Vcc ...


2

Yes, you can - see http://www.instructables.com/id/Simple-Wav-Player-Using-Arduino/ Space is quite limited, unless you use an SD card.


2

If you want to use PWM in place of a DAC, the normal thing to do is to use some kind of analog low-pass filter. However, many people skip the filter when the signal is meant for some system that inherently acts as a low-pass. Example: dimming an LED, where the human eye is the filter. In your case, since your plant looks like a third order low-pass filter ...


2

DACs have many uses outside the realm of audio. Basically a DAC is used any time you want to generate a specific voltage for whatever you need it for - that could be to generate a waveform for audio, or it could be for any other situation, such as: Setting an offset point for an op-amp Creating a comparison voltage for comparing another signal to ...


2

Yes, perfectly possible. Just provide two separate CS pins to select between the two devices.


2

I see two possible options for achieving what you want: Voltage divider This is the solution proposed by William Roy: you make a voltage divider circuit and check whether it gives a voltage above the threshold of the digital input. For example: +5V ---+ | R | +--- digital input | LDR | GND ---+ There are a ...


2

Seeing all on for 128+ and all off for 127- is indicative that you are using a pin that can't do PWM. If you use a non-PWM pin with analogWrite it goes "Is this less than 128? Yes? Then I will turn it off. Otherwise I will turn it on.". case NOT_ON_TIMER: default: if (val < 128) { digitalWrite(pin, LOW); } else { digitalWrite(pin,...


2

You can use the analog pins. I prefer {A0, A1, A2, A3} in the code instead of {14, 15, 16, 17}. That makes it easier to check if you connected the wires to the right pins. Don't use pin 13 for an input with the Arduino Nano. An LED is connected to that pin. You can use that pin as an output for something else.


2

Let's do some maths... 16MHz master clock / 2 = 8MHz SPI clock 2 transactions = 16 bits (not 12!) 8,000,000 / 16 = 500,000 2 transitions per cycle 2 channels 2 + 2 = 4 500,000 / 4 = 125,000Hz So in a perfect world you could expect 125kHz from the DAC. However the world is far from perfect. Let's look at what it's actually doing when you use output2(): ...


2

You just have to add the waveforms. For example, if you want to play pure tones (the simplest and most boring timbre), you generate a sine wave for each of them and add them together: struct Note { float frequency; float phase; bool is_active; } notes[MAX_NOTES]; void output_sample() { static uint32_t previous_time; uint32_t now = ...


1

It would seem the problem lies here: // Set Register to all zeros since Vref // will be set to internal voltge and // analog pin A0 is used. ADMUX = 0x00; According to the datasheet, the bits REFS[1:0] of the ADMUX register select the voltage reference as: 00: AREF, Internal V ref turned off 01: AVCC with external capacitor at AREF pin 10: Reserved 11: ...


1

These ADC's use the SPI protocol. Luckily the Arduino has one onboard. With each ADC you get 8 channels (thus inputs). Since you need more than one SPI device (ADC in your case). With SPI you can chain multiple SPI devices to your SPI port of the Arduino. To select which is active you use the Chip/Slave select signal. This is a separate GPIO you can define ...


1

First off you need to convert your signal's units from analog -> voltage. Do this by using the following equation. I've modified your code so you can copy and paste it into your IDE. float volts = analogRead(A3) * ( 5.0 / 1024.0) ; Hope this helps! Good luck!


1

There's two basic solutions, both of which require the addition of an external chip: Use an analog multiplexer to select the different devices to connect to the ADC input Use an external (I2C or SPI) ADC chip. These can give you higher resolutions than the internal ADC and many more inputs (depending on the chip you choose). My recommended solution would ...


1

Try commenting out the serial in your sketch. In my experience serial communication takes time, and I assume you have a short window where the voltage peaks at more than a volt. Or initialize the serial with a stupidly high baud rate. Edit: even better, you could try this for a faster response time: void setup(){ digitalWrite(13,0); pinMode(13, OUTPUT); ...


1

They don't connect a resistor as such, but analog input pins do have an impedance which can affect your readings. If your output impedance (the resistance of your resistors) is within about a tenth of the impedance of the input pin then you will (and have) noticed skewing of the results. This is normal. The input impedance is somewhere in the region of ...


1

Yes, you can use LDRs(photocells) as an indirect digital input. You can design a voltage divider circuit, which incorporates your LDR and gives LOW or HIGH digital readings based on your pre-calibrated threshold light values. Your voltage divider circuit must reach a specific voltage for your wanted light threshold to give you a HIGH reading. The ...


1

The MCP3008 is an SPI device. You connect it to the SPI pins of your Arduino. Then you can read 8 analog channels through it. It requires 4 pins: MISO, MOSI, SCK and a chip select pin.


1

A more generic version of your approach would be like this. Set the output pin - don't hardwire the pin number but instead use a macro for it. Delay for it's duty cycles. Clear the output pin. Delay for period - duty cycles used in step 2 above. You can put that in a routine and call it. With that said the routine has limited use in a real application as ...


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