Using three pins to drive three LEDs and read three buttons

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.

three_leds_three_buttons_three_gpio

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

Aren’t those programming headers too big?

Microcontroller boards are getting smaller and especially in smaller ones those programming headers become annoying. Think of 6-pin AVR ISP header – even on Arduino board it can be in your way. If you need to program MCU, you cannot get rid of it. So many of hobbyists probably start making custom solutions in order to save space. Danny suggests to take a look at so called tag-connect solution, where connection can be made with spring loaded pogo-pins that are normally used for testing PCBs during manufacturing.

tag-connect-header-vs-icp

It seems that they can serve programming and debugging purposes on small boards pretty well. You can make easily make ISP to tag-connect adapter cable pretty easily and next time design PCB with much smaller ISP footprint. Using tag-connect you are not only saving on board space, but also you need less drill holes and don’t need pin header anymore.

Single I/O pin – double function

There are many situations when you simply run out of I/O pins on microcontroller. For new project you can always select different microcontroller with more pins or ad I/O expander. If you have project running on Raspberry Pi and almost all your pins are busy, then you should try to go smart way. Emilio faced this problem when he needed to add LED indicator and button to his existing project, but there were only single free pin available. So he thought that functionality could be achieved with single pin quite easy.

single_pin_dual_operation

He attached LED to power supply via current limiting resistor. Then using same pin he added push button to ground through another resistor. The rest depends on how program controls that pin. In this case Python script simply runs loop every second where 200ms is used to turn LED another portion of time-frame is used to detect button switch and some sort of debounce. Button is used to shut down Raspberry Pi after it is pressed for longer than 5 seconds. Same technique can be easily used on any microcontroller as well.

Learning about accelerometers and gyroscopes

Accelerometers and gyroscopes are commonly used sensors where some sort of balance is needed. Combination of both in one board is called IMU (Inertial Measurement Unit). You will find one on flight controllers, balance modules and in many other areas. If you are going to build something from scratch then you should know some background information on how to interpret readings and how to use them in control. Gadget Gangster have shared pretty good instructable where he explains how to interface IMU device to microcontroller and how to use this data to get desired results.

IMU_tutorial

As example he uses Acc_Gyro board with LIS331AL triple axis accelerometer and LPR550AL dual axis gyroscope. He goes through some math while explaining how to determine orientation of IMU using either only accelerometer data or combination with gyroscope readings. Plus gyroscope gives some clue about rotation around one or another axis. SO if you are thinking of building inertial system, you should do your homework and understand hos things work.