5% OFF Over $19, Code: Elephant5; 10% OFF Over $59, Code: Elephant10



ARDUBLOCK Project 2: PWM Regulating Light Brightness

Posted by Fiona Su on

Introduction:
In this project, we should connect signal port of LED module to PWM port, and use graphical programming to control it to produce various PWM signals. So the brightness of LED changes, with effect of breathing LED.
Materials Required:

  • 1. KEYESTUDIO UNO Control Board *1
  • 2. V5 Sensor Shield*1
  • 3. Piranha LED*1
  • 4. Female to Female Dupont Line*3

Connection Diagram:

thumb

thumb

In this project, we will use PWM to control an LED, slowly lighting it up and then dimming it, and circulate it like this over and over again. Still, connect high bright LED module to pin 10 of digital IO port.

thumb

Click “download to Arduino” to see the codes in IDE interface.
Sample Code:

*****************************************************************************
int _ABVAR_1_brightness = 0 ;

void setup()
{
  pinMode( 10 , OUTPUT);
}

void loop()
{
  while ( ( ( _ABVAR_1_brightness ) < ( 255 ) ) )
  {
    _ABVAR_1_brightness = ( _ABVAR_1_brightness + 1 ) ;
    analogWrite(10 , _ABVAR_1_brightness);
    delay( 5 );
  }

  while ( ( ( _ABVAR_1_brightness ) > ( 0 ) ) )
  {
    _ABVAR_1_brightness = ( _ABVAR_1_brightness - 1 ) ;
    analogWrite(10 , _ABVAR_1_brightness);
    delay( 5 );
  }

  delay( 500 );
}
*******************************************************************************

Result:
That’s how we use graphical programming to gradually light the LED up and dim it. Just like the LED is taking a breath. That’s why we vividly call it breathing LED.

All Projects

Buy it >> ARDUBLOCK Graphical Programming Starter Kit for Arduino

 

0 comments

Leave a comment

Please note, comments must be approved before they are published