Skip to content

Instantly share code, notes, and snippets.

@drojf
Last active October 29, 2016 13:10
Show Gist options
  • Save drojf/188dcdd474d2859b48a5dc0bdf588224 to your computer and use it in GitHub Desktop.
Save drojf/188dcdd474d2859b48a5dc0bdf588224 to your computer and use it in GitHub Desktop.
#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