Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
23

Those aren't the only frequencies available for the PWM signals. However, they are the frequencies as determined by the applied prescaler (which you can readily change as detailed below). Each of the 3 pairs of PWM pins is tied to one timer, each of which has its own base frequency, as follows: Pins 5 and 6 are paired on timer0, with base frequency of ...


15

digitalWrite will set the specified pin to one of two states - HIGH/LOW, which equate to 5v (3.3v on some boards) and ground respectively. analogWrite can vary by the type of output used. If applied to a PWM pin - it will set the pin to a periodic high/low signal, where the percentage of the signal spent high is proportional to the value written. for ...


11

You basically have three options: Switch to an Arduino Due which has a built-in DAC which outputs a real voltage. Add an external DAC chip (such as the MCP4821/2) to create the voltage for you Use a low-pass filter (R-C network) on a PWM pin. Of the three options I usually use an MCP4822 since it gives the best results and doesn't cost as much as using a ...


9

This answer provides both Arduino specific knowledge and general electrical knowledge - both are necessary for a good solution (unfortunately). Summary To carry out Arduino analog to analog transfer: Use analogWrite(pin, value) on a valid digital pin (see below) Use analogRead(pin) on a valid analog input pin. Connect a series resistor between the two ...


8

I am not aware of the design considerations, but if you check the datasheet for the microcontroller on your Arduino, you will notice that PWM pins are grouped together and per group connected to a timer. The speed at which this timer is increased varies by the configured prescaler. If you change the prescaler for a certain timer, you change the PWM frequency ...


7

You would use a transistor. Something like this would work. In this case the Arduino controls a transistor to drive a brushless motor. Source: Arduino Cookbook: (https://www.inkling.com/read/arduino-cookbook-michael-margolis-2nd/chapter-8/figure-8-9) Update: For the sake of clarity I should point out that the TIP102 is the device to use for the 1A ...


7

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. Ohm's Law defines the relationship between Voltage (V), Current (I) and Resistance (R). R = V/I To find one unknown value (in your case R) you need to know ...


6

Since you already know how to hook up a pot and read it's value, it's quite simple. You already have it hooked up in a voltage divider configuration and are getting a 10 bit (0-1023) value using analogRead(), you just need to decide what to do with it. Assume potVal has the value of the pot.; if (potVal < 256) { // Pot is one quarter turn or less } ...


6

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 ...


6

First, do something simpler, and eliminate possible causes. Are you certain the NodeMCU's CPU is an 8bit PWM? If it were 9bits, it would read about 50% full scale, and 10bits would be about 25% of digitalWrite (which is what I think I can see on the photo). Swap the analogue meters around, and see if the difference is consistent with the pin, or consistent ...


6

At 5V, a 1 ohm resistor will try to sink 1A and far exceed the 40mA specs. Please use at least a 5/0.040=125 ohm resistor to protect your pin. And if you put the a capacitor between your resistor and ground, the RC circuit of the capacitor will smooth out the PWM into an analog voltage. Please try the suggested @russell answer with a 47K resistor and ...


6

analogWrite(): The analogWrite() method sets the value of a PWM output pin. The analogWrite() is on a scale of 0 - 255, such that analogWrite(255) requests a 100% duty cycle (always on), and analogWrite(127) is a 50% duty cycle (on half the time). Syntax: analogWrite(pin, val) Where, pin: the PWM output pin number. val: int value of duty cycle between ...


5

digitalWrite sets the output pin to either LOW or HIGH (where those voltages depend on the Vcc of the processor. For a Uno or Mega that would be 0V or 5V (or close to it). Here's a screenshot of digitalWrite (LOW): That is, the output pin is at 0V. Now for digitalWrite (HIGH): The output voltage is 5V. analogWrite really should have been named PWMwrite ...


5

No. The analogWrite(pin, val) function is reserved to PWM pins (D3, D5, D6, D9, D10, and D11 in Arduino Nano). Pins marked as "ANALOG IN" on the board can work either as analog input (to the Analog to Digital Converter), digital input, or digital output. It is worth to note that the Arduino Nano (and any other Arduino board I'm aware of) actually doesn't ...


5

First, let's consider the logic of your program. You have two groups of pins: 6 pins connected to the wires and 6 pins connected to the terminals. The first thing I would do is forget that these are two different groups. Consider you just have 12 pins that the user has to connect in a specific fashion. This way most “weird things” the user ...


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

Short answer: NO. It would fry your Arduino. Long answer: The current of Arduino pins is very limited (40mA max on UNO). If you need to draw 1A, then you need a transistor between the Arduino pin and your device. In such case, what you would normally do is: connect any Arduino logical pin to the transistor base (through a resistor), plug your device ...


4

You could have the LCD Arduino be an I2C master and all the weighing Arduinos be slaves. There's an example of master/slave communication and wiring here: https://www.arduino.cc/en/Tutorial/MasterReader. I2C supports up to 128 devices and the wiring is very simple.


4

According to the links you provide from the arduino.cc forum the question is more or less answered. If not that important, just avoid analogWrite(led,0) and make it analogWrite(led,1) if you still want that analogWrite(led,0), I've tested your code with the advice and it seems to work OK when changing the register manually: #include "wiring_private.h" int ...


4

I have a page about the analog comparator that has code: volatile boolean triggered; ISR (ANALOG_COMP_vect) { triggered = true; } void setup () { Serial.begin (115200); Serial.println ("Started."); ADCSRB = 0; // (Disable) ACME: Analog Comparator Multiplexer Enable ACSR = bit (ACI) // (Clear) Analog Comparator Interrupt Flag ...


4

On your code, you using analogRead but declaring the pin (A3) as output. Change it to pinMode(A3,INPUT); Aside from that, PWM is basically a digital output which changing (HIGH and LOW) at specified frequency. When the result you got is 0 0 1022 1021 0 1022 1021 0 0 1021 0 1021 1021 0 0 1021 0 0 1022 There's nothing wrong. 0 --> LOW, and 1021++ --> ...


4

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.


4

These are a lot of different questions. However, you can find most of the Arduino related answers in the official reference: Arduino reference Guide Some other answers: how to declare variables: e.g. int x; SerialWrite sends data to the serial port/UART, analogWrite and digitalWrite puts a voltage to a pin (simplified). AnalogWrite is normally used ...


4

Having both the analogRead() and analogWrite() in the same loop is perfectly fine. That would be be my preferred choice if only for one reason: less RAM consumption. If you split them in two loops, you have to store somewhere the readings of the four channels, either before or after mapping. If you keep them in the same loop, you don't need the pot_vals[] ...


3

A PWM frequency of 490Hz means a period of approximately 2.041ms. This allows a high period of 2ms, which is the maximum pulse length required by a large number of inexpensive servos. Obviously if your design uses no servos then this is not a consideration. Timer 0 itself is used for the various Arduino timing functions (delay(), millis(), etc.), so if you ...


3

Because IRremote uses timer 2 by default, and the PWM output on pin 11 is generated via OC2A. Either edit IRremoteInt.h to use timer 1, use a pin on timer 1 for PWM, or frob OCR2A directly instead.


3

If you have 4 pins available, you could use charlieplexing to selectively light up 12 led. Alternatively you could use some IC. You could use the one Greg suggested. Or you could use a shift-register. This requires only 2 or 3 pins, an will enable you to light up any one or more leds at the same time. Most have 8 outputs, but you can connect one to the ...


3

What arduino board is being used? I find that some webserver code takes up a lot of the SRAM and in an UNO this leaves very little space for other code. To save SRAM use the F macro on all the Serial.print statements that have quoted text. i.e: Serial.print("Some text you want output"); This takes up SRAM when running. 1 byte per letter and space. Serial....


3

Why does a Piezo Buzzer not require a PWM digital pin? Tone() uses the microcontroller's hardware timers to control the related code function but do not use the hardware PWM features. The timer can be assigned to any pin that has a digital output capability. Tone() sends a "rail to rail" square wave (50% duty cycle) to the selected pin Slightly more ...


3

analogWrite() on the Uno doesn't actually output an analog value. It outputs a PWM wave whose average is equivalent to that value. If you want to turn it into a true analog value then you need to put it through a low-pass filter in order to remove the components that make it a PWM wave instead.


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