Bom dia galera eu pesquisei muito e achei 2 codigos

o 1° eu não conseguir fazer funcionar que seria desse video

https://www.youtube.com/watch?v=X4QNT5hOHLs

Eu queria colocar uns led na hora que clicar ele acendam..

o 2° foi esse que eu achei

http://www.instructables.com/id/The-Arduino-OctoSynth/

http://www.instructables.com/files/orig/F2T/BLKU/GY65QIF1/F2TBLKUGY...

mais nao entendi o codigo e tambem queria colocar uns led, na hora de clicar eles acendam

isso seria por meu tcc que e por dia 30 agora so que eu nao sei anda da linguagem C entao eu nao posso estudar agora a linguagem , posso ate pagar pra alguem me ajudar porfavor.

eu queria muito o primeiro exemplo que nao funcinou , e tambem nao entendir porque colocar resistor..

Exibições: 290

Responder esta

Respostas a este tópico

Não testei mas, se você substituir essa parte do primeiro codigo

if (total1 > 150) tone(speaker,523);
if (total2 > 150) tone(speaker,587);
if (total3 > 150) tone(speaker,659);
if (total4 > 150) tone(speaker,698);
if (total5 > 150) tone(speaker,784);
if (total6 > 150) tone(speaker,880);
if (total7 > 150) tone(speaker,988); 

por isso

if (total1 > 150){
tone(speaker,523);
digitalWrite(LED1, HIGH);
}else{
digitalWrite(LED1, LOW);
}
if (total2 > 150){
tone(speaker,587);
digitalWrite(LED2, HIGH);
}else{
digitalWrite(LED2, LOW);
}
if (total3 > 150){
tone(speaker,659);
digitalWrite(LED3, HIGH);
}else{
digitalWrite(LED3, LOW);
}
if (total4 > 150){
tone(speaker,698);
digitalWrite(LED4, HIGH);
}else{
digitalWrite(LED4, LOW);
}
if (total5 > 150){
tone(speaker,784);
digitalWrite(LED5, HIGH);
}else{
digitalWrite(LED5, LOW);
}
if (total6 > 150){
tone(speaker,880);
digitalWrite(LED6, HIGH);
}else{
digitalWrite(LED6, LOW);
}
if (total7 > 150){
tone(speaker,988);
digitalWrite(LED7, HIGH);
}else{
digitalWrite(LED7, LOW);
}

definindo os devidos pinos, claro.

definir aonde os pino ?

Sander de fato o seu projeto era bem simples, para declarar os pinos você pode declara-los dentro do loop ou antes do setup. No meu caso eu sempre prefiro declarar antes do setup e quebro o código em vários blocos de funções, mas isso não é obrigatório.

O seu código ficaria assim, conforme a dica do joão:

#include <CapacitiveSensor.h>

// Name the pin as led.
#define speaker 11

// Set the Send Pin & Receive Pin.
CapacitiveSensor cs_2_3 = CapacitiveSensor(2,3); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
CapacitiveSensor cs_2_4 = CapacitiveSensor(2,4); // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil
CapacitiveSensor cs_2_5 = CapacitiveSensor(2,5); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
CapacitiveSensor cs_2_6 = CapacitiveSensor(2,6); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
CapacitiveSensor cs_2_7 = CapacitiveSensor(2,7); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
CapacitiveSensor cs_2_8 = CapacitiveSensor(2,8); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
CapacitiveSensor cs_2_9 = CapacitiveSensor(2,9); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil

int LED1 = 12; // os leds são declarados como inteiros é aqui que são definidos os pinos
int LED2 = 11;
int LED3 = 10;
int LED4 = 9;
int LED5 = 8;
int LED6 = 7;
int LED7 = 6;


void setup()
{
cs_2_3.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example

// Arduino start communicate with computer.
Serial.begin(9600);
}

void loop()
{
// Set a timer.
long start = millis();

// Set the sensitivity of the sensors.
long total1 = cs_2_3.capacitiveSensor(30);
long total2 = cs_2_4.capacitiveSensor(30);
long total3 = cs_2_5.capacitiveSensor(30);
long total4 = cs_2_6.capacitiveSensor(30);
long total5 = cs_2_7.capacitiveSensor(30);
long total6 = cs_2_8.capacitiveSensor(30);
long total7 = cs_2_9.capacitiveSensor(30);


Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("\t"); // tab character for debug windown spacing

Serial.print(total1); // print sensor output 1
Serial.print("\t"); // Leave some space before print the next output
Serial.print(total2); // print sensor output 2
Serial.print("\t"); // Leave some space before print the next output
Serial.print(total3); // print sensor output 3
Serial.print("\t"); // Leave some space before print the next output
Serial.print(total4); // print sensor output 4
Serial.print("\t"); // Leave some space before print the next output
Serial.print(total5); // print sensor output 5
Serial.print("\t"); // Leave some space before print the next output
Serial.print(total6); // print sensor output 6
Serial.print("\t"); // Leave some space before print the next output
Serial.println(total7); // print sensor output 7
// "println" - "ln" represent as "line", system will jump to next line after print the output.


// When hand is touched the sensor, the speaker will produce a tone.
// I set a threshold for it, so that the sensor won't be too sensitive.
if (total1 > 150){
tone(speaker,523);
digitalWrite(LED1, HIGH);
}else{
digitalWrite(LED1, LOW);
}
if (total2 > 150){
tone(speaker,587);
digitalWrite(LED2, HIGH);
}else{
digitalWrite(LED2, LOW);
}
if (total3 > 150){
tone(speaker,659);
digitalWrite(LED3, HIGH);
}else{
digitalWrite(LED3, LOW);
}
if (total4 > 150){
tone(speaker,698);
digitalWrite(LED4, HIGH);
}else{
digitalWrite(LED4, LOW);
}
if (total5 > 150){
tone(speaker,784);
digitalWrite(LED5, HIGH);
}else{
digitalWrite(LED5, LOW);
}
if (total6 > 150){
tone(speaker,880);
digitalWrite(LED6, HIGH);
}else{
digitalWrite(LED6, LOW);
}
if (total7 > 150){
tone(speaker,988);
digitalWrite(LED7, HIGH);
}else{
digitalWrite(LED7, LOW);
}

// When hand didn't touch on it, no tone is produced.
if (total1<=150 & total2<=150 & total3<=150 & total4<=150 & total5<=150 & total6<=150 & total7<=150)
noTone(speaker);

delay(10); // arbitrary delay to limit data to serial port
}

você pode alterar os pinos da forma que lhe convir como joão falou, como vc conhece o básico acho que isso não será problema

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço