Тёмный
No video :(

Expanding TONS of Switches/LEDs with Arduino (Teensy + ATtiny) and Controlling over MIDI! 

Kevin Darrah
Подписаться 106 тыс.
Просмотров 7 тыс.
50% 1

Big thanks to this customer for giving permission to showcase this project here - lots to discuss and hopefully you'll pick something up here to use in your own projects! TLDR: Expanding IO from a Teensy 4.1 over I2C bus using ATtiny1614's super easy to do this and the MIDI control from the Teensy keeps it simple.
Mega Tiny Core: github.com/Spe...
The chip I'm using: github.com/Spe...
Build your own UPDI programmer: github.com/Spe...
Teensy: www.pjrc.com/s...
Teensy Code: github.com/krd...
ATtiny Code: github.com/krd...
Check out my Tindie store (trigBoard is available) www.tindie.com...
Thanks to all the Patrons for dropping a few bucks in the tip jar to help make these videos happen!
/ kdarrah
Twitter: / kdcircuits
For inquiries or design services:
www.kdcircuits...

Опубликовано:

 

28 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 50   
@andreasdreher9449
@andreasdreher9449 3 года назад
100.000 follower ! congratulation
@Kevindarrah
@Kevindarrah 3 года назад
thanks man!
@Geek_Chef
@Geek_Chef 3 года назад
Since you splurged for the Attiny carrier board.....could you have also just used Teensy LC boards at $11.65...? You could have then set up an 8 pin address on an 8 pin Dip Switch. So you would have 4 ins and 4 outs, 8 bit address for 256 units, I2C bus at 2 pins. That is 18 pins and the LC has 27 pins of I/O. Then you could just program them all the same....and use the Dip Switch to tell the chip what unit it is and what MIDI to use. Just another thought. Another possibility would be to use an Attiny84....or possibly an Attiny4313(maybe). Absolutely love your channel...and the Trigboard! Congrats on the 100k!
@Kevindarrah
@Kevindarrah 3 года назад
yea that's a cool idea! And thanks for that!!
@McTroyd
@McTroyd 3 года назад
Huge scalability potential here! Nice. A thought: * I can't remember for sure, but I think most AVRs have a unique ID burned into them somewhere. * If that's the case, you could load the ATTiny boards with the same code at some default I2C address (perhaps the top end of your range). * The Teensy would then call out to that universal address, send the UID, and send the desired address for that UID. * ATTiny compares UIDs; if matched, set the specified address. * That way, any changes can be done from the Teensy code, which could simplify the management & maybe aid repair-ability later (should a board need swapping). * If you're really feeling fancy, you could have the ATTiny briefly display its assigned address once it's set for debugging (in four-bit increments of course). 😁
@Kevindarrah
@Kevindarrah 3 года назад
Yea, that would be super cool! I'd love to figure out a way to auto address an I2C bus. Wonder if there would be any interest in this?
@McTroyd
@McTroyd 3 года назад
@@Kevindarrah I'd be interested.
@TheEmbeddedHobbyist
@TheEmbeddedHobbyist 3 года назад
As the number of ATtiny's increase the latency of the button presses will increase. You could try and arrange the ATtiny’s in to blocks. Each block sends an interrupt on a key press, so you only need to process a block where there is button is pressed, this will reduce the number of reads to devices that have nothing to report.
@Kevindarrah
@Kevindarrah 3 года назад
thanks yea, we're not really going to know true speeds until the final installation, but luckily we don't need crazy speeds. In the next part, I'll add some benchmarking code to report total scan time.
@fluteplayerify
@fluteplayerify 3 года назад
Interesting! I have always considered i2c to be fairly slow but it looks like you got great performance. My initial thought for design would be to use a parallel bus to a bunch of io registers
@Kevindarrah
@Kevindarrah 3 года назад
yea, same, but good thing speed was not a major requirement. Just so happened to be crazy fast
@fathomisticfantasy2681
@fathomisticfantasy2681 3 года назад
It must be a normal thought of Engineering because I too was considering this (Parrellel Bus) for my project in a MIDI to CV module. Yea I am marking this video for consideration. Good luck on the projects Ya all.
@GordieGii
@GordieGii 3 года назад
I2C is slow, if by slow you mean it's not a good choice for transmitting video. If you want a few thousand buttons or LEDs per second, it's fine.
@user-qf6yt3id3w
@user-qf6yt3id3w 3 года назад
Kind of crazy you can get a microcontroller for under a dollar which is as capable as the ATtiny1614.
@Kevindarrah
@Kevindarrah 3 года назад
yea!! with hardware UART/SPI/I2C and a friggin DAC!
@user-qf6yt3id3w
@user-qf6yt3id3w 3 года назад
@@Kevindarrah Actually another nice thing is that all the microcontrollers in the series have the same IO devices. So you can prototype with the 16K flash one but use one with a smaller flash if you can fit the code into it.
@YoutubeBorkedMyOldHandle_why
@YoutubeBorkedMyOldHandle_why 3 года назад
Exactly. I've been playing around with ATTiny412s. Similar MCU, but with fewer pins and less flash/ram ... but also at half the cost. Kevin obviously needs the extra GPIOs, but maybe he could get away with the ATTiny814 or 414 and save a few cents/chip. I mean, it's not like the code is very complex.
@nrdesign1991
@nrdesign1991 3 года назад
I'd use a standard port expander as they're readily available. For large installations, an RS485 based bus like DMX (unidirectional) , CAN or MODBUS (bidirectional, used in industry) would be appropriate as it is very resilient to EMI. 4 in/4 out reminds me strongly of AS-i bus which transmits power and data on the same two lines, but is kinda slow and proprietary.
@Kevindarrah
@Kevindarrah 3 года назад
love it - RS485 was a major contender! have not done much with CAN though, that might be interesting
@joanantonllarchpoyo2837
@joanantonllarchpoyo2837 3 года назад
Interesting as always... An I2C booster chip close to the Teensy will help...like the LTC4311. For long distances rs485 is an alternative solution...
@Kevindarrah
@Kevindarrah 3 года назад
yes! But luckily distances are pretty close
@jenskaa4044
@jenskaa4044 3 года назад
Nice. Have you checked the i2c on a scope? Perhaps you need a lower pullup resistor when you scale up. It could also be nice to have exactly the same sw on each node. Perhaps the node address could be kept in eeprom.
@Kevindarrah
@Kevindarrah 3 года назад
nice catch!! Yea. we'll need to watch bus capacitance as we add nodes. And yea that would be cool with the address - use the spare pin to analog read a dip switch or something. Customer was cool with different code though
@jenskaa4044
@jenskaa4044 3 года назад
@@Kevindarrah idea: press a key(or more) during power on to enter configuration mode, and use the leds as feedback. Store the address in eeprom.
@ZelleJ
@ZelleJ 3 года назад
Dude fire. keep it up!
@tal.klinger
@tal.klinger 3 года назад
Have you heard about charlieplexing? You can use it for driving LEDS and even input with the original GPIO pluse few diodes. For large matrices, the design gets complicated layout-wise, but its worth checking as an alternative
@Kevindarrah
@Kevindarrah 3 года назад
yea it is pretty neat - I think I made a binary clock using that about 10years ago :)
@Xx_TurTix_xX
@Xx_TurTix_xX 3 года назад
Hey I really need some help with a project with leds. So i have this small replica of sky tree and it only got 3 color blue, red and pink. I want to change it up and make it connect to the razer argb controller so i can use it with the razer synapse app and make it work with the rest of my gaming setup. And i have no idea on how to make it work
@adamkrezz
@adamkrezz 3 года назад
Have you measured the power at all? I imagine that constantly looping means the idle power would be a little higher. What changes would you make in order to turn this into an interrupt-driven design rather than a polling design for the purposes of reducing overall power consumption?
@daveturner5305
@daveturner5305 3 года назад
I possibly missed it. Did you debounce the switches?
@Kevindarrah
@Kevindarrah 3 года назад
you know what's funny, actually did not need to. No chatter or false commands were ever seen during testing. And also for this application, would not be critical if chattering was seen. But I was prepared to debounce the buttons originally
@superdau
@superdau 3 года назад
@@Kevindarrah I don't know how long the installation will be in use and if the buttons shown are actually the buttons being used later, but switches get "old" fast and start to bounce a lot. Could easily be done in software though, the attinys aren't doing much anyway.
@BenMitro
@BenMitro 3 года назад
Nice solution. Was a simple matrix for both led and switches not an option? Wiring I guess would be more dense with a matrix and perhaps response time would be slower too. What was your thinking for not choosing a matrix arrangement?
@Kevindarrah
@Kevindarrah 3 года назад
that would be cool! but yea like you said wiring across multiple boards would be a pain
@FrankGraffagnino
@FrankGraffagnino 3 года назад
great walkthrough. thanks for sharing. couple of questions. You walked through the NoteOff case... for NoteOn, is it the exact same code but with a "1" in the writeLED statements? If so, couldn't you just set a bool from NoteOff or NoteOn case and then run the same code? Also, do the buttons not need any debouncing? If not, i'm wondering why they don't. Awesome build!
@Kevindarrah
@Kevindarrah 3 года назад
yea the noteOn/Off bit was just laziness - I just copy/pasted same code up there. More elegant would be just like you said to set a bit and write LED based on that. And yea, someone else also asked about debouncing - really didn't need it and I too was surprised by this. Was planning on writing some code for this, but wasn't needed - I think mostly because buttons are not interrupting anything and also they are polled on the I2C buss, so that's slightly adding delay between readings. In the logs, I did not see any false pos/neg readings, so it might be fine. If I do end up adding debounce code, will mention it in a part 2
@ClaytonDarwin
@ClaytonDarwin 3 года назад
Nice.
@eccentricOrange
@eccentricOrange 3 года назад
Comment at 3:00 I²C?? Daisy chain type of thing Edit: I was right!!
@hydroalternation
@hydroalternation 3 года назад
I knew it when you sleep you dream machine code LOL
@davy822
@davy822 3 года назад
Have you decided to use the Teensy instead an Arduino usb compliance ( like micro ) for the board price or of the libraries?
@Kevindarrah
@Kevindarrah 3 года назад
customer really liked this part especially for its MIDI support
@Stinktierchen
@Stinktierchen 3 года назад
Did you took in concideration to use a simple MCP23017 ? Thats a great 16 bit I/O chip and rather cheap! It has interrupts on the pins too. It has an I2C and SPI verison as well! And if 16 pins arent needed you could have easily used an PCF8574 which is an 8bit I/o with I2c as well. I wouldnt go with your solution simply because it is too expensive for everyone who is not living in a rich country. There are much cheaper solutions. Of course if you can spare the money thats alright... I wouldnt go that path Edit: Ok I see you want to have a lot of separated button arrays. Most of the I2C chips are limited to 8 chips on a bus...
@Kevindarrah
@Kevindarrah 3 года назад
we think alike :) I was originally on that same path!
@jumadhaheri
@jumadhaheri 3 года назад
Look like Wintergatan machine
@tseckwr3783
@tseckwr3783 3 года назад
They call you the "Switchman"
@dennisdecoene
@dennisdecoene 3 года назад
20:17 have you heard of shifting bits? >>
@Kevindarrah
@Kevindarrah 3 года назад
yep, made a video about just that a while back, but was lazy here :) and speed was still fine
@dennisdecoene
@dennisdecoene 3 года назад
This is the first video I've seen on your channel. It was recommended to me from the previous video I watched. I'm glad I watched because it is interesting to see how you solved this. So kudo's to that. It IS a very good solution. Thanks for sharing! Just when I saw the code I was going whut? Haha. But good work sir. I like it. Will check out rest of channel now 😉
Далее
Experiments with Super Capacitors for IoT Projects
19:19
Building a MIDI Controller Using Arduino
15:41
Просмотров 631 тыс.
74HC595 & 74HC165 Shift Registers with Arduino
40:38
Просмотров 397 тыс.
Arduino MIDI Controller: Part 3 - Multiplexers
20:09
Просмотров 196 тыс.
Build a Programmable USB Midi Controller - FADR-4
25:10