Go Down

Topic: [Solved] unwanted activation or deactivation (Read 307 times) previous topic - next topic

Elaz1234

Sep 23, 2019, 11:07 pm Last Edit: Sep 24, 2019, 10:59 am by Elaz1234
I have a program where certain OUTPUTS get HIGH when certain INPUTS get HIGH. My arduino is connected to 220V and everything works perfectly. But sometimes when I press the light switch in same room one of my outputs would turn on/off. Why is that happening, why does a light switch activates my program? I also noticed when i slowly press the light switch it would happen. is it because of High Voltage parasite? How do I fix this?

TheMemberFormerlyKnownAsAWOL

Spikes.

Try inverting the switch logic.

Try posting details, not vague hand-waving.

TomGeorge

Hi,
How have you got your inputs wired and are you using pullup or pull down resistors on your digital inputs?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Please include the 220Vac power supply you are using.

Thanks.. Tom.. :)
Everything runs on smoke, let the smoke out, it stops running....

Elaz1234

#3
Sep 23, 2019, 11:45 pm Last Edit: Sep 23, 2019, 11:46 pm by Elaz1234
Spikes.

Try inverting the switch logic.

Try posting details, not vague hand-waving.
I have a program where output (led) gets High if input gets high, and led stays high until it's reactivated (input -taster gets high again) but it can't be reactivated in first 10 seconds, same happens when led is reactivated and gets low, it can't become high again until 10 seconds passed. Now there is just arduino connected to 220V and ordinary light switch in room activates it for no reason, it is not connected to arduino or something. if its because of spikes then how do i fix it? seems like your answer is vague hand-waving.

TheMemberFormerlyKnownAsAWOL

#4
Sep 23, 2019, 11:49 pm Last Edit: Sep 23, 2019, 11:52 pm by TheMemberFormerlyKnownAsAWOL
OK, it seems like we need to work on your personal definition of "detail"

Quote
if its because of spikes then how do i fix it?
See reply #1

Elaz1234

OK, it seems like we need to work on your personal definition of "detail"
Can you imagine one led and one taster connected to arduino nano (ofc with resistor), arduino connected to 220V with its original cable pluged in a phone charger which is in 220v? Now you have serious problems if you can't imagine that. When I turn on the light switch in that room to be able to see because i can't see in dark obviously(but you need details and i need to explain it to you), turning lights on or off would turn the led on/off sometimes.

Code:

Code: [Select]


const int  buttonPin = 3;
const int ledPin = 6;
int buttonPushCounter = 1;
int buttonState = 0;
int lastButtonState = 0;
bool flashState = false;


void setup()
{
  Serial.begin(115200);
  pinMode(buttonPin, INPUT);
  pinMode(ledPin, OUTPUT);
  Serial.println(" == Button Press - Three Flash V1.0 == ");
}


void loop()
{
  buttonState = digitalRead(buttonPin);
  Serial.print("buttonState = ");
  Serial.print(buttonState);
  if (buttonState != lastButtonState)
  {
    if (buttonState == HIGH)
    {
      flashState = true;
    }
    delay(50); //bouncing
  }
  Serial.print("\t flashState = ");
  Serial.print(flashState);
  lastButtonState = buttonState;
 


  if (flashState == true)
  {

   
    digitalWrite(ledPin, HIGH);
    delay(10000);
    flashState = false;
    while(digitalRead(buttonPin) == LOW)
      {
        digitalWrite(ledPin, HIGH);
      }
  delay(50); //bouncing
  }
  else
  {
    digitalWrite(ledPin, LOW);
   
  }



  if (flashState == false)
  {

   
    digitalWrite(ledPin, LOW);
    delay(10000);
    flashState = true;
    while(digitalRead(buttonPin) == LOW)
      {
        digitalWrite(ledPin, LOW);
      }
  delay(50); //bounce
  }
  else
  {
    digitalWrite(ledPin, HIGH);
   
  }

  Serial.println(" ");
}


TheMemberFormerlyKnownAsAWOL

#6
Sep 24, 2019, 12:03 am Last Edit: Sep 24, 2019, 12:10 am by TheMemberFormerlyKnownAsAWOL
Ok,.I imagine that you've got a pulldown resistor on pin 3.
That wasn't so hard, because you've got a serious problem if you haven't.
So, invert the logic of the switch, and use the built-in pullup instead.

(You still need to work on the whole "detail" thing)

What exactly is a "taster"?

Wawa

Most of the information was in OP.s other thread.
Leo..

TheMemberFormerlyKnownAsAWOL

Most of the information was in OP.s other thread.
Leo..
Oh great.
Another time-waster.

Elaz1234

Ok,.I imagine that you've got a pulldown resistor on pin 3.
That wasn't so hard, because you've got a serious problem if you haven't.
So, invert the logic of the switch, and use the built-in pullup instead.

(You still need to work on the whole "detail" thing)

What exactly is a "taster"?
I think you don't understand what my problem is. Read my posts again carefully, then answer if you know how to, if not, then please don't.

I fixed problem now with capacitor, but i would still like to know other possible fixes.

TheMemberFormerlyKnownAsAWOL

I know exactly what at least one of your problems is.

Read my replies again, carefully.

If you don't want to implement my suggestions, I really couldn't give a toss.

Elaz1234

I know exactly what at least one of your problems is.

Read my replies again, carefully.

If you don't want to implement my suggestions, I really couldn't give a toss.
Tried, nothing works except adding capacitor on the input.

Elaz1234

Most of the information was in OP.s other thread.
Leo..
So what is wrong with that thread? I am new to programming, someone helped me and i said thanks

TheMemberFormerlyKnownAsAWOL

#13
Sep 24, 2019, 12:53 am Last Edit: Sep 24, 2019, 12:55 am by TheMemberFormerlyKnownAsAWOL
Detail.
Quote
Can you imagine one led and one taster connected to arduino nano (ofc with resistor)
Your imaginary circuit should have at least two resistors, not a singular resistor.
nothing works except adding capacitor on the input.
I'm truly delighted for you.

Now please mark the the thread "solved" and we can all move on.

(I still have no idea what a "taster" is)

Elaz1234

Detail. your imaginary circuit should have at least two resistors, not a singular resistor. I'm truly delighted for you.

Now please mark the the thread "solved" and we can all move on.
I still need to know if it can be fixed with code. You see I'm newbie and i appreciate help from experienced members, i'm thankful for it, instead of mocking whats wrong in comments, why don't you show me what's right (without mocking), since your first post, you are insulting me in a way ''vague hand-waving'' things like that, I see you older members as motivation and when you act like that it really demotivates me, but people like you will not stop me i will go on with learning.

Go Up