Last active
October 29, 2016 13:10
-
-
Save drojf/188dcdd474d2859b48a5dc0bdf588224 to your computer and use it in GitHub Desktop.
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
#include "pitches.h" | |
int LRD = A0; | |
void setup() { | |
int buzzerPin = D1; | |
int LRD = A0; | |
pinMode(buzzerPin, OUTPUT); | |
pinMode(LRD, INPUT); | |
Serial.begin(9600); | |
} | |
void loop() { | |
int ldrval = analogRead(LRD); | |
Serial.println(ldrval); | |
if (ldrval < 300) { | |
beep(NOTE_A4, 500); | |
delay(3000); | |
} | |
if (ldrval > 300); { | |
beep(NOTE_F6, 500); | |
}; | |
if (ldrval > 500); { | |
beep(NOTE_A6, 500); | |
delay(3000); | |
}; | |
} | |
void beep(int note, int duration) { | |
tone(D1, note, duration); | |
delay(duration); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment