Sunday, June 20, 2010

Arduino code for LDR

int LDR = 1;
int speaker = 10;
int val = 0;
int tones[] = {3830, 3400, 3038, 2864, 2550, 2272, 2028, 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956};

void setup() {
pinMode(LDR, INPUT); // declare the LDR as an INPUT
pinMode(speaker, OUTPUT); // declare the ledPin as an OUTPUT
}

void loop() {
val = analogRead(LDR);
digitalWrite(speaker, HIGH);
delayMicroseconds(tones[val]);
digitalWrite(speaker, LOW);
delayMicroseconds(tones[val]);
}
Related Posts Plugin for WordPress, Blogger...
Disclaimer: All the information in this blog is just gathered from different sites in the web and placed here and I am not the owner for these content

Popular Projects

Followers

My Blog List

Give Support

Give Support
Encourage me Through Comments & by Following