Hello!
I'm trying to connect an USO Earphone, which has a built-in magnetic reed switch, to an Arduino. This is simply in order to read the on/off state into Max/MSP to trigger some audio files.
http://www.molitor-berlin.de/en/products/uso/functions
I'm trying to use the "Auto start-function."
When the Arduino's internal pull-up resistor is set to HIGH, the LED on 13 is not lit, and when it is set to LOW, the LED is lit. But, when lifting the headset, ie. making the connection in the reed switch the LED does not go on/off.
The USO is connected to Ground and pin 5 on the Arduino UNO.
When looking at the Serial monitor, when the pullup is high, the monitor return "1" and when the pullup is low, it returns "000111000111"
Code:
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 5; // the number of the pushbutton pin
const int ledPin = 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(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
digitalWrite(buttonPin, HIGH); // turn on input pin's pull-up resistor
Serial.begin(9600);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
Serial.println(buttonState);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == LOW) {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
The switch is supposed to be a simple on/off switch, but I'm slightly confused...
Could someone help, please!