[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/diy/ - Do It Yourself


View post   

File: 934 KB, 2592x1552, IMAG0234.jpg [View same] [iqdb] [saucenao] [google]
830196 No.830196 [Reply] [Original]

I am currious about something:

Lets say we have a device attached to AVR microcontroller that is supposed to run exactly once during certain circumstances - it could be an alarm, mouse trap or a bomb. Is it possible that it will run on it's own? Cause in some tutorial with buttons + ATMEGA I found a suggestion to always check if button was pressed for some long time. Does that mean that sometimes ATMEGAs emit electricity on their own?

>> No.830209

>>830196
>Cause in some tutorial with buttons + ATMEGA I found a suggestion to always check if button was pressed for some long time.
it may have to do with how they had the buttons wired exactly... can you link to such a tutorial?

>> No.830212

>>830196
I don't get your question. Are you curious about how to check if a certain event, like for example a mouse trap activates, happened?

In that case, the best way to realize it would be an interrupt.

Please clarify what you are wondering about.

>> No.830215

>>830212

Let's say you have a following situation:

>Laser toy emiting light
>Light detector at the end of said laser that sends input to ATMEGA; 1 if laser light is falling on detector and 0 if it does not.
>ATMEGA, that turns on the alarm by starting to emit electricity on some pin if it gets 0 on input.

My question is: can ATMEGA turn on the alarm due to some error, even if laser was not crossed?

>>830209

No, saw it ages ago.

>> No.830294

>>830215
There's always some electrical noise, caused by fridge compressors, light switches, static electricity and whatever. If it's important that such random noise won't get registered and your actual input signal isn't particularly short, it often makes sense to add some software filtering.
An alternative (or additional safeguard) would be to add external hardware filtering.

>> No.830309

>>830215
We'd be better able to help if you'd actually describe your project to us - when you're avoiding it and trying to keep it hidden like this we're going to get confused.

This is especially true since English doesn't appear to be your first language, and you don't appear to have that deep an education in electronics.

TL;DR: Tell us more, and we'll help you out. Your question currently is vague and confusing.

>> No.830315
File: 3 KB, 320x240, bounce.png [View same] [iqdb] [saucenao] [google]
830315

>check if button was pressed for some long time
you might be thinking of switch debouncing

to you the switch seems to click on and click off instantly, but the microprocessor is like aaaaaa what the fuck is happening

>> No.830362
File: 66 KB, 800x1000, Aeternitas_Mega_4_ur8943528hr.jpg [View same] [iqdb] [saucenao] [google]
830362

>>830215
>My question is: can ATMEGA turn on the alarm due to some error, even if laser was not crossed?
okay I get it now, OP wants to make a laser-triggered bomb... well why didnt you say so?

the way you would ensure that you wouldn't get any false positive signals is that you would not use a simple on/off state for the laser. That is a simplistic method that is prone to errors.

What you could do is flash the laser at a known frequency, and have the receiver look only for that frequency.
Such as:
1--If the [whatever] is triggered, then the laser begins pulsing at 30 times per second. (you might need another MCU to do this)
2--The receiving arduino has a phototransistor that checks the light level faster than the laser pulses--say, perhaps 200 times per second.
3--When the receiving arduino gets any positive signal, it begins 'recording' for two seconds (requiring an array with 400 places).
4--Then after the two seconds is over, the receiving arduino looks at the data from position #50 to position #149. It counts how many times the signal went from a low to a high state. If it finds that the signal did this 30 times in that time span, then the arduino sets off the bomb. Or whatever.

yeppers

>> No.830423 [DELETED] 

>>830215
>My question is: can ATMEGA turn on the alarm due to some error, even if laser was not crossed?

As a feller with a couple decades working with PLC's I can guarantee that the software logic will cause undesirable results for many reasons, some of which have already been mentioned.