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
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.
Breadboard prototyping with an Atmel Xplained board is not as easy as using a board such as an Arduino which allows jumper wires to be connected directly from the board’s headers to the breadboard.
Easily Connecting to an Atmel Xplained Board for Breadboard Prototyping
One solution to easily connect to an Atmel Xplained board from a breadboard is to make up a ribbon cable with two female IDC connectors. This allows jumper wires to be inserted into the IDC connector which can then be connected to a breadboard or breadboard circuit. The image below shows how this is done.
Breadboard Prototyping with an Atmel Xplained Pro Board
The above arrangement of breadboard prototyping is used in the ASF ARM tutorial series that teaches how to use the Atmel Software Framework on ARM Cortex microcontrollers.
The board in the above image is a SAM4N Xplained Pro board.
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
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.
I wrote the article after being asked a question on how to control an LED from an HTML button on an Arduino hosted web page and a physical button connected to an Arduino pin.
The image below shows the final project.
Arduino LED Control from Web Page and Push Button Switch
An Arduino and Ethernet shield is used with a web page hosted on the micro SD card inserted into the Ethernet shield.
When the checkbox or button on the web page is clicked, the corresponding LED will switch on or off. When a push button is pressed, the corresponding LED will switch on or off and the state of the LED will be updated on the web page. Ajax is used to update the LED states on the web page so that there is no page refresh flicker.
Pressing the left push button causes the left LED to switch on and the checkbox on the page to get a check mark. Pushing the left push button again switches the LED off and the check is removed from the checkbox on the web page.
The button on the web page will initially display the text OFF as part of the button text. When the right push button is pressed, the LED will switch on and the HTML button text will be updated to display ON. Pressing the right push button again will switch the LED off and update the button text on the web page to display OFF again.
How can one measure or monitor voltages greater than 5V using an Arduino board? The easiest way is to use a voltage divider network — which consists of only two resistors as shown in the circuit diagram below.