I am trying to connect my Arduino with a remote control Inorder to control the function of solenoid I used a remote but it doesn't work

On this, the code is the simple public domain digital button and everything seems to be linked correctly but its seems to always read HIGH when its plugged in.

Should mention that it worked yesterday with this exact set-up but now its not working.

const int buttonPin = 2;     // the number of the pushbutton pin
const int solenoid =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(solenoid, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(solenoid, HIGH);
  } else {
    // turn LED off:
    digitalWrite(solenoid, LOW);

9V smoke alarm batteries are pretty much useless for motors and solenoids, and an Arduino output pin can power at most a small LED.

Please post links to the parts, and a wiring diagram. The photo doesn't tell us much.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.