33 lines
963 B
C++
33 lines
963 B
C++
//**** INCLUDES *************************************************************
|
|
|
|
//**** CONSTANTS ************************************************************
|
|
|
|
//**** PIN ASSIGNMENT OF OUR SHIELD *****************************************
|
|
static const int buttonLeft = D7;
|
|
static const int buttonRight = D6;
|
|
static const int ledBlue = D5;
|
|
static const int ledRed = D3;
|
|
static const int ldr = A0;
|
|
static const int buzzer = 26;
|
|
|
|
//**** SETUP ****************************************************************
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
|
|
pinMode(buttonLeft, INPUT_PULLUP);
|
|
pinMode(buttonRight, INPUT_PULLUP);
|
|
pinMode(LED_BUILTIN, OUTPUT);
|
|
pinMode(ledBlue, OUTPUT);
|
|
pinMode(ledRed, OUTPUT);
|
|
pinMode(buzzer, OUTPUT);
|
|
pinMode(ldr, INPUT);
|
|
}
|
|
|
|
//**** LOOP *****************************************************************
|
|
void loop() {
|
|
|
|
int Brightness = map(analogRead(ldr), 0, 1023, 255, 0);
|
|
analogWrite(ledBlue, Brightness);
|
|
delay(70);
|
|
}
|