Go Down

Topic: playing tones based on micros() (Read 13129 times) previous topic - next topic

nightcrawler218

Code: [Select]
(easily scaled back to 8 & 8 on an UNO). I cannot understand this. I've seen the youtube link. This sounds cool. Can I make use of the attached code in UNO? I have another bare ATmtga32A.
"Imagination is more important than knowledge."
-Einstein

CrossRoads

Atmega1284 has 32 IO pins, so it can support 13 buttons and create 13 outputs (a full octave), and have some pins left for serial.
Uno has 20 pins, so you can't have quite as many. So the note just refers to having less buttons & less notes. Adjust the code for the hardware you have.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

nightcrawler218

"Imagination is more important than knowledge."
-Einstein

nightcrawler218

#18
Dec 31, 2013, 12:09 pm Last Edit: Jan 01, 2014, 10:03 am by nightcrawler218 Reason: 1
Hello,
I have uploaded the sketch & made connections as described in the sketch... Only the CMajor scale notes
Quote
Input keys: pin2=C4, 3=C#4, 30=D4, 8=D#4, 9=E5, 31=F5, 4=F5#, 5=G5, 6=G5#, 7=A5, 10=A5#, 11=B5, 12=C5
Output notes: pin 16=C4, 17=C#4, 18=D4, 19=D#4, 20=E5, 21=F5, 22=F5#, 23=G5, 24=G5#, 25=A5, 26=A5#, 27=B5, 28=C5

The schematic & picture is also followed for reference.

I powered up the system & pressed buttons & no sound.
Then I debugged the sketch to see if the port pin detection is working or not. using this code...
Code: [Select]
if ((portDkeys & 0x04) == 0){ // key is pressed D2 -> A2
     if (keyActive[0]==0){
       keyActive[0] = 1;
       changeTime[0] = currentTime;
       Serial.println("OK"); // added this line
     }

Serial monitor prints the "OK" when I press a portD key, it means the controller is working. Now the second step, want to check if my speakers are working or not. I need your suggestion at this point. I am using a cheap pc stereo speaker 2.0 config. Connected the resistors in (One end is towards capacitor & the other ends are connected together). I put a 10K pot in the resistor node, as shown in pic & connected the wiper pin of the pot to the TIP of the stereo jack. Connected GND to the bottom part of the jack (Image included). Will this speaker work in this project? How to troubleshoot / setup the audio output part of this project? cant determine if any signal is generated from the output pins!

I'm using this speaker.
"Imagination is more important than knowledge."
-Einstein

elac

Oscilloscope handy to test output?
I also built this awesome project (pic attached) and after button/sound issues figured out that I needed to use the ATmegaBOOT_1284P_16MHz.hex bootloader file, after that it works great.
I used these for piano keys.

It's all about the skills

nightcrawler218

Hello elac,
Thanks for the reply. Since I don't have any oscilloscope, I shall try to view the output with another arduino board by connecting the o/p pins to analogpins & then analogRead. But should I upload the 1284 bootloader to my mega32A chip? Is it safe? I have a mega32A 40 pin chip only. Successfully ported the pin mappings but cang get the project to run anyhow. Any ideas?
Good day.
"Imagination is more important than knowledge."
-Einstein

elac

Nope, wrong bootloader ... didn't catch that in you are using the mega32A, sorry.
It's all about the skills

nightcrawler218

#22
Dec 31, 2013, 05:48 pm Last Edit: Dec 31, 2013, 07:48 pm by nightcrawler218 Reason: 1
Don't be sorry bro. It was my mistake. I should have mentioned the chip.
Thanks for your earnest efforts.
Happy new year ...
:)
"Imagination is more important than knowledge."
-Einstein

nightcrawler218

Tried to see the output values via another arduino board & analogreadSerial example. The adc reading is around 1 to 4 & no changes happen while pressing the buttons... Cant get it worked in mega32A.
:-/
"Imagination is more important than knowledge."
-Einstein

Grumpy_Mike

Please read this:-
How to use this forum
Because your post is breaking the rules about activating old threads, this one is three years old and your contribution is not very relevant to the thread's topic.

Start you own thread and POST YOUR CODE.

Go Up