9 votes

Input Oscillating Wildly

Pins configured as INPUT are in a high impedance state and very sensitive to electrical noise from the environment, especially with wires connected to them See Arduino Tutorial Try using INPUT_PULLUP ...
Bra1n's user avatar
  • 1,008
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'...
gbg's user avatar
  • 518
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 ...
Majenko's user avatar
  • 105k
5 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 ...
Duncan C's user avatar
  • 5,682
5 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 ...
Duncan C's user avatar
  • 5,682
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)...
Majenko's user avatar
  • 105k
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.
st2000's user avatar
  • 7,325
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 ...
VE7JRO's user avatar
  • 2,566
4 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 .....
KIIV's user avatar
  • 4,752
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), ...
Edgar Bonet's user avatar
  • 43.1k
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 ...
Majenko's user avatar
  • 105k
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. ...
Edgar Bonet's user avatar
  • 43.1k
4 votes
Accepted

Safe to solder a slide switch to unused GPIO pins?

Yes, you will lose the USB connection, since PB3 and PB4 are used for the USB communication. Normally you wouldn't solder a component directly onto a board if it doesn't fit with all pins. Instead you ...
chrisl's user avatar
  • 16.3k
4 votes

Please help me with my project of water pump relay switching too fast

The problem lies in the specification itself. According to your rules, what should the pump do if the water level is exactly 2 cm? Granted, there is no such thing as an exact physical measurement. But ...
Edgar Bonet's user avatar
  • 43.1k
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 ...
Mark Smith's user avatar
  • 2,181
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 ...
Hantarish's 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 ...
zdub's 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: ...
sa_leinad's user avatar
  • 3,188
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 ...
phlogratos's 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 ...
Gerben's user avatar
  • 11.3k
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-...
Majenko's user avatar
  • 105k
3 votes

State machine sketch to drive a DC motor with limit switches

You have created a flow chart. When discussing state machines it is better to use a state diagram. In this state diagram of a turnstile (from the state machine wikipedia page linked to above) it is ...
st2000's user avatar
  • 7,325
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 ...
Michel Keijzers's 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 ...
gabonator's user avatar
  • 371
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 ...
Jeff Wahaus's 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: .....
chrisl's user avatar
  • 16.3k
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 ...
Rudy's user avatar
  • 993
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 ...
JRobert's user avatar
  • 15.3k
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 ...
chrisl's user avatar
  • 16.3k
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, ...
Michel Keijzers's user avatar

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