I've been tinkering for 2 days now and I am officially stuck. What I'm trying to do is use a basic hall effect rotary encoder I have built to control when a pneumatic solenoid is energized / de-energized.
I have a 10k potentiometer in the circuit that controls how long the solenoid stays energized.
What I'm trying to achieve...
Whenever the hall effect is closed (magnet present), I want the solenoid
energized for a time that is controlled by the pot setting.
I then want the Arduino to "see" the hall effect go low again before it repeats the loop...that way if you ever stop on a magnet it won't machine gun fire the solenoid.
Here's the code so far, I don't think I'm understanding the while function correctly.
// GH Bear auto driller supplement
// Set analog pin 1 as venier control
// Venier control sets how long solenoid is energized
int venierPin = 1;
int venierValue = 1;// Set analog pin 2 as hall effect sensor
int hallPin = 2;
int hallValue = 2;// Set digital pin 13 as solenoid transistor control
const int solPin = 13;// Set threshold for hall effect sensor
const int threshold = 170;// Set constant for using vernier setting to determine time
// to energize soleniod
const int constvenierValue = 5;// Set digital pin 12 as hall effect supply transistor base
const int dhallPin = 12;void setup() {
// initialize digital pins as outputs
pinMode(solPin, OUTPUT);
pinMode(dhallPin, OUTPUT);// give juice to hall effect supply transistor base
digitalWrite(dhallPin, HIGH);
delay(1000);
digitalWrite;(dhallPin, LOW);
delay(2000);
digitalWrite;(dhallPin, HIGH);
}void loop() {
// read hall effect state
hallValue = analogRead(hallPin);// read venier setting
venierValue = analogRead(venierPin);// add 10 millisecond delay
delay(10);// if magnet is present, energize solenoid for time as
// function of vernier setting
if (hallValue > threshold) {
digitalWrite(solPin, HIGH);
}
delay(venierValue * constvenierValue);
digitalWrite(solPin, LOW);// do not repeat loop until hall effect goes low again,
// indicating movement
while (hallValue > threshold) {
delay(100);
hallValue = analogRead(hallPin);
}
}
Also, if someone will tell me how, I'll provide a copy of my wiring diagram.
Also, I have an led that will turn on when the solenoid is to be energized. When I put the magnet over the hall effect, the response time is terribly slow (like 3 seconds).
I'm in desperate need of some help as I've got to have this thing perfected in a couple of days. Thanks guys.