Hey all, I'm trying to use Hall sensors to send variables to Max7 to play samples.
I've got it working fine, my only problem is the string of incessant bangs from Arduino.
I'm not sure why, but the third sensor (hallState3) sends a consistent 3 when I have a
sensor on it; but hallState 1 and 2 both send constant 010101010101, or 020202020202.
I really need 1 and 2 to also be 11111111 etc. and 22222222 etc. But I can't get it to work.
I see that my code serialWrite(0); is at the bottom next to hallState3; but I can't seem to
get it to work for the others....
here's my code:
int hallPin = 12;
int hallPin2 = 2;
int hallPin3 = 7;
int ledPin = 13;
int hallState = 0;
int hallState2 = 0;
int hallState3 = 0;
void setup(){
pinMode(hallPin, INPUT);
pinMode(hallPin2, INPUT);
pinMode(hallPin3, INPUT);
Serial.begin(9600);
}
void loop(){
hallState = digitalRead(hallPin);
hallState2 = digitalRead(hallPin2);
hallState3 = digitalRead(hallPin3);
if (hallState == LOW){
digitalWrite (ledPin, HIGH);
Serial.write(1);
}
if (hallState2 == LOW){
digitalWrite (ledPin, HIGH);
Serial.write(2);
}
if (hallState3 == LOW){
digitalWrite (ledPin, HIGH);
Serial.write(3);
}
else {
digitalWrite (ledPin, LOW);
Serial.write(0);
}
delay(100);
}
Thanks for any help.