Created
April 8, 2021 16:38
-
-
Save jaythomas/2163c926c71bd153f35c89ae6f34b350 to your computer and use it in GitHub Desktop.
Wemos ESP8266 D1 Mini RGB led blink
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
/* *********************************************************** | |
* Global Constants * | |
* Hardware Definitions * | |
* ********************************************************* */ | |
// Wemos Mini D1 Pro pinout. This should have been provided by selecting the correct board but this | |
// board wasn't available when I looked for it so whatever this requires less dependency on the | |
// Arduino IDE configuration anyway. | |
// https://arduino-projekte.info/wp-content/uploads/2017/03/wemos_d1_mini_pro_pinout.png | |
byte PIN_D0 = 16; | |
byte PIN_D1 = 5; | |
byte PIN_D2 = 4; | |
byte PIN_D3 = 0; | |
byte PIN_D4 = 2; | |
byte PIN_D5 = 14; | |
byte PIN_D6 = 12; | |
byte PIN_D7 = 13; | |
byte PIN_D8 = 15; | |
/* The Arduino Web site recommends that one uses const | |
* rather than #define since using #define could have | |
* unwanted side effects | |
*/ | |
const int redPin = PIN_D3; // Red LED pin | |
const int greenPin = PIN_D2; // Green LED pin | |
const int bluePin = PIN_D1; // Blue LED pin | |
const int maxBright = 255; // Maximum LED brightness | |
/* *********************************************************** | |
* setup Function * | |
* ********************************************************* */ | |
void setup(){ | |
// Turn on the Serial Port | |
Serial.begin(115200); | |
pinMode(redPin, OUTPUT); | |
pinMode(greenPin, OUTPUT); | |
pinMode(bluePin, OUTPUT); | |
} | |
/* *********************************************************** | |
* loop Function * | |
* ********************************************************* */ | |
void loop(){ | |
digitalWrite(redPin, HIGH); | |
digitalWrite(greenPin, LOW); | |
digitalWrite(bluePin, LOW); | |
delay(1000); | |
digitalWrite(redPin, LOW); | |
digitalWrite(greenPin, HIGH); | |
digitalWrite(bluePin, LOW); | |
delay(1000); | |
digitalWrite(redPin, LOW); | |
digitalWrite(greenPin, LOW); | |
digitalWrite(bluePin, HIGH); | |
delay(1000); | |
digitalWrite(redPin, HIGH); | |
digitalWrite(greenPin, HIGH); | |
digitalWrite(bluePin, LOW); | |
delay(1000); | |
digitalWrite(redPin, HIGH); | |
digitalWrite(greenPin, LOW); | |
digitalWrite(bluePin, HIGH); | |
delay(1000); | |
digitalWrite(redPin, LOW); | |
digitalWrite(greenPin, HIGH); | |
digitalWrite(bluePin, HIGH); | |
delay(1000); | |
digitalWrite(redPin, HIGH); | |
digitalWrite(greenPin, HIGH); | |
digitalWrite(bluePin, HIGH); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment