Tell us about yourself!

Complete Your Profile
  • JanainaF commented on nikoala3's instructable Arduino Guitar Tuner5 months ago
    Arduino Guitar Tuner

    I don't remember exactly what happened but I think the problem was that I was using pin 12 to connect the lcd and the code uses manipulation of this port. Anyway this is the code that i used:#include //variaveis para armazenar dadosbyte newData = 0;byte prevData = 0;unsigned int time = 0;//armazena o tempo e envia valores para o vetor timeint timer[10];//vetor que armazena o tempo dos eventosint slope[10];//vetor que armazena a inclinacao dos eventosunsigned int totalTimer;//usado para calcular o periodounsigned int period;//armazena o periodobyte index = 0;//indice atualfloat frequency;//frequenciaint maxSlope = 0;//usado para o calculo da inclinação máxima como triggerint newSlope;//armazenamento de novas inclinacoes//variáveis para comparacaobyte noMatch =...

    see more »

    I don't remember exactly what happened but I think the problem was that I was using pin 12 to connect the lcd and the code uses manipulation of this port. Anyway this is the code that i used:#include //variaveis para armazenar dadosbyte newData = 0;byte prevData = 0;unsigned int time = 0;//armazena o tempo e envia valores para o vetor timeint timer[10];//vetor que armazena o tempo dos eventosint slope[10];//vetor que armazena a inclinacao dos eventosunsigned int totalTimer;//usado para calcular o periodounsigned int period;//armazena o periodobyte index = 0;//indice atualfloat frequency;//frequenciaint maxSlope = 0;//usado para o calculo da inclinação máxima como triggerint newSlope;//armazenamento de novas inclinacoes//variáveis para comparacaobyte noMatch = 0;//conta quantos valores diferentes foram recebidos para resetar as variaveis byte slopeTol = 3;//tolerancia da inclinacao (pode ser ajustada)int timerTol = 10;//tolerancia de tempo (pode ser ajustada)//variaveis para deteccao da amplitudeunsigned int ampTimer = 0;byte maxAmp = 0;byte checkMaxAmp;byte ampThreshold = 30;//aumentar caso o ruido seja muito grande//variaveis para o afinadorint correctFrequency;//frequencia correta da corda tocadaLiquidCrystal lcd(13, 11, 5, 4, 3, 2);void setup(){ lcd.begin(16,2); Serial.begin(9600); lcd.print("Afinador"); lcd.setCursor(0,1); lcd.print("<<<<<< oo >>>>>>"); delay(5000); lcd.clear(); cli();//desabilita interrupcoes(time sensitive) //da uma amostra do pino 0 com frequencia 38.5kHz //limpa os registradores ADCSRA e ADCSRB ADCSRA = 0; ADCSRB = 0; ADMUX |= (1 << REFS0); //tensao de referencia ADMUX |= (1 << ADLAR); //alinhamento à esqueda do valor de ADC // so eh possivel ler os maiores 8bits do registrador ADCH ADCSRA |= (1 << ADPS2) | (1 << ADPS0); //clock do ADC com 32 escalas- 16mHz/32=500kHz ADCSRA |= (1 << ADATE); //habilita auto trigger ADCSRA |= (1 << ADIE); //habilita interrupcoes quando a medida foi completa ADCSRA |= (1 << ADEN); //habilita ADC ADCSRA |= (1 << ADSC); //habilita medidas ADC sei();//habilita interrupcoes}ISR(ADC_vect) {//quando um valor novo de ADC está pronto PORTB &= B11101111;//pino 12 em low prevData = newData;//armazena dado anterior newData = ADCH;//novo valor de A0 if (prevData < 127 && newData >=127){//se aumentando ao passar por 2.5v newSlope = newData - prevData;//calcular inclinacao if (abs(newSlope-maxSlope) //armazenar os dados e zerar o tempo slope[index] = newSlope; timer[index] = time; time = 0; if (index == 0){//resetar se a inclinacao eh nova PORTB |= B00010000;//pino 12 no high noMatch = 0; index++;//aumenta o indice } else if (abs(timer[0]-timer[index]) //se o tempo e a inclinacao sao iguais aos valores iniciais //somar os valores do tempo totalTimer = 0; for (byte i=0;i totalTimer+=timer[i]; } period = totalTimer;//periodo //reseta novo indice zero para comparacao timer[0] = timer[index]; slope[0] = slope[index]; index = 1; PORTB |= B00010000;//pino 12 high noMatch = 0; } else{//cruza a linha de 2.5v mas nao deve ser armazenado(nao eh match) index++;//aumenta o indice if (index > 9){ reset(); } } } else if (newSlope>maxSlope){//se a inclinacao eh muito maior que a inclinacao max maxSlope = newSlope; time = 0;//reseta o clock noMatch = 0; index = 0;//reseta indice } else{//inclinacao menor que o esperado noMatch++;//aumenta o contador do noMatch if (noMatch>9){ reset(); } } } time++;//aumenta o timer em uma taxa de 38.5kHz ampTimer++;//aumenta o timer da amplitude if (abs(127-ADCH)>maxAmp){ maxAmp = abs(127-ADCH); } if (ampTimer==1000){ ampTimer = 0; checkMaxAmp = maxAmp; maxAmp = 0; } }void reset(){//limpa algumas variaveis index = 0;//reseta o indice noMatch = 0;//reseta o contador de noMatch maxSlope = 0;//reseta inclinacao}//Determina a frequência correta void stringCheck(){ lcd.setCursor(0,0); if(frequency>70&frequency<90){ lcd.print("Corda E . E (mi)"); correctFrequency = 82.4; } if(frequency>100&frequency<120){ lcd.print("Corda A . A (la)"); correctFrequency = 110; } if(frequency>135&frequency<155){ lcd.print("Corda D . D (re)"); correctFrequency = 146.8; } if(frequency>186&frequency<205){ lcd.print("Corda G . G (sol)"); correctFrequency = 196; } if(frequency>235&frequency<255){ lcd.print("Corda B . B (si)"); correctFrequency = 246.9; } if(frequency>320&frequency<340){ lcd.print("Corda e . e (mi)"); correctFrequency = 329.6; }}//Compara a frequencia de entrada com a//frequencia correta para determinar o ajustevoid frequencyCheck(){ if(frequency>correctFrequency+1){ lcd.setCursor(0,1); lcd.print(" << "); } if(frequency>correctFrequency+6){ lcd.setCursor(0,1); lcd.print("<<<<<< "); } if(frequency lcd.setCursor(0,1); lcd.print(" >> "); } if(frequency lcd.setCursor(0,1); lcd.print(" >>>>>>"); } if(frequency>correctFrequency-1&frequency lcd.setCursor(0,1); lcd.print(" oo "); }}void loop(){ if (checkMaxAmp>ampThreshold){ frequency = 38462/float(period); //calcula a frequencia taxa do timer/periodo } stringCheck(); frequencyCheck(); delay(100); lcd.clear(); }

    View Instructable »
  • JanainaF commented on nikoala3's instructable Arduino Guitar Tuner1 year ago
    Arduino Guitar Tuner

    I'm trying to adapt a lcd screen to this project but I cant seem to figure the code out.I have checked everything multiple times but wasn't able to find whats wrong and why isn't this working. Everythig seems to be working fine with the leds but when I try to use the lcd screen it shows nothing.I have included the LiquidCrystal on the begining of the code and lcd.begin(16,2); in the setup, this was the other change I did in the code:"void stringCheck(){if(frequency>70&frequency<90){lcd.print("E");correctFrequency = 82.4;}if(frequency>100&frequency<120){lcd.print("A");correctFrequency = 110;}if(frequency>135&frequency<155){lcd.print("D");correctFrequency = 146.8;}if(frequency>186&frequency<205){lcd.print("G&q...

    see more »

    I'm trying to adapt a lcd screen to this project but I cant seem to figure the code out.I have checked everything multiple times but wasn't able to find whats wrong and why isn't this working. Everythig seems to be working fine with the leds but when I try to use the lcd screen it shows nothing.I have included the LiquidCrystal on the begining of the code and lcd.begin(16,2); in the setup, this was the other change I did in the code:"void stringCheck(){if(frequency>70&frequency<90){lcd.print("E");correctFrequency = 82.4;}if(frequency>100&frequency<120){lcd.print("A");correctFrequency = 110;}if(frequency>135&frequency<155){lcd.print("D");correctFrequency = 146.8;}if(frequency>186&frequency<205){lcd.print("G");correctFrequency = 196;}if(frequency>235&frequency<255){lcd.print("B");correctFrequency = 246.9;}if(frequency>320&frequency<340){lcd.print("e");correctFrequency = 329.6;}}//Compare the frequency input to the correct//frequency and light up the appropriate LEDSvoid frequencyCheck(){if(frequency>correctFrequency+1){lcd.setCursor(0,1);lcd.print(">");}if(frequency>correctFrequency+4){lcd.setCursor(0,1);lcd.print(">>");}if(frequency>correctFrequency+6){lcd.setCursor(0,1);lcd.print(">>>");}if(frequency<correctFrequency-1){lcd.setCursor(0,1);lcd.print("<");}if(frequency<correctFrequency-4){lcd.setCursor(0,1);lcd.print("<<");}if(frequency<correctFrequency-6){lcd.setCursor(0,1);lcd.print("<<<");}if(frequency>correctFrequency-1&frequency<correctFrequency+1){lcd.setCursor(0,1);lcd.print("OK!");}}void loop(){lcd.clear();"Thanks for the project! If someone could help me it would be awesome =)

    I'm trying to adapt a lcd screen to this project but I cant seem to figure the code out. I have checked everything multiple times but wasn't able to find whats wrong and why isn't this working."void stringCheck(){ if(frequency>70&frequency<90){ lcd.print("E"); correctFrequency = 82.4; } if(frequency>100&frequency<120){ lcd.print("A"); correctFrequency = 110; } if(frequency>135&frequency<155){ lcd.print("D"); correctFrequency = 146.8; } if(frequency>186&frequency<205){ lcd.print("G"); correctFrequency = 196; } if(frequency>235&frequency<255){ lcd.print("B"); correctFrequency = 246.9; } if(frequency>320&frequency<340){ lcd.print("...

    see more »

    I'm trying to adapt a lcd screen to this project but I cant seem to figure the code out. I have checked everything multiple times but wasn't able to find whats wrong and why isn't this working."void stringCheck(){ if(frequency>70&frequency<90){ lcd.print("E"); correctFrequency = 82.4; } if(frequency>100&frequency<120){ lcd.print("A"); correctFrequency = 110; } if(frequency>135&frequency<155){ lcd.print("D"); correctFrequency = 146.8; } if(frequency>186&frequency<205){ lcd.print("G"); correctFrequency = 196; } if(frequency>235&frequency<255){ lcd.print("B"); correctFrequency = 246.9; } if(frequency>320&frequency<340){ lcd.print("e"); correctFrequency = 329.6; }}//Compare the frequency input to the correct //frequency and light up the appropriate LEDSvoid frequencyCheck(){ if(frequency>correctFrequency+1){ lcd.setCursor(0,1); lcd.print(">"); } if(frequency>correctFrequency+4){ lcd.setCursor(0,1); lcd.print(">>"); } if(frequency>correctFrequency+6){ lcd.setCursor(0,1); lcd.print(">>>"); } if(frequency<correctFrequency-1){ lcd.setCursor(0,1); lcd.print("<"); } if(frequency<correctFrequency-4){ lcd.setCursor(0,1); lcd.print("<<"); } if(frequency<correctFrequency-6){ lcd.setCursor(0,1); lcd.print("<<<"); } if(frequency>correctFrequency-1&frequency<correctFrequency+1){ lcd.setCursor(0,1); lcd.print("OK!"); }}void loop(){ lcd.clear();"

    View Instructable »