Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int photoPin= A0;
- const int piezoPin= 8;
- int photoVal=0;
- int mini= 60;
- int maxi= 200;
- void setup()
- {
- // put your setup code here, to run once:
- pinMode (photoPin, INPUT);
- pinMode (piezoPin, OUTPUT);
- Serial.begin (9600);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- photoVal= analogRead (photoPin);
- Serial.println (photoVal);
- photoVal= map(photoVal, mini, maxi, 130, 930);
- tone(piezoPin, photoVal,20);
- delay(20);
- noTone (piezoPin);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement