Last active
December 10, 2015 01:58
-
-
Save fukubaya/4363134 to your computer and use it in GitHub Desktop.
control full color LED (EP204K-35G1R1B1-CA) with the Arduino compatible board GR-SAKURA (http://japan.renesas.com/products/promotion/gr/index.jsp).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* gr_sketch.ino | |
* | |
* Created by FUKUBAYASHI Yuichiro on 2012/12/19 | |
* Copyright (c) 2012, FUKUBAYASHI Yuichiro | |
* | |
* last update: <2012/12/23 21:00:36> | |
*/ | |
#include <rxduino.h> | |
#define INTERVAL 1000 | |
#define PIN_5V PIN_P33 | |
#define PIN_R PIN_P21 | |
#define PIN_G PIN_P22 | |
#define PIN_B PIN_P20 | |
unsigned int PINS[] = {PIN_R, PIN_G, PIN_B}; | |
void LED_OFF (){ | |
for(int i=0; i<3; i++){ | |
digitalWrite(PINS[i], HIGH); | |
} | |
} | |
void RED_ON(){ | |
digitalWrite(PIN_R, LOW); | |
digitalWrite(PIN_G, HIGH); | |
digitalWrite(PIN_B, HIGH); | |
} | |
void YELLOW_ON(){ | |
digitalWrite(PIN_R, LOW); | |
digitalWrite(PIN_G, LOW); | |
digitalWrite(PIN_B, HIGH); | |
} | |
void PINK_ON(){ | |
digitalWrite(PIN_R, LOW); | |
digitalWrite(PIN_G, HIGH); | |
analogWrite(PIN_B, (int) 255*(100-14)/100); | |
} | |
void GREEN_ON(){ | |
digitalWrite(PIN_R, HIGH); | |
digitalWrite(PIN_G, LOW); | |
digitalWrite(PIN_B, HIGH); | |
} | |
void PURPLE_ON(){ | |
analogWrite(PIN_R, (int) 255*(100-61)/100); | |
digitalWrite(PIN_G, HIGH); | |
digitalWrite(PIN_B, LOW); | |
} | |
void WHITE_ON(){ | |
digitalWrite(PIN_R, LOW); | |
digitalWrite(PIN_G, LOW); | |
digitalWrite(PIN_B, LOW); | |
} | |
void setup() | |
{ | |
pinMode(PIN_R, OUTPUT); | |
pinMode(PIN_G, OUTPUT); | |
pinMode(PIN_B, OUTPUT); | |
pinMode(PIN_5V, OUTPUT); | |
digitalWrite(PIN_5V, HIGH); | |
} | |
void loop() | |
{ | |
RED_ON(); | |
delay(INTERVAL); | |
LED_OFF(); | |
YELLOW_ON(); | |
delay(INTERVAL); | |
LED_OFF(); | |
PINK_ON(); | |
delay(INTERVAL); | |
LED_OFF(); | |
GREEN_ON(); | |
delay(INTERVAL); | |
LED_OFF(); | |
PURPLE_ON(); | |
delay(INTERVAL); | |
LED_OFF(); | |
WHITE_ON(); | |
delay(INTERVAL); | |
LED_OFF(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment