Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [switch]

In electrical engineering, a switch is an electrical component that can break an electrical circuit, interrupting the current or diverting it from one conductor to another

0
votes
3answers
30 views

Defining array in switch case

I’m completely new to arduino, so be polite. I’m trying to program my esp32 to drive neopixels as seven segment display. So I take a digit and pass it to switch case and in switch case I mention which ...
-1
votes
1answer
31 views

Adding a switch to control log interval [closed]

HI this is a code for a set of logging scales. What I want to do is to add a switch that changes the logging from the set time of 1000 mills to either 5000 mills or 10000 mils depending on the switch ...
1
vote
4answers
143 views

How to boil down analog input to just three cases?

I am investigating the use of a 3-position-switch for one of my projects to switch between different settings using just one analog input pin. For the three positions I am using ground/0V, ~2.5V (via ...
-1
votes
2answers
41 views

Is there a key switch for Arduino? [closed]

I am trying to make a launch controller, which will turn on with a key. Like the one in this photo below:
0
votes
0answers
28 views

DIY Light Switch Trouble Shooting Help

Goal of the Project: DIY method of a smart light switch Process Used: Implement using IFTTP with: BLYNK Google Assistant NodeMCU (ESP8266 WiFi) High Voltage Relay Samsung Wall Wart for NodeMCU ...
0
votes
1answer
35 views

Arduino DC motor with 2 buttons

I have a problem with my Arduino project and I tried everything to fix it but nothing helps. I am trying to rotate my DC motor with two buttons: one button is to stop/start rotating on left side, ...
0
votes
1answer
106 views

TinkerCAD switch seems to be not working (always closed)

I am using TinkerCAD to simulate the functionality of a slide switch. Please comment if you think this question is off-topic. /* LiquidCrystal Library - Hello World Demonstrates the use a 16x2 ...
2
votes
2answers
71 views

Calculate sensor unique address with a 8 position DIP Switch

I have a large amount of sensor boards that I need to be able to configure setting unique addresses. Each sensor is attached to it's own arduino, I'm using a 8 position DIP switch for setting the ...
0
votes
3answers
63 views

Need help with a program for a button to change the display on an OLED display

So I am programming an OLED display from my Arduino Uno. I am trying to have a button that switches the different words on the display. (The words are just placeholders for programs as of now.) My ...
2
votes
1answer
41 views

How can I make a power button for my project powered by a USB powerbank? [closed]

I've solved the battery power supply issue for my Arduino project by simply connecting a USB powerbank. However, I just realised that I can't come up with a good way to add an on/off button! There ...
0
votes
1answer
60 views

Which transistor I should use to switch 12V 0.8A? [closed]

I am have circuit with Arduino NANO and I need to control air valve, which is powered with 12 Volts and 0.8 Amper. Problem is that Arduino NANO is powered with 5 volts. I want to use transistor to ...
-1
votes
2answers
76 views

Button Switch arduino

I'm trying to use my button as a switch (the led goes on after I push the button and the led goes off when I push the button again). I know I have the right circuit, because I also used a code from ...
0
votes
1answer
81 views

Transistor as switch for signal and high current buzzer [closed]

I'm a newbie in transistor switching. I have PIR sensors with C and NC onboard. NC is 12 V signal that I need to switch transistor (bipolar?) to emit 3.3 V (collector connected to 3.3 ...
0
votes
1answer
228 views

Arduino Uno Motor control using 2 Relays, 2 Limit switches and Bluetooth. Forward Reverse Stop

Modified existing project from this link: Problem : Trigger limit switch to stop DC motor I modified this code to control two relays which are wired to motor poles for Forward or Reverse movements ...
0
votes
2answers
152 views

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

in pascal's case statement i can use this: Var i : integer; ... Case i of 1..5 : DoSomething; end; i was wondering if there is a way in can do this with c/c++ in the arduino compiler using:...
0
votes
1answer
71 views

How to create “Auto switch case”

I am new to programming. I want to modify this sketch and I really need help. I have a switch case in this sketch, and what I want is an auto change effect. In this sketch 18 color effects for ...
0
votes
0answers
36 views

Push button storing in array and display sequentially without debounce

I would like to read 6pushbutton values from analog0 pin and store it in a array . And print them sequentially My project is to make a bot that could store the input commands (right left forward ...
0
votes
0answers
126 views

limit switch and external interrupt

The INT0 pin of a custom Arduino-like board based on Atmega16 is configured in INPUT_PULLUP mode and connected to a N.O contact of a limit switch, the other end of the switch is connected to GND. in ...
0
votes
1answer
28 views

Servo speed in a Toggle Code

I am new to Arduino and am trying to figure out servos. Right now I have a toggle button code for the servos. Although I want to know how to speed them up. Is there a way to do this? Currently, this ...
1
vote
2answers
42 views

SPST switch - powered from pin output, or voltage regulator

I have a SPST switch and I just want to sense whether it's on or not. I will then turn on/off a relay depending on the state of this switch. The two options I'm considering are: create a digital out ...
1
vote
1answer
71 views

Small Baseball Scoreboard using 2 to 3 breadboards

I'm helping my son start an Arduino small baseball scoreboard (roughly 2 or 3 breadboards in size). Im thinking to use qty 2, 2 digit 7 segment LED's (score of each team), an LCD 1602 module (inning ...
0
votes
1answer
83 views

Timer for Control Motor using Limit Switch

Im not good in arduino, but I have project that control motor using limit switch. The rule is: When switch OFF, motor ON When switch ON, motor OFF for 1 hour (i dont want use delay because cannot ...
1
vote
1answer
81 views

Understanding how a tilt switch works [duplicate]

I am learning Arduino and pardon me if this is nooby. I am trying to make an LED glow when the tilt switch is tilted. The LED should not glow if the tilt is in normal position. The circuit and the ...
1
vote
2answers
392 views

Crosses Initialization in switch case with different size of array per case

void setup() { Serial.begin(9600); } void loop() { time_Text(2); } void time_Text(int PastTo_val) { switch (PastTo_val) { case 1: { int tPTT_y[] = {11, 11, 11, 11}; int tPTT_x[] = ...
0
votes
1answer
53 views

Can someone help me with my arduino and relay and switch?

This is my code. What i want to do is activate the relay when switchInNcPin is activate. I am using a switch (micro switch). It has COM NC and NO pins. Can you tell me what is wrong with my code? ...
-1
votes
1answer
39 views

yellow LED not turning off in traffic light simulation

I wanted to make a simulation of a traffic light, and since I don't have any sensors I used a button to change between the different states (red/stop and green/drive). When the states are changing I ...
0
votes
0answers
1k views

Controlling a DC motor with limit switches, initiate travel from one switch to the other with button

I have a DC motor that has a limit switch at both ends of travel, when the button on cyclePin is pushed, and one of the limit switches is closed, the motor is supposed to run in the opposite direction ...
0
votes
1answer
236 views

How to make timed loops after switch / case?

I am working on a code, which is running a function once a second: switch (gearbox1) { case 1: //manually close Serial.println("Closing1"); digitalWrite(gear1OpenPin, OFF); t....
3
votes
2answers
61 views

Write a condition to execute 2 switch-case functions?

I'm new to programming and using Arduino products, and was wondering if someone wouldn't mind assisting me with a project I'm trying to tackle? If you review my code below, I have 3 conditions within ...
2
votes
2answers
650 views

State machine sketch to drive a DC motor with limit switches [closed]

I have a DC motor that will need to use two limit switches to detect end of travel in two directions. I've read that coding a state machine to do this task is the best method, however I have no idea ...
0
votes
1answer
88 views

Play .Wav sound only once on switch change [closed]

I have a project where if you change the value of the spdt switch the colour of the LEDs change. As well as this a .wav file plays. The problem is I only want the .wav to play once. At the moment it ...
-1
votes
2answers
51 views

Why the program keeps applying what is in loop in first case and stops in the second one? [closed]

In the first program after removing hand from the button it keeps on, means it keeps applying what is in the loop: int led = 13; int button = 12; void setup() { pinMode(led, OUTPUT); pinMode(...
1
vote
2answers
296 views

Use of array in case statement

I want to know how I can use case statement for each array. Below is my code: int incomingByte = 0; void setup() { Serial.begin(115200); for (int thisPin = 2; thisPin < 6; thisPin++) { ...
0
votes
1answer
140 views

What is wrong with my state machines?

My goal is to make an automatic gate and garage door, and it has a servo as the lock mechanism on the gate, and alarm systems that notify when the gate or garage door is open too long, more than the ...
0
votes
2answers
233 views

Alternative of relay

I am carrying out a physics experiment using an Arduino. This experiment requires accurate time measurements of upto a millisecond. However I am using a relay to turn on/off an electromagnet and there ...
0
votes
1answer
949 views

Problem : Trigger limit switch to stop DC motor

I want to make a project about automatic gate and garage door via Android app and connected by HC-05 bluetooth module. Each of the gate and garage door have two limit switches(located at each end of ...
-1
votes
1answer
27 views

How do I write a program that turns on both on board LEDS ONLY when BOTH switches are ON [closed]

int btn1=0; int btn2=0; void setup() { // put your setup code here, to run once: pinMode(GREEN_LED,OUTPUT); digitalWrite(GREEN_LED,HIGH); pinMode(RED_LED,OUTPUT); digitalWrite(RED_LED,HIGH)...
1
vote
1answer
202 views

Help: Using if-else on two switch state

Problem I'm stuck on triggering different switch. I'll explain what each of my switch should do. Output of this setup : No output from relayPin mainPin Main power of the switch to control relayPin ...
0
votes
2answers
76 views

Loop one specific case inside of a switch

I want to loop one specific case inside of my switch, until the button gets pressed a second time. How can i make this work? Code: const int ledrood = 9; const int ledgroen = 10; const int ledblauw =...
3
votes
1answer
2k views

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

Beginner here. I´ve been trying to implement a button function timer working with millis() instead of delay as I want the button to be responsive while the timer is running. So far I´ve managed to ...
0
votes
2answers
89 views

Why it's not possible to manipulate the TWSR directly? [closed]

I think I forgot the reason for this SFR manipulation in microcontrollers; like, checking the TWSR in twi. The technique for checking the values of the TWSR is by masking it with another variable or ...
1
vote
0answers
455 views

Switch on/off LED 24V using a MOSFET

I try to switch on/off IKEA Ledberg LEDs which are powered with 24 V using the setup from this tutorial video: https://www.youtube.com/watch?v=sVyi7yWuXxs I use a IRLB8721PBF MOSFET. When I switch ...
1
vote
1answer
100 views

How to reset an arduino while being able to know which button has been pressed?

Context I keep the board in sleep mode and want to wake it with different buttons. I need to know which button has been pushed on boot. In the following schematic, SW-R is actually used to reset the ...
0
votes
1answer
154 views

Modify On board 4 pin switch to work with Arduino

I have a HDMI Switch module which switches Input signals. It has a 4 pin push button to switch inputs. ( - ) I want to modify the button in order to control it with an Arduino. (push via Arduino ...
0
votes
2answers
61 views

Door sensors on every cabinet in the kitchen

At this point, I have yet to actually touch an Arduino. I'm toying with the RPi3 along with Home Assistant, but I'm always thinking of ways to do useless things that are fun. Let's say I had a ...
-1
votes
2answers
447 views

Using Arduino or ESP8266 as a switch to turn on a 12V DC Fan

I am new to the community and this is my first question. Hope it turns out to be a nice question :) Me and my friend are preparing a senior design project on home automation. I have several things in ...
0
votes
1answer
96 views

Code runs, then doesn't run after I add some routine code

I am programming an ESP8266-01. I have this code which I am using to operate an on-off switch, which is being used as an override switch for when the relay is turned on and off over the internet: ...
0
votes
1answer
1k views

digitalRead not reading input pin of ESP8266-01

I am trying to use a on-off switch with the ESP8266 to change whether GPI02 is HIGH or LOW. I am using GPIO3 as input. My circuit looks like this: The red area to the right is a relay, I wasn't sure ...
-1
votes
3answers
87 views

How to switch on or off up to seven devices individually? [closed]

Is there a way to turn on or off the power supply of up to seven hard drives with the help of an Arduino? Or maybe there is another way to ultimately - but restorable - prevent read/write access to ...
2
votes
3answers
110 views

Controlling 10+x 5m led strips with 10+ individual analog floor switches

I am looking to control around 10 (exact number TBD) non-addressable 5m led strips with an Arduino. Each led strip will be activated when a corresponding DIY analog floor switch. The idea is to have ...