67 lines
1.6 KiB
C++
67 lines
1.6 KiB
C++
/*
|
|
fade.ino
|
|
2013 Copyright (c) Seeed Technology Inc. All right reserved.
|
|
|
|
Author:Loovee
|
|
2013-10-15
|
|
|
|
Grove - Serial LCD RGB Backlight demo.
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with this library; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#include <Wire.h>
|
|
#include "rgb_lcd.h"
|
|
|
|
rgb_lcd lcd;
|
|
|
|
void setup()
|
|
{
|
|
// set up the LCD's number of columns and rows:
|
|
lcd.begin(16, 2);
|
|
// Print a message to the LCD.
|
|
lcd.print("fade demo");
|
|
|
|
}
|
|
|
|
void breath(unsigned char color)
|
|
{
|
|
|
|
for(int i=0; i<255; i++)
|
|
{
|
|
lcd.setPWM(color, i);
|
|
delay(5);
|
|
}
|
|
|
|
delay(500);
|
|
for(int i=254; i>=0; i--)
|
|
{
|
|
lcd.setPWM(color, i);
|
|
delay(5);
|
|
}
|
|
|
|
delay(500);
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
breath(REG_RED);
|
|
breath(REG_GREEN);
|
|
breath(REG_BLUE);
|
|
}
|
|
|
|
/*********************************************************************************************************
|
|
END FILE
|
|
*********************************************************************************************************/ |