I have a relatively simple question for you all. I am still quite new to Arduino. The end goal for my project is to be able to have an analog input power on a electromagnet.
The way I have it set up right now, the optocoupler is watching a timing wheel with 4 notches in it to create a analog signal. This signal needs to be accurately watched so it never misses a beat. When this signal goes up, the electromagnet needs to power up and stay on for 30 milliseconds, then turn off. I also would be using a light so it is easy to see when the electromagnet turns off and on.
Again, I am a beginner here and i would just like to understand how to use the millis() time in Arduino to program a LED to turn on for a set amount of time after a analog signal is detected.
If any of you can recommend a forum page or other tutorials i am open to that.
I trust I have uploaded the code the proper way.
Thanks for any and all input!!
int sensorvalue;
void setup() {
// put your setup code here, to run once:
pinMode(9, OUTPUT);
pinMode(6, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
sensorvalue = analogRead(0);
if(sensorvalue >= 8) {
digitalWrite(6, HIGH);
analogWrite(9, 80);
millis();
}else{
digitalWrite(6, LOW);
digitalWrite(9, LOW);
}
}
I forgot to add, this code currently does nothing to blink an led as the you coders will be able to tell immediately. It simply turns the led on and stays on.
Thanks,
Denley
Thanks LarryD for that link. I will be reading that.
I will not be able to take pictures of my actual setup till later this afternoon.
Thanks for the fast responses folks!!