Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
cruft
Oct 25, 2007

Ethics_Gradient posted:

You monster, that worked perfectly the first time I compiled it! And I'm feeling real dumb not noticing the "RST" pin right between two other ones I'm using :doh: All I had to do was move the pin from D3 over to there and now I've got an external reset button, nice.

Taking Cojawfee's advice I added in the beeps using some if else statements, which is also working well (once I figured out where it logically ought to go). I deleted the 1s delay and used the delay between LED flashes for that purpose instead.

I also added a solid tone to the 3s delay at the start just as a non-visual cue.

I think the only thing I'm missing is having it keep counting past 15 (so you know how much you had to overdevelop). I've tried quite a few different combinations/moving things around but best I can get is to have it leap from 15 straight to 90. (edit: nevermind, I eventually got it! Definitely understand the code a lot better after sitting down and puzzling through it, a lot of the stuff I learned a year ago is coming back to me)

If either you guys want a print, let me know your mailing address by PM :kiddo:

edit: another question - am I safe plugging in a strip of 60 5V (4W, according to the manufacturer) LEDs to replace the single one I have on D11? Just tried it and it worked fine, but wasn't sure about long term. They're pretty dainty.

I didn't mean to hand you a fully working program, sorry. I was hoping it'd be broken and you could learn by fixing it. But it sounds like you learned by adding stuff to it, so that's great. Hopefully the structure I used helped you understand how to think about the problem in a more linear (computer-y) way.

I love teaching, so that was its own reward. Maybe in the future somebody will need help developing prints, and you can step in on that :)

The 60 LEDs you mentioned are those 5050 SMD LEDs on foil tape. I use those all the time. Worst case, the one at the end will be voltage starved and look sick. As long as they're rated at the same or higher voltage your microcontroller is outputting, you're probably fine.

Send us a photo of your setup, though!

Adbot
ADBOT LOVES YOU

Ethics_Gradient
May 5, 2015

Common misconception that; that fun is relaxing. If it is, you're not doing it right.

cruft posted:

I didn't mean to hand you a fully working program, sorry. I was hoping it'd be broken and you could learn by fixing it. But it sounds like you learned by adding stuff to it, so that's great. Hopefully the structure I used helped you understand how to think about the problem in a more linear (computer-y) way.

I love teaching, so that was its own reward. Maybe in the future somebody will need help developing prints, and you can step in on that :)

The 60 LEDs you mentioned are those 5050 SMD LEDs on foil tape. I use those all the time. Worst case, the one at the end will be voltage starved and look sick. As long as they're rated at the same or higher voltage your microcontroller is outputting, you're probably fine.

Send us a photo of your setup, though!

Haha, I meant more that you made it seem so easy! Out of curiousity, how long did it take you to write? My day job is teaching (not photography) so I do get that :)

It definitely helped a lot, not paying close enough to what the curly brackets were including/excluding from a function was a decent-sized part of the learning curve for me. It took me quite a while to figure out the last part (extending the count beyond 15) but when I did it was a real "aha!" moment.

I actually took a video of it to show a mate, here it is on the breadboard: https://youtu.be/rk6BIcAJuOw

I'm planning on picking up a prototyping board to solder everything in place, as well as some big fat buttons at the electronics store when I'm out running errands today. Also gonna start 3D printing an enclosure for it.

Ethics_Gradient fucked around with this message at 20:53 on Jan 31, 2023

cruft
Oct 25, 2007

Ethics_Gradient posted:

Out of curiousity, how long did it take you to write?

I dunno, maybe 5 minutes? Most of the time was just trying to understand what you wanted.

That's a nice looking display, I figured it would be dinky but that's massive! What software are you using to model the enclosure?

Ethics_Gradient
May 5, 2015

Common misconception that; that fun is relaxing. If it is, you're not doing it right.

cruft posted:

I dunno, maybe 5 minutes? Most of the time was just trying to understand what you wanted.

That's a nice looking display, I figured it would be dinky but that's massive! What software are you using to model the enclosure?

Haha, took me hours to figure everything out.

Yeah, I bought the biggest one I could find that would run off of 5V so it'd be easily readible and powered off the Arduino/my USB battery. I'm now trying to go the other way and find the tiniest 2 digit display, so I can make a handheld one that fits into a 3D printed helper tray (basically a little plastic tray barely bigger than your plate, that helps you handhold/keep your chemistry on it while it's developing). Totally unnecessary but a fun little project that'll stretch me a bit more.

I use Fusion 360, although my educational license is about to run out (quit my old school to go freelance doing casual relief work before I move later this year, lost my .edu email address). I think the free version is still pretty full featured though?

One little niggling thing that I think I know how to solve - my little speaker makes periodic clicks when the device is plugged in, I'm guessing from background noise produced by whatever processes the Arduino has going on in the background. What value resistor would be good to place between it and the digital pin to filter this out?

cruft
Oct 25, 2007

Ethics_Gradient posted:

Haha, took me hours to figure everything out.

I'm going to guess you haven't written code five days a week for 30 years :wink:

quote:

One little niggling thing that I think I know how to solve - my little speaker makes periodic clicks when the device is plugged in, I'm guessing from background noise produced by whatever processes the Arduino has going on in the background. What value resistor would be good to place between it and the digital pin to filter this out?

There shouldn't be any clicks on your speaker pin. Adding a resistor will for sure make it so you can't hear the clicks as well, but it'll also mean you can't hear the speaker as well, since it will attenuate the signal going to it, like adding a permanently-adjusted volume knob.

I couldn't say what's causing the clicking but I might be able to help if you can get a recording of it. But for starters, maybe just try a different pin for the speaker. Perhaps the display driver code is also sending something out on that particular pin.

Sagebrush
Feb 26, 2012

Ethics_Gradient posted:

edit: another question - am I safe plugging in a strip of 60 5V (4W, according to the manufacturer) LEDs to replace the single one I have on D11? Just tried it and it worked fine, but wasn't sure about long term. They're pretty dainty.

You are driving the LEDs directly from pin D11? Like the anode of the LED is connected to the pin, the cathode to ground, and you're turning it on and off directly with digitalWrite()?

I would not replace that setup with a string of 60 LEDs, no way. The digital pins can source maybe 50 milliamps of current in low-impedance (OUTPUT) mode, and even little 5050 LEDs will draw 10 or more milliamps each. You should not be trying to pull 600mA from the pin. First of all you probably can't, and if you could, you would almost certainly burn out the Arduino. I am surprised it works at all, if by "just tried it" you mean you just hooked up the positive and negative to D11 and ground. I'd imagine they are glowing very dimly, with more like 1-2 milliamps per LED. That is enough to light them up but it's nowhere near full brightness.

The correct way to do this is with a relay board or a solid-state equivalent like a MOSFET.

e: okay, I looked at the strip's datasheet. 5 volts, 4 watts = 800 mA, or 15 mA per LED. Pretty dang close to what I guessed, lol. And yeah that is far far beyond what the Nano's digital pins are rated to provide. Get yourself a relay module and you won't have to worry about burning out the board, and the LEDs will probably be like an order of magnitude brighter too.

Sagebrush fucked around with this message at 02:25 on Feb 1, 2023

Hadlock
Nov 9, 2004

I tried running one, then three and four servos (tower pro 80/90s, little tiny toy things) off an arduino. One would run ok, two would run ok. Four moving at the same time would create a voltage dip so severe it would restart the arduino. Servos pull way more power than an LED, but same general concept. Had to buy a controller/daughter board with it's own dedicated power supply to feed the controller board. Pretty sure adafruit sells some sort of LED controller daughterboard. I would guess they're in the $8-25 range depending on need

Ethics_Gradient
May 5, 2015

Common misconception that; that fun is relaxing. If it is, you're not doing it right.

Sagebrush posted:

You are driving the LEDs directly from pin D11? Like the anode of the LED is connected to the pin, the cathode to ground, and you're turning it on and off directly with digitalWrite()?

I would not replace that setup with a string of 60 LEDs, no way. The digital pins can source maybe 50 milliamps of current in low-impedance (OUTPUT) mode, and even little 5050 LEDs will draw 10 or more milliamps each. You should not be trying to pull 600mA from the pin. First of all you probably can't, and if you could, you would almost certainly burn out the Arduino. I am surprised it works at all, if by "just tried it" you mean you just hooked up the positive and negative to D11 and ground. I'd imagine they are glowing very dimly, with more like 1-2 milliamps per LED. That is enough to light them up but it's nowhere near full brightness.

The correct way to do this is with a relay board or a solid-state equivalent like a MOSFET.

e: okay, I looked at the strip's datasheet. 5 volts, 4 watts = 800 mA, or 15 mA per LED. Pretty dang close to what I guessed, lol. And yeah that is far far beyond what the Nano's digital pins are rated to provide. Get yourself a relay module and you won't have to worry about burning out the board, and the LEDs will probably be like an order of magnitude brighter too.

Yeah, straight off the pin. It worked fine, ran plenty of cycles with no apparent ill effects (I considered it might be an overload, but I also have more spare Nano boards than I know what to do with thanks to an Ali Express binge when I was starting out last year), but I'll take your word for it. You can see in the video how they light up, I wasn't expecting them to be any brighter than that and I don't actually want them too bright.

I'll be honest: I had a hazy recollection that the Arduino can't supply a lot of power directly, and was surprised they worked, because 60 LEDs is a lot more than one. Maybe my AliExpress ones have some extra lead or cadmium or whatever in them giving it some temporary chutzpah.

Would something like this suit for the relay?

https://www.ebay.com.au/itm/1551986...%3ABFBM4oLhyMFh

Actually, what, if any options are there for lower power LEDs running straight off an Arduino? I was thinking of making a much more compact, handheld version of this (integrated into a developing tray for 4x5" plates) and using 15 small red LEDs as time indicators, and would like to try and keep the electronics as light and compact as I can.

cruft posted:

But for starters, maybe just try a different pin for the speaker. Perhaps the display driver code is also sending something out on that particular pin.

I'll give that a go!

Ethics_Gradient fucked around with this message at 11:59 on Feb 1, 2023

shame on an IGA
Apr 8, 2005

Hadlock posted:

I tried running one, then three and four servos (tower pro 80/90s, little tiny toy things) off an arduino. One would run ok, two would run ok. Four moving at the same time would create a voltage dip so severe it would restart the arduino. Servos pull way more power than an LED, but same general concept. Had to buy a controller/daughter board with it's own dedicated power supply to feed the controller board. Pretty sure adafruit sells some sort of LED controller daughterboard. I would guess they're in the $8-25 range depending on need

Yeah best practice in the industrial PLC world is to run controllers, input sensors and output actuators from three independent power rails

cruft
Oct 25, 2007

,

Sagebrush posted:

e: okay, I looked at the strip's datasheet. 5 volts, 4 watts = 800 mA, or 15 mA per LED. Pretty dang close to what I guessed, lol. And yeah that is far far beyond what the Nano's digital pins are rated to provide. Get yourself a relay module and you won't have to worry about burning out the board, and the LEDs will probably be like an order of magnitude brighter too.

I have to ask what the price is of the relay and new power supply vs. the price of replacing a burned out nano.

If you're worried about voltage starvation, OP, I think it'd be cheaper to just cut your LED strip in half.

e: Another option would be to buy (or salvage from some broken thing) a 5V power supply with, say, 5 or more amps, and wire the Arduino and LED strip in parallel.

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
In general, you should never have a GPIO pin driving anything. With the exception of something small like an LED. The GPIO pin should be activating whatever is driving the thing you need to turn on.

cruft
Oct 25, 2007

cruft posted:

e: Another option would be to buy (or salvage from some broken thing) a 5V power supply with, say, 5 or more amps, and wire the Arduino and LED strip in parallel.

This actually won't work for the type of LED strip you have. So your options are:

  • Go back to just one LED
  • Trim your strip down from 60 to, like, 15 or fewer
  • Buy a relay or MOSFET and higher-amp power supply and rewire so the relay closes the circuit with the LEDs and the beefy PSU
  • Wait and see if your current setup actually kills your Arduino

Me, I would go with the "trim strip" option. My brother in law, who does this kind of thing for a living, would go with the "wait and see" option. Several posters ITT are suggesting the MOSFET/Relay option.

Which one are you going to do, OP? :ohdear:

HolHorsejob
Mar 14, 2020

Portrait of Cheems II of Spain by Jabona Neftman, olo pint on fird
Echoing everyone above me scratching their heads. I'm curious how you're YOLOing those LEDs without destroying the board immediately. An I/O pin on a microcontroller can only source or sink 5-30 mA (depending on the chip) without blowing out. It's protected in pull-up or pull-down mode, but only because it's internally limiting the current going through the pin to a few mA.

Connecting an I/O pin to an LED strip that can draw 800 mA is effectively shorting the pin to either VCC or ground. If it's not blowing out, either the pin is in pull-up/down mode and you're getting a piddly glow, or there's a MOSFET or something on the board that's actually handling the current, and whatever pin you're using on the MCU is driving it.

Ethics_Gradient
May 5, 2015

Common misconception that; that fun is relaxing. If it is, you're not doing it right.

HolHorsejob posted:

Echoing everyone above me scratching their heads. I'm curious how you're YOLOing those LEDs without destroying the board immediately. An I/O pin on a microcontroller can only source or sink 5-30 mA (depending on the chip) without blowing out. It's protected in pull-up or pull-down mode, but only because it's internally limiting the current going through the pin to a few mA.

Connecting an I/O pin to an LED strip that can draw 800 mA is effectively shorting the pin to either VCC or ground. If it's not blowing out, either the pin is in pull-up/down mode and you're getting a piddly glow, or there's a MOSFET or something on the board that's actually handling the current, and whatever pin you're using on the MCU is driving it.

Your guess is as good as mine (well, probably infinitely better informed), you can watch the video I linked a couple posts up, somehow it's working/board is still alive. The circuit for it goes D11 -> 330 ohm resistor -> LED strip -> ground rail. Looking back at the code, the pin isn't in pullup or pulldown mode (just set as output in the void setup loop).

It's a bog standard Nano that I bought off AliExpress (to the best of my recollection) so I don't think it would have any intgrated special power handling stuff like a MOSFET.

I do have a multimeter, would putting the probes on either side of the LED give us some helpful info? My curiousity is piqued too, and I don't mind risking the Nano for another couple cycles of the program.

If this 5V relay will work, I'll definitely buy one and wire the LEDs up to it. I could probably get by with trimming it down to 15, but since it's mainly meant to be seen out of the corner of one's my eye, the bigger it is the better.

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
If the 330 ohm resistor is in series, then the most current you could get would be 15mA.

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib

Cojawfee posted:

If the 330 ohm resistor is in series, then the most current you could get would be 15mA.

And now we know how it's not blown up.

Ethics_Gradient
May 5, 2015

Common misconception that; that fun is relaxing. If it is, you're not doing it right.

Cojawfee posted:

If the 330 ohm resistor is in series, then the most current you could get would be 15mA.

sharkytm posted:

And now we know how it's not blown up.

Ahh, there we go! So there's no danger leaving it with the resistor? I'm happy with the level of brightness as is.

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
You could if you want, it's just bad practice.

Ethics_Gradient
May 5, 2015

Common misconception that; that fun is relaxing. If it is, you're not doing it right.

Cojawfee posted:

You could if you want, it's just bad practice.

Would you be able to explain why? I've tried searching a few different combinations of terms on Google but haven't been able to find an answer.

I know for a single LED it's to keep it from drawing too much current and burning out, but couldn't find much about using a resistor with an LED strip (I guess because it's not good practice, but nobody talks about it or explains why).

Sagebrush
Feb 26, 2012

Well no, it's fine to leave the resistor in place and do what you're doing. Nothing will blow up. Just that if you are running the entire strip at 15mA, that's only 75 milliwatts of power when the strip is rated for 4,000. One fiftieth of the intended brightness, more or less. This dim red light for a darkroom is probably the only place where this is acceptable, lol.

Hook the strip up directly to a 5v/1A power supply if you want to see what it's really capable of.

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius

Ethics_Gradient posted:

Would you be able to explain why? I've tried searching a few different combinations of terms on Google but haven't been able to find an answer.

I know for a single LED it's to keep it from drawing too much current and burning out, but couldn't find much about using a resistor with an LED strip (I guess because it's not good practice, but nobody talks about it or explains why).

IO pins are meant to be signals, not drivers. So you use the IO pin to turn on a transistor or a relay, and then that relay or transistor is what sources all the current you need for what you're doing. If what you're doing stays under the current limit of that pin and it gets you the result you want, that will probably fine, it's just not the "right" way to do it.

Ethics_Gradient
May 5, 2015

Common misconception that; that fun is relaxing. If it is, you're not doing it right.
Remembered I had another question, for a future project!

Another thing I wanted to make was a recirculating plate washer (it's necessary to run a bunch of water over the plates to clear the residual fix so that they're archivally stable, prior to varnishing). Typically I just put them under the tap in the bathtub or sink when I get home, but I would really like an "off grid" solution for doing it in the field.

Part of the issue with the off the shelf 12v pumps I've seen is that they all look too powerful; from some of the videos I've seen there's a very real chance water moving that aggressively might rip the collodion off the plate, and just generally be splashy and messy. The adjustable ones are quite expensive and don't really give a minimum flow rate, just max. I'm also not wild about running any accessories of my van's starter battery, have been on the lookout for a secondhand deep cycle battery for a few weeks but no luck.

Would I be OK running a 5-12V pump like this directly off a USB battery bank? Again, low flow rate would be a feature rather than a bug.

Sagebrush posted:

Well no, it's fine to leave the resistor in place and do what you're doing. Nothing will blow up. Just that if you are running the entire strip at 15mA, that's only 75 milliwatts of power when the strip is rated for 4,000. One fiftieth of the intended brightness, more or less. This dim red light for a darkroom is probably the only place where this is acceptable, lol.

Hook the strip up directly to a 5v/1A power supply if you want to see what it's really capable of.

Ahhh, gotcha!

The narrow wavelength of the red LED's is supposed to be fine for what I'm doing (wet plate collodion, it's orthochromatic so can't "see" that far down into the visible light spectrum), but I don't want it to be too bright/flashy.

shame on an IGA
Apr 8, 2005

very simple solution for your pump issue: don't direct the flow from the pump onto the plates at all. Set up a bucket or bowl or tank above your plate with with some tubing and let the water gravity-feed where and at the flow rate you need, then just pump from a corner of the tray your plates are in back to the tank.

cruft
Oct 25, 2007

Sagebrush posted:

Hook the strip up directly to a 5v/1A power supply if you want to see what it's really capable of.

For the benefit of the thread, OP, please (temporarily) do this, so you can report in on what the difference is. You can probably just connect the red wire to the 5V pin on your Arduino to get a close approximation.

I'm eagerly looking forward to the "GREAT GOOGLY MOOGLY THAT WAS BRIGHT" post.

Splode
Jun 18, 2013

put some clothes on you little freak

Cojawfee posted:

IO pins are meant to be signals, not drivers. So you use the IO pin to turn on a transistor or a relay, and then that relay or transistor is what sources all the current you need for what you're doing. If what you're doing stays under the current limit of that pin and it gets you the result you want, that will probably fine, it's just not the "right" way to do it.

I dunno, if you're using electronic components within their stated specifications then it's not wrong.

Even in terms of best or common practice, it's pretty common to drive an LED from a GPIO pin directly.

What is a bit weird and perhaps not best practice is using an entire LED strip with a single resistor (and also running LEDs with such a tiny fraction of their rated current- normally you'd just use less LEDs and save money). This is only "wrong" in that it is not a very cost efficient way of using the LEDs, but buying more parts would be missing the forest for the trees.

If you do ever need more brightness you're going to need to rethink the circuit, but if you don't then it's fine.

Ethics_Gradient
May 5, 2015

Common misconception that; that fun is relaxing. If it is, you're not doing it right.

shame on an IGA posted:

very simple solution for your pump issue: don't direct the flow from the pump onto the plates at all. Set up a bucket or bowl or tank above your plate with with some tubing and let the water gravity-feed where and at the flow rate you need, then just pump from a corner of the tray your plates are in back to the tank.

I was thinking even with a reservoir for the outlet to go into it's still be kicking up a fair bit of errant splashes (this will be in a big plastic container at the back of my van, but I'll have to take the lid off to load new plates in) but I guess if I put a lid on the reservoir snugly it won't be able to do that.

A 5V pump like like I linked hooked up directly to a USB battery bank would work for that though, right?

Splode posted:

I dunno, if you're using electronic components within their stated specifications then it's not wrong.

Even in terms of best or common practice, it's pretty common to drive an LED from a GPIO pin directly.

What is a bit weird and perhaps not best practice is using an entire LED strip with a single resistor (and also running LEDs with such a tiny fraction of their rated current- normally you'd just use less LEDs and save money). This is only "wrong" in that it is not a very cost efficient way of using the LEDs, but buying more parts would be missing the forest for the trees.

If you do ever need more brightness you're going to need to rethink the circuit, but if you don't then it's fine.

Yeah, it seems I've accidentally stumbled on the optimal, if inelegant solution for my situation by dumb luck. I had the LED strip laying around from an earlier project, so buying more (or buying a $5 relay and waiting for that to come in the post) doesn't really make sense compared to whacking a 330ohm resistor in series and calling it good. I also wanted maximum surface area and not a lot of brightness for the darkroom application; it's better to have things a bit dim not just for not accidentally fogging the plate, but also so my eyes stay better adjusted to the dark and I can spot any light leaks.

cruft posted:

For the benefit of the thread, OP, please (temporarily) do this, so you can report in on what the difference is. You can probably just connect the red wire to the 5V pin on your Arduino to get a close approximation.

I'm eagerly looking forward to the "GREAT GOOGLY MOOGLY THAT WAS BRIGHT" post.

It didn't seem to do anything on the 5V pin but there already was one coming off that for the 7 digit display. I thought I had a bare USB cable for experimenting but can't find it, I will try it when I get the chance. Looking at the LED's again I can say they're pretty dim compared to the other ones I have.

cruft
Oct 25, 2007

Ethics_Gradient posted:

It didn't seem to do anything on the 5V pin but there already was one coming off that for the 7 digit display. I thought I had a bare USB cable for experimenting but can't find it, I will try it when I get the chance. Looking at the LED's again I can say they're pretty dim compared to the other ones I have.

I hope you realize that at this point the thread is just goofing around with you (with you, not at your expense). You already have a working gadget (congratulations!) and now we all just want to noodle around with your components for no other reason than there's nobody else posting at the moment.

So, like, please feel encouraged to just be, like, "nah".

Splode
Jun 18, 2013

put some clothes on you little freak
yeah don't blow up your LEDs for the thread's curiosity!

I hope your gadget suits your purposes.

Funnily enough you have stumbled on to something I discovered myself at work: it is often better to run LEDs at a tiny fraction of their max current. I had a terrible habit of carefully calculating a resistor value to put 5-10mA through indicator LEDs, and then they'd be annoyingly bright. Now I just thoughtlessly throw down a 1k and know it'll be visible, but not annoying. Less effort for a better result.

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib

Splode posted:

yeah don't blow up your LEDs for the thread's curiosity!

I hope your gadget suits your purposes.

Funnily enough you have stumbled on to something I discovered myself at work: it is often better to run LEDs at a tiny fraction of their max current. I had a terrible habit of carefully calculating a resistor value to put 5-10mA through indicator LEDs, and then they'd be annoyingly bright. Now I just thoughtlessly throw down a 1k and know it'll be visible, but not annoying. Less effort for a better result.

Meanwhile I carefully calculate resistor values so they're just barely visible because I'm concerned about that extra couple of mA. 1mA for a year is a D cell. Different strokes and all...

Splode
Jun 18, 2013

put some clothes on you little freak

sharkytm posted:

Meanwhile I carefully calculate resistor values so they're just barely visible because I'm concerned about that extra couple of mA. 1mA for a year is a D cell. Different strokes and all...

oh yeah if its battery powered I just don't have LEDs at all if I can help it. If I have to have it, I usually try and fix the energy problem with software rather than hardware though. Making the LED briefly flash rather than stay on saves so much power.

cruft
Oct 25, 2007

Splode posted:

oh yeah if its battery powered I just don't have LEDs at all if I can help it. If I have to have it, I usually try and fix the energy problem with software rather than hardware though. Making the LED briefly flash rather than stay on saves so much power.

And making it flash *really fast* has the effect of dimming it! You can just call analogWrite(LED, 1) and it will output a pulse-width modulation signal with a 0.4% duty cycle, allowing you to skip adding the resistor :)

Splode
Jun 18, 2013

put some clothes on you little freak
Got a weird question for you all.
I have a project going on an ESP32. I'm using the arduino IDE because its easy and I am lazy.
However, I needed the more powerful touch sensor library functions from the ESP32's SDK.

Currently, I am doing it with this absolutely horrendous include line:

code:
#include "/home/splode/.arduino15/packages/esp32/hardware/esp32/2.0.7/tools/sdk/esp32/include/driver/esp32/include/driver/touch_sensor.h"
This does actually work, but its obviously extremely not portable, and also I have to correct it whenever the board package updates (earlier today I had to change 2.0.6 to 2.0.7, for example). If I ever want to compile this on a different computer, this would also have to be modified - extensively if it was a windows machine rather than linux.

Is it possible to reference this header file in a cleaner way, or am I just paying the price for being lazy and using the Arduino IDE?

(oh by the way - yes I am aware the touch sensor esp32 functionality is built into arduino as "touchread" - but this gives me a lot less control than I need, as I am using it as a capacitive sensor rather than a touch button)

Edit: figured it out!
I just used Sketch -> Add file, navigated to the header in question, and bam - now the reference to it is just
code:
#include "touch_sensor.h"
, and a copy of the file sits in the same directory as my project so git picks it up. Leaving this here in case anyone else runs into this very specific issue

Splode fucked around with this message at 12:38 on Mar 7, 2023

ToxicFrog
Apr 26, 2008


So my partner is getting into Arduining, and since they didn't really get an education in electrical circuit basics as a kid they're reading through the tutorials on the Arduino site.

In general they're finding that the Arduino documentation tends to assume way more electrical knowledge and way less programming knowledge than they already have, which isn't great in general, but also a lot of the tutorials look like this:

Guide to 3V3 and 5V power supplies posted:

Sometimes the electronic device, that should receive 3.3V level of input from the supply may receive a "dirty" tension. This causes the electronic device to suffer abnormal electronic behaviour. As it could destabilise the system completely or change the logic forcefully due to changed logic range to be unrecognised. There are more of this undesired behaviour, if over-voltage or over-current is introduced to the system.

So for this matter, how do we protect the system? The solution can be based of the proper Reverse Polarity Protection showed previously. The proper Polarity Reverse Polarith Protection implements a bidirectional Transient Voltage Suppressor while adding the P-Channel MOSFET with a zenerdiode and two resistors to get all its flavours.
Which has me wondering if this is even the correct site or if docs.arduino.cc is the user-generated-content slop bucket or something.

cruft
Oct 25, 2007


This right here is why I didn't get into electronics until I could do it in C.

namlosh
Feb 11, 2014

I name this haircut "The Sad Rhino".

That is shockingly poor writing… when I started picking up electronics and arduino/microcontrollers, I mainly stuck with:
the arduino forums
sparkfun
but mostly YouTube.

I actually prefer written articles to videos on topics I’m trying to learn most of the time… but the world is changing and I’m trying to adapt :)

e:
vvvvv totally
I don’t have the link handy, but in the electronics thread there’s a goon parts swap spreadsheet that also has a huge list of YouTubers on another tab. I know there are a few in there that are microcontroller specific too

namlosh fucked around with this message at 15:59 on Mar 11, 2023

cruft
Oct 25, 2007

namlosh posted:

That is shockingly poor writing… when I started picking up electronics and arduino/microcontrollers, I mainly stuck with:
the arduino forums
sparkfun
but mostly YouTube.

I actually prefer written articles to videos on topics I’m trying to learn most of the time… but the world is changing and I’m trying to adapt :)

Adafruit Learn is another superb resource.

DreadLlama
Jul 15, 2005
Not just for breakfast anymore
Does anyone know how to unbrick an Arduino 328p processor?

I have a minimOSD that I tried to flash using a too-recent version of CT tool available at https://code.google.com/archive/p/minimosd-extra/downloads. According to a thread on the internet:

quote:

Silicon Labs introduced driver 2.12.0.0 back in October 2015 which (unless you have a genuine Silicon Labs chip on your FTDI) will do a soft 'brick' on your device. For none genuine SiLabs FTDI device (90% of things with a Silicon Labs chip from China), you need to download an older driver.

I reverted to the 2014 driver, but the board doesn't work. I guess I bricked it when I tried to read from it with the more recent version. I didn't write anything with it. It just failed to read, and now when I try to use the older version it says "failed to talk to bootloader" and "the EEPROM mapping is outdated. An automatic update will start." And then "failed to talk to bootloader" again. And finally, "EEPROM mapping updated!" but it still doesn't work. The minimOSD-extra config tool says to try again with arduino. That's what I'm trying to do now. I think I set it up correctly:




quote:

avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'
Failed chip erase: uploading error: exit status 1

I thought I connected everything correctly. Rx goes to Tx, Tx goes to Rx, GND goes to GND, 5V is connected to 5V, and 3V3 isn't connected because the minimOSD doesn't have anything labelled 3V3. The lights are on.


But it didn't work. I hope that I'm missing something stupid obvious. I tried with both the USBasp and the FTDI chip, but neither worked, although I got a progress bar for a few seconds using the FTDI chip. But in the end I got the same error message

quote:

avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'
Failed chip erase: uploading error: exit status 1

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
If the board has ICSP pins and you happen to have another arduino or a programmer, you can write a new bootloader to it.

Something like this:
https://support.arduino.cc/hc/en-us/articles/4841602539164-Burn-the-bootloader-on-UNO-Mega-and-classic-Nano-using-another-Arduino

DreadLlama
Jul 15, 2005
Not just for breakfast anymore
Awesome! Thank you!

There's 6 unlabeled through holes in the middle. Are any of them ICSP? It looks like the top-left pin is labelled ISP. Is it possible that's short for ICSP?





edit: I'm going to assume that they are. The 3x2 orientation seems to match the article you linked. How do you tell which pin is which though?

edit2: If I just connect pins randomly, will I brick the arduino? There's a finite number of possible combinations. One will work eventually, right?

DreadLlama fucked around with this message at 17:41 on Mar 16, 2023

Adbot
ADBOT LOVES YOU

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
Someone else can check my math, but assuming the chip on the left is the 328P (which seems to line up with where the traces are going. It's this:

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply