Not long time ago we featured simple Arduino wav player that played music stored in internal microcontroller RAM. Due to memory limitation, you can play only couple of seconds of sound on Arduino UNO. To remove this limitation Kathy Yang extended player by adding SD card, where any size and length music files can be loaded.
Before you can listen for music, wav files need to be converted in to appropriate format so Ardiuno could play them correctly. This is done by special software provided by author. In order to select file and play it, you need to connect to Arduino via serial port debugger, where list of files are visible and with several control commands you can play file, stop, pause or switch to next file. Having this you shouldn’t have problem implementing you own user interface to control player. But more practical way of using it would be embedding sound effects in to project – think of educational child toy or other.
Today all C compilers generate very optimal code for microcontrollers. In most cases is not worth trying to optimizing it by writing assembly lines. But there are one factor left that lead to less efficient code – the guy who writes code. If you have programmed for PC writing code same way not always is the best way to do. Microcontroller oriented compilers like AVR GCC is adapted to generate optimal code for AVR devices. If you will go to other micros, then you will see that programming ARM microcontrollers with C in some cases require special code structure to get most of hardware. To be a pro on those things you actually need to know how hardware works in one or in other situation, but simple general tricks may save a day by reducing code size ans so speeding up the execution. Improper coding may generate excess code. So Atmel has prepared an application note where they take through several key coding tips.
One part is more dedicated to reducing code size by doing simple decisions on selecting variable types, making them global or local. Then move towards loops, where counter increment and decrement generate different code size. Storing constants in program memory instead of loading to RAM helps saving RAM space. Other part goes to improving execution speed. Simple tricks like loop enrolling, control flow, can significantly speed up your program. Sometimes code space can be sacrificed to gain speed. So it is up to you what you are looking.
When project goes wireless prototyping with breadboard can be really messy. This is OK with single module, but what if you need several options? This is why TechBitar designed BridgeDuino board that can work as Arduino shield or HUB that can carry several popular wireless adapters including IR transmitter LED, IR receiver, RF433MHz reseiver and transmitter, Bluetooth HC-06 and HC-05, and Nrf24L01+.
Board can sit on top of Arduino Uno as shield or be as base for Arduino Pro Mini along with FTDI programmed adapter. All those adapters already have Arduino libraries available, so there is no problem to interfacing them you just need to be sure when selecting proper control and data pins. BridgeDuino also has several additional features that make life easier. For instance LM1117 3.3V supply for powering Nrf24L01+ module, battery power option with Schotky diode protection, jumpers for programming and configuring other adapters, several I2C and ADC headers.
Sometimes in more complex projects it is a waste to dedicate a line for every LED or button. If you thinking of selecting bigger microcontroller because you need additional pin to drive LED, think of smart way out. Francois AUGER & Philippe Fretaud have shared their technique of interfacing three LEDs and three buttons with three I/O pins.
They used special Charlieplexing method of connecting all together and then wrote code piece to drive LEDs and read buttons. Three additional diodes allow reading buttons without affecting other components. Using three additional diodes is way more efficient than expanding number of pins. See video bellow of live action. Continue reading