Hey gang!
I'm an EE and am currently using Arduino's to finish my senior design project (a wireless fencing strip/piste). I'm using the arduino to simply read the three lines of the weapon ( Called a, b , c). When the button is depressed, the lines a and b should connect.
Since I originally had the code such that the code wrote high to A and read from B, digitally. However, I was having trouble. To fix that, I tried to just read the analog input to see what the differences were.
When the button is pressed, the serial output will say 1023, at a slower rate (yes, I have changed the delay on the code to see if that was the issue). However, I kept getting noise, and the code just wasn't showing a big difference between button depressed (a and b line together) and button not depressed as much as a difference as I'd like.
Just to see, I connected the analog input pin to a resistor and a capacitor to ground in series. I still got the results below:
0
1
2
2
0
3
31
60
63
69
74
74
74
74
54
12
15
8
3
0
0
0
0
7
6
6
8
37
67
68
76
79
87
83
85
58
22
19
9
4
1
3
1
1
7
5
9
1
35
63
68
76
74
75
69
74
63
14
15
You can see the "up and down" of the wave of voltage read. Is there a way to reduce this, and allow for my code to work? Here it is below:
const int epeeAlinePin=2;
const int epeeBlinePin=A3;
const int epeeClinePin=4;
const int LEDpin=12;
void setup(){
Serial.begin(9600);
pinMode(LEDpin, OUTPUT);
pinMode(epeeAlinePin, OUTPUT);
pinMode(epeeBlinePin, INPUT);
pinMode(epeeClinePin, INPUT); //grounded for the bell guard
}
void loop () {
digitalWrite(epeeAlinePin,HIGH);
int Bvalue=analogRead(epeeBlinePin);
Serial.println(Bvalue,DEC);
delay(100);
}
Thanks for the help!
-Kat