I have a car clicker (not sure what it is technically called) that allows through the push of a button the ability to unlock (or another push button lock) the car. I have removed the circuit board and connected two wires to the unlock circuit. If I touch these two wires together it will unlock the car so I have the wires in the correct location.
I would like to run the two wires into the arduino and allow the arduino to complete the circuit to unlock the car. For my prototype I have connected the wire that has voltage to A0. I have connected the wire that has no voltage to A2. I have a pushbotton on a breadboard that I am using as my fake signal to connect the circuit. Unfortunately this is not working. I have posted my code below. When I watch the Serial Monitor says:
START
Button pressed.
169
END
If I disconnect the wires from A0 and A2 and touch them together it will unlock the car.
Any help would be appreciated. (In the end I want to use a BLE shield to have my phone send the A5 button press signal so I can unlock my car using the bluetooth in my phone.)
const int clickerAnalogReadPin = A0;
const int clickerAnalogWritePin = A2;
const int buttonAnalogInPin = A5;
void setup()
{
//start serial connection
Serial.begin(9600);
//configure as an input and enable the internal pull-up resistor
pinMode(buttonAnalogInPin, INPUT_PULLUP);
pinMode(clickerAnalogWritePin, OUTPUT);
}
void loop()
{
Serial.println("START");
//read the pushbutton value into a variable
int buttonValue = analogRead(buttonAnalogInPin);
// when the sensor value is below 1000 that means the button was depressed.
if (buttonValue <= 1000)
{
Serial.println("Button pressed.");
//read the value from the unlock upper right pin
int unlockValue = analogRead(clickerAnalogReadPin);
int outputValue = map(unlockValue, 0, 1023, 0, 255);
//int unlockValue = 175;
Serial.println(outputValue);
analogWrite(clickerAnalogWritePin, outputValue);
}
else
{
Serial.println("Button not pressed.");
analogWrite(clickerAnalogWritePin, 0);
}
Serial.println("END");
delay(2000);
}