Hello,
I am building a small robot that uses an ATtiny 84 and infrared LEDs with TSOP receivers to detect obstacles. I am using the arduino software with a USBtinyISP AVR programmer to program the ATtiny. I can make the Blink sketch work and have no problems uploading the code and am using this set of cores : Google Code Archive - Long-term storage for Google Code Project Hosting.
However, the TSOP sensors can only detect IR light if it is pulsed at 38 kHz, but the tone() function not being available for ATtinys I do not know how to send a 38 kHz signal to the LEDs. I do not have enough room on the robot to implement a 555 oscillator so I will have to find a way of coding it on the ATtiny.
Thank you very much for helping me.
tone() should be available with the Tiny core. I've not used that core personally but I see the file listed at cores/tiny/Tone.cpp.
Thank you for your awnser.
I actually was using another core and downloaded this one instead because of its tone() support but I've tested it on piezo speakers and it does not work.
Billygoat:
...but I've tested it on piezo speakers and it does not work.
Are you claiming that tone in the Tiny Core does not work?
Yes, evrerything except tone() works fine.
Just to put this in perspective, there are 10s of thousands of people using that core (including me). You are the only one who is reporting a problem with tone. While it is certainly possible that tone is defective, odds are a bit higher that the problem lies elsewhere.
Maybe you have a wiring problem
Show us your connections.
This sketch outputs a nice 1000 HZ tone on pin 1 on Atiny84
Pin 1 is physical pin 3 on the chip
int soundPin=1;
void setup() {
pinMode(soundPin,OUTPUT);
tone(soundPin,1000);
}
void loop() {
}
It works now ! Thank you ! I don't know why but it works. Is it because only some pins on the ATtiny are capable of producing a tone ?
Billygoat:
It works now ! Thank you ! I don't know why but it works. Is it because only some pins on the ATtiny are capable of producing a tone ?
That will depend on the core. Any pin can output a tone in software but only a few pins are connected to the hardware timers (which is the best way to do it).
The hardware output pins are: PA5, PA7, PB2