I am trying to do an ON/OFF switch to power up my MCU when user use a push button :
Schematics
When the user clicks once, the MCU should light up. When the user clicks a second time, the MCU should turn off.
To do this I thought of the simplest solution, in analogue, which seems to be a flip flop D.
I did some simulations on LTspice, it seems to work, but I'm not really sure.
Simulation result
I have three questions:
Why do I get 1V and not 3V at the output of the simulation?
Does this setup seem OK in reality?
What to do with the SET & RESET pins: should I leave them unconnected or connect them to GND?
Regards
The digital components of ltspice has two only 0 and 1 (low and high). Download a library for LS and for CD series to behave more like the real components. And make symbols for them.
I was writing some simple code involving a tilt ball switch, but it didn't end up working right. I messed around with the inputs and outputs and eventually I learned that when I put my fingers near the input pin, the built-in led lit up. I didn't even have to touch anything. Are the input pins just really sensitive to an electric or magnetic field in my fingers?
Here is the code that I was running: 1
When the led built-in was lighting up I only had the Arduino hooked up to a power source. The most logical thing that I can come up with (which is probably wrong) is that my fingers are magnetized which creates a magnetic flux which induces a current. So basically I'm Magneto until somebody tells me what is actually happening.
I'm not qualified to answer whether or not you are Magneto.
As for the Arduino, try adding a resistor between Pin 8 and Ground.
That should help to drain the phantom signal that your mutant powers are generating.
My setup is a PC with running Node-Red and Arduino Mega (standard Firmata) plugged via USB. I also have a push button wired to the Arduino's pin. I can read the state of the button, but I would like to distinguish a long press from a short one. For example:
short press - power toggle switch #1
medium press - power toggle switch #2
long press - power off all switches.
How can I achieve this? Do I need to write some function (I'd be glad for a little help here too, as I am no programmer) or I just have not found yet dedicated nodes?
The second scenario is not to distinguish the length but the number of times a button was pushed (in 0.5 sec for example):
1 time - power toggle switch #1
2 times - power toggle switch #2
3 times - power off all switches.
Is this easier to achieve?
Best regards,
Jakub
You will certainly have to write a function on the Arduino to have it generate some form of a message that can be sent to Node-Red.
You could use the serial interface of the Arduino to send it to the pc over the USB port and have Node-Red listen to the serial port. There are plenty of examples for Arduino to start with (a lot of them in the Arduino IDE itsself).
I have an Arduino starter set, which came with both an active and a passive buzzer. Unfortunately, I can't seem to know which is which. All I know is that one is a little longer than the other one, on which I can see the green circuit board underneath.
An active buzzer generates the sound itself. You basically just turn it on or off.
A passive buzzer needs a signal source that provides the sound signal.
To find out which is which you can measure the resistance between both leads. If it is a few Ohms its the passive one, higher values indicate an active one.
Also the active one will have it's own circuitry (the pcb you can see) and will therefor be probably bigger.
But I guess your arduino package comes with a parts list that should give you all information you need?
"Programatically" speaking:
Active Buzzer: using a simple digitalWrite(buzzerPin, HIGH) will turn the beep on, once it has a internal oscillator.
Passive Buzzer: you need to use Tone() function in order to make it beep. Once it has no internal oscillator you need to use Tone() function to create the frequency it will oscillate. Check the Tone() reference page to learn how to use it, but is quite simple, you just need to enter as parameter pin and frequency like Tone(3, 440), will generate a 440Hz on passive buzzer hooked up to pin 3.
To stop a active buzzer you need to use digitalWrite(buzzerPin, LOW), while with a passive buzzer you need to use noTone(passiveBuzzerPin).
How to distinguish passive buzzer and active buzzer?
There are several ways to distinguish passive buzzer and active buzzer.
The most simple method is to watch their different appearances.If you can see a drive board,it is passive buzzer.If the buzzer is completely covered by black adhesive,it is active buzzer.
https://www.keliking.com/Differences-Between-Passive-Buzzer-and-Active-Buzzer-id570060.html
They come in all shapes and sizes, so don't assume "long" means one thing or another. The passive buzzer has only a small piezo on the module's PCB. An active buzzer will have a couple other small components on the pcb, like an amp and resistor(s).
In the Freenove Arduino kit that i bought, the passive buzzer is the one with the green on the bottom and the active is the one without, and is slightly taller with varied hights of the pins
Physical distinction between the two.
Slight disclaimer first. . . the buzzers I have are from one of those 27 piece sensor kits. For me it was an extra buy from "30 Days Lost In Space". After my pieces all got mixed together, I've decided to lay them all out & know what each one does. Yours may be different
Here's what I observed. If you have the connections down and the buzzer away from you so you're looking at the back of the board There are solder points. The upper left solder point is filled on the active buzzer. note don't count the larger mounting hole on the very edge. In the photo, I've highlighted the filled solder hole on the active buzzer.
highlighted solder point on active buzzer -- left vs passive buzzer -- right
I had this same question, which led me here. The other answers were helpful in and of themselves, but I noticed the difference after testing, and hopefully someday this may help someone else who may be new, as I am now.
I've been at arduino just shy of 2 weeks.
Is there any benefit/reason to apply a setup & hold constraint to a push button input to an FPGA when the button is asserted asynchronously?
From what I understand a violation can still happen regardless as the button can be pressed within the setup and hold time of the flip-flop that it's connected to inside the FPGA.
Push buttons generate very slow changing signals compared to the system clock (0.001 .. 10Hz vs. several MHz). Applying setup/hold times is a waste of effort. Just apply a timeing ignore rule.
A propper synchronizer and maybe a debouncer circuit is needed anyway.
I agree with previous poster that push button input pin shouldn't be timed (use false_path). If you want to be very safe, you should probably:
Turn on Schmitt trigger for the input pin connected to the button.
Feed the input signal through 2 stage synchronizer (2 flops in serial)
Implement debouncer either using analog circuit on the board, or doing this digitally using a counter after the synchronizer.