PWM on an Oscilloscope

What PWM looks like on an oscilloscope. PWM is Pulse Width Modulation which can be used to change the brightness of an LED. This article and video shows PWM on an oscilloscope by using the Fade example sketch or program from the Arduino IDE. An LED and series resistor is connected to an Arduino Uno pin and the Arduino sketch continually adjusts the brightness of the LED by using PWM on the pin.

Video Showing PWM on an Oscilloscope

The following video shows PWM on an oscilloscope that is continually changing in order to change the brightness of the LED. Both the LED and Arduino Uno can be seen in the inset video. PicoScope is a PC based oscilloscope that connects to the USB port of a computer. Software running on the computer acts as the oscilloscope screen and control panel and can be seen in the video.

Hardware and Software for the PWM Demo

Find the Fade sketch in the Arduino IDE under File → Examples → 01.Basics → Fade from the top menu. The oscilloscope GND is connected to the Arduino GND. Pin 9 of the Arduino is used as the measurement point to measure the PWM waveform on the oscilloscope. The image below shows how the LED and series resistor are connected to the Arduino Uno. For more information, see the related Fade tutorial on the Arduino website.

Fade Arduino Example used to Show PWM on an Oscilloscope

Fade Arduino Example used to Show PWM on an Oscilloscope

How PWM Works

PWM changes the duty cycle of a square wave, which means that it changes the ratio of its on time to its off time. When the square wave is on, or at 5V, for longer than it is off, the LED will burn brighter. If the square wave is off, or at GND, for longer than it is on, the LED will burn dimmer.

Duty cycle of a PWM waveform is usually given as a percentage. If the duty cycle is 80%, then the on cycle of the square wave is on for 80% of the time and off for 20% of the time. A square wave with a 50% duty cycle has an equal on and off time.

 

Choosing an Arduino for Beginners

In this blog post we look at how beginners wanting to start with Arduino can choose an Arduino board. Help is provided for beginners choosing an Arduino. The difference between an Arduino and AVR ATmega microcontroller is also covered.

Choosing an Arduino for Beginners

The recommended Arduino for beginners is usually the Arduino Uno. On the Starting Electronics website, the article on choosing an Arduino for beginners provides more information on which Arduino to choose when starting to learn about Arduino and writing sketches.

Difference Between Arduino and AVR

Many Arduino beginners are confused about the difference between Arduino and AVR, or Arduino and ATmega. Difference between Arduino and ATmega328 explains what the ATmega328 microcontroller is and how it relates to the Arduino Uno. The article also explains more about the AVR microcontroller found on most Arduino boards.

Arduino Projects for Beginners

A list of easy to build Arduino projects for beginners and kids. These projects use easy to obtain components and can be built on an electronics breadboard. Suitable for use with an Arduino Uno or similar board.

Arduino projects for absolute beginners below list very easy projects for first time Arduino users. The section that follows lists projects for beginners who have learned the basics of how to use an Arduino.

Arduino Projects for Absolute Beginners

The simple projects below are suitable for absolute beginners with Arduino. They are part of a series of tutorials that introduce beginners to basic electronics. For beginners who have not yet used an electronics breadboard, see how to build a simple circuit on breadboard.

Arduino Projects for Beginners

The Arduino projects for beginners area on the Starting Electronics website has various projects for beginners such as:

Other projects suitable for beginners:

Programming Arduino

Beginners wanting to learn how to program Arduino can look at the Arduino programming course.

Arduino Ethernet Shield

For those wanting to know how to use the Arduino Ethernet shield as  a web server, the Arduino Ethernet shield web server tutorial explains all you need to know.

Other Arduino Resources

Also see the following areas on the Starting Electronics website:

  • Arduino Projects – various Arduino projects for beginners and more advanced users.
  • Arduino Tutorials –  interesting Arduino tutorials.
  • Arduino Articles – various articles and small projects such as how to battery power an Arduino, connecting a buzzer to Arduino, using Arduino to measure voltage and more.
  • Arduino Software – various Arduino software projects and information on installing Arduino software.

Another useful resource for projects is the Arduino tutorials page on the Arduino website.

Moving Light Display Arduino Project for Beginners

This easy Arduino project for beginners can be built on an electronic breadboard and uses only four LEDs and four series resistors to make a moving light display. The Arduino sketch for the project can be modified to change the rate at which the pattern on the LEDs is updated. The patterns to display on the LEDs can also be changed.

Moving Light Display Arduino Project for Beginners

Moving Light Display Arduino Project for Beginners

Details of this Arduino Project for Beginners

A breadboard is used to connect four LEDs with series resistors to an Arduino which can be an Arduino Uno or other Arduino. Four wire links connect the LEDs to four of the Arduino pins which are set as outputs. A common GND wire from the Arduino is connected to the breadboard which connects the other side of each of the series resistors to GND. This completes the circuit and enables the LEDs to be switched on by the sketch running on the Arduino.

Moving LED Arduino Project

Moving LED Arduino Project

The full project includes the circuit diagram, Arduino sketch code and instructions on how to modify the sketch to display different moving light LED patterns on the LEDs.

Other Arduino Beginner Project Resources

Those new to Arduino may be interested in the beginners electronics series of tutorials that includes an introduction to Arduino.

The same tutorial series includes ten Arduino projects for absolute beginners which is a sample of various Arduino built-in examples with instructions on how to build each project.

Arduino Internet Voltage Monitoring

Arduino Internet voltage monitoring can be achieved in several ways. The Arduino can be set up as a client or a server in order to display measured voltage on a web page. In this article an Arduino is set up as web server that hosts a web page stored on SD card. The web page displays the voltage measured on Arduino analog pin A2 in near real-time. The web server also interacts with ThingSpeak, a Internet of Things (IoT) service which logs voltage over time. Voltage is displayed on the hosted web page on a gauge and in a ThingSpeak generated graph or chart.

Arduino Internet Voltage Monitoring

Arduino Internet Voltage Monitoring

How Arduino Internet Voltage Monitoring Works in this Project

The Arduino web server hosts a web page that communicates with the Arduino using JavaScript / Ajax. This allows the voltage to be sent from the Arduino to the web page over the Ethernet connection to update the voltage in the gauge on the web page. A potentiometer is used to vary the voltage on Arduino pin A2 between 0 and 5 volts.

The raw value from the Arduino analog input is sent to the web page and converted to voltage in the JavaScript that runs on the page. The raw analog value is also displayed on the web page and will be between 0 and 1023.

After the voltage is calculated, it is sent to ThingSpeak by JavaScript. ThingSpeak logs the voltage and plots the graph of the voltage. The graph in the above image is created by copying graph code from ThingSpeak which then updates the graph with the data from the ThingSpeak server.

Voltage Update Timing

Voltage is measured by the Arduino and updated on the web page every 200ms. ThingSpeak only updates graph or chart values every 15s (fastest update speed), so the JavaScript code only sends updates to the ThingSpeak server every 20s.

Tutorial for the Project and Other Resources

A full tutorial is available which explains how to set up this project on your own Arduino.

Learn how ThingSpeak works and how to set up a channel to send data from an Arduino to an account on the ThingSpeak server — ThingSpeak is a free service.

Learn about measuring voltage with Arduino.

Arduino Ethernet shield tutorial explains how to set up an Arduino and Ethernet shield as a web server.