Advertisement
KRITSADA

PWM Test for UNO R3B pin 2

Jul 29th, 2016
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. /*
  2.  Fading
  3.  
  4.  This example shows how to fade an LED using the analogWrite() function.
  5.  
  6.  The circuit:
  7.  * LED attached from digital pin 9 to ground.
  8.  
  9.  Created 1 Nov 2008
  10.  By David A. Mellis
  11.  modified 30 Aug 2011
  12.  By Tom Igoe
  13.  
  14.  http://arduino.cc/en/Tutorial/Fading
  15.  
  16.  This example code is in the public domain.
  17.  
  18.  */
  19.  
  20.  
  21. int ledPin = 2;    // LED connected to digital pin 9
  22.  
  23. void setup() {
  24.   // nothing happens in setup
  25. }
  26.  
  27. void loop() {
  28.   // fade in from min to max in increments of 5 points:
  29.   // ต้องใส่ 255 ก่อนการเรียกใช้งาน
  30.   analogWrite(ledPin, 255);
  31.   analogWrite(ledPin, 32); delay(200);
  32.   analogWrite(ledPin, 128); delay(200);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement