2022 Developer Survey is open! Take survey.

Hot answers tagged

6 votes
Accepted

How to switch 12V with esp32?

BC549 provides strong pull-down for IRFR5305, which is provides up to +12V at 16A with less than 0.09 Ohm channel resistance. This circuit works well with ESP8266, I use it in some of my devices. Don'...
user avatar
  • 503
5 votes
Accepted

Switch a 12V 3.3A component from an Arduino

A relay, as pictured, is a good choice. It provides complete galvanic isolation and switches the power properly. Another option is to use a MOSFET that can handle enough current (an N-channel ...
user avatar
  • 101k
5 votes
Accepted

Switching fan on with transistor, fan running very slowly

With a 2.2K resistor you're massively limiting the current that can flow through the transistor. I haven't looked up the specs on that transistor, but taking typical values for Vbe (0.6V) and Hfe (100)...
user avatar
  • 101k
4 votes

Switching Many Switches with one Input

Almost, you will need two 74157 (or similar chips) to switch 8 pairs of TTL level logic signals down to 8 individual signal.
user avatar
  • 6,451
4 votes

SPST switch - powered from pin output, or voltage regulator

You could configure one of the digital pins as INPUT_PULLUP and connect one end of the switch to it. The other end of the switch goes to ground. LOW = switch ON, HIGH = switch OFF. const byte ...
user avatar
  • 2,471
4 votes
Accepted

How to boil down analog input to just three cases?

The simplest fix to your problem is to change the map() call to byte alrmSet = map(alrmSwState, 0, 1024, 0, 3); In the call above, the mapped intervals are of the semi-open type, e.g. [a, b), ...
user avatar
  • 35.5k
4 votes
Accepted

LED on same Pin as Toggle Switch, not illuminating

LEDs have a (fairly) fixed voltage drop across them. The red LED is about 2V. You can use that to work out the voltage at the input. You basically have a voltage divider, with your 200Ω resistor as ...
user avatar
  • 101k
4 votes
Accepted

How to wire a three-pin on-off-on switch for reading input?

You talk about wiring a switch to control lights directly. Instead, you want to use your switch to send information to your Arduino. You link to an SPDT (single pole, double throw) switch. When ...
user avatar
  • 5,509
4 votes

How to wire a three-pin on-off-on switch for reading input?

I suggest this simple circuit: simulate this circuit – Schematic created using CircuitLab Set both inputs to INPUT_PULLUP. If the input reads LOW, that means it has been grounded by the switch. ...
user avatar
  • 35.5k
3 votes
Accepted

Intermittent LOW reading from input pin set to INPUT_PULLUP

My guess would be that you're getting noise interference on the line and it's too much for the Arduino's little internal pullup. Try adding an external pullup resistor - say 5k-10k (exact value is ...
user avatar
  • 2,147
3 votes

USB connector between Arduino and a lever (switch)

I'd suggest using a multimeter to figure out what's connected to what after hooking up the complete wiring scheme; there aren't that many options and you should be able to figure out what's connected ...
user avatar
3 votes

Is there a cheap relay that can control voltage from stuff like bulb lights with a 5 V control output?

You can use a 5V Solid-State Relay module to control light bulbs. They cost $4-6 from US-based suppliers and $1-3 from a Chinese supplier. Just hook up the supply to the center pin and the load to ...
user avatar
  • 141
3 votes
Accepted

LED and Switch Compolation Error Arduino 101

I notice that your pinMode function calls are not quite correct: pinMode(Sender = OUTPUT); // Setting pin two to output pinMode(Reader = INPUT); // Making pin 12 set to read switch data Should be: ...
user avatar
  • 3,042
3 votes
Accepted

digitalRead not reading input pin of ESP8266-01

The expression read3 + " input" performs pointer arithmetic, i.e. you either add 0 or 1 to the start adress of " input", so you get either " input" or "input". Does the leading space disappear when ...
user avatar
3 votes
Accepted

Button with switch timer and reset time function + LED feedback. What am I doing wrong?

Written and tested. I also included the red blinking led. //CONSTANTS const int BUTTON_PIN = 2; // Button const int in1 = 7; const int greenLED = 4; const int redLED = 9; //VARIABLES int ...
user avatar
  • 11.1k
3 votes

Alternative of relay

A relay is just an electromagnet, and the same circuit that can drive a relay can drive an electromagnet. You just need to make sure it can handle the power. The simplest circuit is to use an N-...
user avatar
  • 101k
3 votes

Small Baseball Scoreboard using 2 to 3 breadboards

Actually, you can very easily verify this yourself: Per item (1602LCD, 7 segment LCD and LEDs check how many pins you need and what type, like e.g. I2C or SPI for the 1602 LCD). The 7 segment ...
user avatar
3 votes
Accepted

SPST switch - powered from pin output, or voltage regulator

It is wasting of IO pins to use the digital output pin just to get +5V rail. But both options will work. Don't forget to use pull/up or pull/down resistor, or activate internal pull/up resistor on the ...
user avatar
  • 371
3 votes

Can i use a range in a switchcase like in pascal?

There are some GNU extensions available in the avr-gcc/avr-g++ compilers (used in Arduino IDE for AVR based Arduino boards). One of them is suport of ... for the case: switch (i) { case 10 .....
user avatar
  • 4,092
3 votes

How to boil down analog input to just three cases?

Replace the line: byte alrmSet = map(alrmSwState, 0, 1023, 0, 2); with byte alrmSet = alrmSwState / ((1023 / 3) + 1); And this should do what you want. Note that in C fractional results are ...
user avatar
3 votes
Accepted

Defining array in switch case

If you want to declare multiple variables with the same name inside different case statements, you can enclose the code inside each of them inside curly braces: case 1:{ Code... break;} case 2: .....
user avatar
  • 13.7k
3 votes

Using a toggle switch to run part of a sketch

There are different ways to accomplish the same thing. The condition is a flag, or a read port. if(digitalRead(inPin)) { // Your first code here. } else { // second code ...
user avatar
  • 985
3 votes

Running in loop or once according to a slide switch position

Let's assume the switch is on pin 9, that the pinMode() has already been set, and that the switch reads HIGH for loop operation. #define MODE_SWITCH 9 #define DO_LOOP HIGH // This loop will ...
user avatar
  • 14.4k
3 votes
Accepted

How to use this Toggle Switch?

It's basically a push button. Possible examples depend on what you want to do. As it seems, you simply want to start interfacing it with Arduino, just use it as a normal push button. Use the ...
user avatar
  • 13.7k
3 votes

How to use this 3-pin slide-switch?

Since it has two possible positions, and three pins, you have a connection between pin 1 and 2 when position 1 is selected, and between pin 1 and 3 when position 2 is selected. As BSF comment below, ...
user avatar
3 votes
Accepted

How to use this 3-pin slide-switch?

As others have said, this is a SPDT (Single Pole Double Throw) switch. The center pin is common. When the switch is slid one way, it connects the center pin to the outer pin on that side. When you ...
user avatar
  • 5,509
3 votes

Turning off a LED

1. pushpressed gets set, but never reset. It's set in stopPins() and stopPins2() if the input is HIGH. Since it's never reset back to zero, once it's been set, the logic in startBuzz and startBuzz2 ...
user avatar
2 votes

Need Help in circuit diagram of 8*8 reed switch matrix

This answer is based on a previous version of the question Not necessarily. You can use the internal pullups of the arduino if you're willing to accept that reading a "1" means that no piece is there ...
user avatar
2 votes
Accepted

Do I need resistors or capacitors on this relay?

Yes, that is too simple. The Arduino's IO pin is not designed to directly drive a relay. It needs to go through a transistor first, and you must include a diode to absorb the back-EMF generated by ...
user avatar
  • 101k
2 votes

Switch a 12V 3.3A component from an Arduino

I've just bought a few STP16NF06L fets for this very purpose, N channel MOSFET. The key part of that part number is the L at the end. This indicates low (or Logic) gate threshold, which means it will ...
user avatar
  • 404

Only top scored, non community-wiki answers of a minimum length are eligible