0
\$\begingroup\$

I'm absolutely new to this subject and I have no idea how to start, save for the fact that I need an microcontroller for this.

I want to toggle the power between modules/devices I want to hook up to another device.

  1. Push button once: Turn on bluetooth, toggle RGB LED to blue and play sound 1.
  2. Push button twice: Turn off bluetooth, turn on USB port, toggle RGB LED to green and play sound 2.
  3. Push button thrice: Turn on bluetooth and USB port, toggle RGB LED to red and play sound 3.
  4. Push button for 5 seconds: Turn on bluetooth and pair it (to get into the bluetooth modules pairing mode, you just have to push a button on it) and play sound 4.

Where do I start? Is an ATtiny85 sufficient for this?

\$\endgroup\$
1
\$\begingroup\$

To my knowledge, an ATTiny85 requires an Arduino board (or other micro controller) to program it and then it can run standalone, this is where you would start. As for the ability of the chip, it has 5 I/O pins (2,3,5,6,7) and you have 4 actions:

  • Toggle bluetooth
  • Change LED color
  • Play various sounds
  • Toggle USB port

ATTiny85 Pin layout

You could wire each action to its own pin in order to keep the fifth port open for input from your button. The PWM/Analog output that the ATTiny85 has will allow you to play multiple pitches from one port to handle all four sounds. Toggling something on such as bluetooth or the USB port uses digital output (0 or 1), which will not take more than 1 pin for each action since you send either a high or a low from a pin to engage/disengage the corresponding action.

A problem arises for changing the color of your RGB LED because you only have one output port remaining now and the RGB LED has 3 inputs. You could potentially use two ATTiny85 chips to solve this or you could also explore signal splitting techniques such as charlieplexing or multiplexing, but I think those methods cannot work with a single pin. After that, just figure out the programming logic for sequential and timed button press triggers to engage your output pins.

A good solution to this problem would be to use the ATtiny84-20PU for a larger array of pins. Below is the pin layout for the ATtiny84:

ATtiny84 Pin Layout

I would recommend following this ATtiny85 program upload guide or this ATtiny84 program upload guide to learn how to get your code onto the chip.

\$\endgroup\$
  • \$\begingroup\$ If power consumption isn't a major issue a "neopixel" type RGB LED only needs one signal. Of course there also many MCU's with more pins in both the ATtiny and MegaAVR families. It would probably be easier to do initial development on an Arduino board itself. \$\endgroup\$ – Chris Stratton Jul 30 at 23:57
  • \$\begingroup\$ What would be an alternative to the ATtiny if I want to use a 4 pin RGB LED? Also: Do I need resistors or anything else? I already have an Arduino Board for programming. \$\endgroup\$ – Christian Jul 31 at 13:48
  • \$\begingroup\$ I would recommend using an Arduino Nano since it gives you 14 digital pins and 8 analog pins for a total of 22 I/O pins. Its definitely more than enough for controlling an RGB on top of your other actions without losing the small size you would have from using an ATtiny85. It also allows direct program uploading unlike the ATtiny85 method. They are cheap, you can buy one for about $8. You would need a resistor to drop the voltage down to either 3.3v or 2v to run your LED safely, check the manufacturer's notes on operating voltage and current. \$\endgroup\$ – Kharonos Jul 31 at 14:29
  • \$\begingroup\$ The Nano unfortunately is a bit too big for my taste / use case. Also I don't need the micro usb port. \$\endgroup\$ – Christian Jul 31 at 16:27
  • \$\begingroup\$ In that case, you could stay in the ATtiny family and use either ATtiny84-20PU or ATtiny2313-20PU for the few extra pins to control your LED. If you need to find even more alternatives, search up "8-bit 14 Pin MCU" and change the pin number to your liking, that is how I found the other two ATtiny types. \$\endgroup\$ – Kharonos Jul 31 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.