Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int photocell = A0;
- int speaker = 8;
- float freq = 0;
- void setup() {
- // put your setup code here, to run once:
- pinMode(speaker, OUTPUT);
- Serial.begin(9600);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- int photoread = analogRead(photocell);
- Serial.println(photoread);
- freq = map(photoread, 0, 1023, 100, 1000);
- /*
- * Default - 350 - 650
- * R1 covered- 100-350
- * R2 covered- 650 - 1000
- */
- tone(speaker, freq, 10);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement