Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Adrien Oliva
witty
Commits
2bd06e81
Commit
2bd06e81
authored
Nov 15, 2017
by
Adrien Oliva
Browse files
Initial import
parents
Changes
3
Hide whitespace changes
Inline
Side-by-side
.gitignore
0 → 100644
View file @
2bd06e81
.pioenvs
.piolibdeps
.clang_complete
.gcc-flags.json
platformio.ini
0 → 100644
View file @
2bd06e81
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html
[env:nodemcuv2]
platform
=
espressif8266
board
=
nodemcuv2
framework
=
arduino
src/main.cpp
0 → 100644
View file @
2bd06e81
#include <Arduino.h>
/******************************************************************************/
/* Pin Definition */
/******************************************************************************/
#define RGB_LED_R (15)
#define RGB_LED_G (12)
#define RGB_LED_B (13)
#define BUTTON_PIN (4)
#define LDR_PIN (0)
/******************************************************************************/
/* Global Variable */
/******************************************************************************/
static
uint8_t
down
=
0
;
static
uint16_t
ldr
=
0
;
static
uint8_t
color
=
0
;
/**************/
/* Setting up */
/**************/
void
setup
()
{
Serial
.
begin
(
115200
);
Serial
.
println
(
"Initialization"
);
pinMode
(
RGB_LED_R
,
OUTPUT
);
pinMode
(
RGB_LED_G
,
OUTPUT
);
pinMode
(
RGB_LED_B
,
OUTPUT
);
pinMode
(
BUTTON_PIN
,
INPUT
);
pinMode
(
LDR_PIN
,
INPUT
);
}
/**************************************/
/* Compute next state and show output */
/**************************************/
void
next
()
{
Serial
.
printf
(
"Color RGB: #%02x%02x%02x
\n
"
,
(
color
&
0x04
)
?
255
:
0
,
(
color
&
0x02
)
?
255
:
0
,
(
color
&
0x01
)
?
255
:
0
);
digitalWrite
(
RGB_LED_R
,
(
color
&
0x04
)
?
HIGH
:
LOW
);
digitalWrite
(
RGB_LED_G
,
(
color
&
0x02
)
?
HIGH
:
LOW
);
digitalWrite
(
RGB_LED_B
,
(
color
&
0x01
)
?
HIGH
:
LOW
);
ldr
=
analogRead
(
LDR_PIN
);
Serial
.
printf
(
"Lumens: %d%%
\n
"
,
ldr
*
100
/
1024
);
color
++
;
color
%=
0x08
;
}
/********************************/
/* Scan user input in main loop */
/********************************/
void
loop
()
{
int
button
=
digitalRead
(
BUTTON_PIN
);
if
(
down
&&
button
)
{
Serial
.
printf
(
"KeyRelease
\n
"
);
next
();
}
down
=
(
button
==
0
?
1
:
0
);
delay
(
50
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment