int pinoPot=0;int valPot=0;int nota=0;int notaMin = 49;int notaMax=notaMin*4;int valLDR =0;void setup() { Serial.begin(9600); }void loop() { // put your main code here, to run repeatedly:valPot=analogRead(pinoPot);valLDR=analogRead(1);nota=map(valLDR,450,950,notaMin,notaMax);tone(9,nota);Serial.println(valLDR);} // ---------------------------------------------------------------------------//Utiliza a bibliotece NewTone e NewPing// ---------------------------------------------------------------------------#include <NewTone.h>#define TONE_PIN 3#include <NewPing.h>#define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor.#define ECHO_PIN 11 // Arduino pin tied to echo pin on the ultrasonic sensor.#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.unsigned int freq = 0;void setup() { Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.}void loop() { delay(25); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings. unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS). if(uS<2000&&uS>100){ freq=map(uS,100,2000,10,800); NewTone(TONE_PIN, 800-freq); }else{ noNewTone(TONE_PIN); } Serial.println(freq); /**Serial.print("Ping: "); Serial.print(uS );/// US_ROUNDTRIP_CM); // Convert ping time to distance in cm and print result (0 = outside set distance range) Serial.println("cm");**/} int brilho = 0;int pinLed = 9;int pinBot = 8;int leituraBot;boolean acende = false;void setup() { pinMode(pinLed, OUTPUT); pinMode(pinBot, INPUT); Serial.begin(9600);}void loop() { leituraBot = digitalRead(pinBot); analogWrite(pinLed,brilho); if (leituraBot == 1) { acende = ! acende; Serial.println("bot apertado"); delay(300); } if (acende) { if (brilho < 255 ) { brilho++; delay(10); Serial.println("acende"); } }else { if (brilho > 0) { brilho--; delay(10); Serial.println("apaga"); } } } Aqui vai o link para o instructables do projeto Loud Noise Objects:LOUD NOISE OBJECTS //Fazer o download da biblioteca NewTone no link: https://code.google.com/p/arduino-new-tone/downloads/detail?name=NewTone_v1.0.zip//variaveis//escopo global#include <NewTone.h>#define TONE_PIN 3unsigned long tempoSalvo,tempoSalvo2 = 0;//salvar o tempo depois de um periodo;unsigned int contador = 0;unsigned long tempoAtual=0;boolean ligado,ligado2=false;int dur=100;int dur2=300;int valPot1,valPot2, valPot3,valLDR=0;int brilho=0;int nota;//funcao que inicializavoid setup(){ pinMode(11,OUTPUT); pinMode(10,OUTPUT); //inicia comunicacao serial com a maquina Serial.begin(9600);}void loop(){ //millis e uma funcao que conta o tempo; tempoAtual=millis(); valPot1=analogRead(0); valPot2=analogRead(1); valPot3=analogRead(2); valLDR=analogRead(3); dur=map(valPot1,0,1024,50,1000); dur2=map(valPot2,0,1024,50,1000); brilho=map(valPot3,0,1024,0,255); nota=map(valLDR,450,950,100,400); /**Serial.print("o led piscou "); Serial.print(contador); Serial.println(" vezes");**/ Serial.println(tempoAtual); //LED 1 if(tempoAtual>=tempoSalvo+dur){ tempoSalvo=tempoAtual; contador++; ligado=!ligado; } if(ligado){ analogWrite(6,brilho); }else{ analogWrite(6,0); } //LED 2 if(tempoAtual>=tempoSalvo2+dur2){ tempoSalvo2=tempoAtual; ligado2=!ligado2; } if(ligado2){ analogWrite(10,brilho); }else{ analogWrite(10,0); } NewTone(9,nota);} //variaveis//escopo globalunsigned long tempoSalvo,tempoSalvo2 = 0;//salvar o tempo depois de um periodo;unsigned int contador = 0;unsigned long tempoAtual=0;boolean ligado,ligado2=false;int dur=100;int dur2=300;int valPot1,valPot2, valPot3=0;int brilho=0;//funcao que inicializavoid setup(){ pinMode(11,OUTPUT); pinMode(10,OUTPUT); //inicia comunicacao serial com a maquina Serial.begin(9600);}void loop(){ //millis e uma funcao que conta o tempo; tempoAtual=millis(); valPot1=analogRead(0); valPot2=analogRead(1); valPot3=analogRead(2); dur=map(valPot1,0,1024,50,1000); dur2=map(valPot2,0,1024,50,1000); brilho=map(valPot3,0,1024,0,255); /**Serial.print("o led piscou "); Serial.print(contador); Serial.println(" vezes");**/ Serial.println(tempoAtual); //LED 1 if(tempoAtual>=tempoSalvo+dur){ tempoSalvo=tempoAtual; contador++; ligado=!ligado; } if(ligado){ analogWrite(11,brilho); }else{ analogWrite(11,0); } //LED 2 if(tempoAtual>=tempoSalvo2+dur2){ tempoSalvo2=tempoAtual; ligado2=!ligado2; } if(ligado2){ analogWrite(10,brilho); }else{ analogWrite(10,0); }} // Auduino, the Lo-Fi granular synthesiser//// by Peter Knight, Tinker.it http://tinker.it//// Help: http://code.google.com/p/tinkerit/wiki/Auduino// More help: http://groups.google.com/group/auduino//// Analog in 0: Grain 1 pitch// Analog in 1: Grain 2 decay// Analog in 2: Grain 1 decay// Analog in 3: Grain 2 pitch// Analog in 4: Grain repetition frequency//// Digital 3: Audio out (Digital 11 on ATmega8)//// Changelog:// 19 Nov 2008: Added support for ATmega8 boards// 21 Mar 2009: Added support for ATmega328 boards// 7 Apr 2009: Fixed interrupt