my problem with delay
so what I want is to make something like this:
values = 1023 "green light on"
values = 0 "red light on"
for now everything worked with me my problem start from here:
values < 1023 "delay 1min"
values > 1023 "delay 1min"
how can I make a delay for only one function not for the whole code?
second how can I make it ignore "0"
That's my code
Come on. You don't REALLY think that you're the first to use the Arduino for a traffic light system, do you?
loool nop I am not using it for traffic light, I want to make a lock from Arduino by using specific input values
To be more hard to brake, or hack, a delay will happen if you put other values or tried to know the right values
if(analogRead(lightPin) = 0 ){
I correct that to ==
hmm let me google it then, thanks anyway
To be more hard to brake, or hack, a delay will happen if you put other values
What other values? If you read the potentiometer, and get something other than 0 or 1023, is that "the other values" you are referring to? If so, is that WHEN you want to delay? Why is then a bad time to delay everything?
I don't really understand what you are trying to accomplish, or what security will be obtained using a delay.
it's a lock by using only 1 resistor
I removed everything from USB flash memory and put a resistor inside.
Then I connect a female USB port to pinA0 with a resistor to GND
now if you put your USB flash memory your lock will be open, because that's resistor have 1023 values that I mention in my code.
There is a problem here, If you put a potentiometer to brake the lock it will be very easy to know the value.
What I want is to make a delay for 1min if you tried to put other values your lock will be locked.
Then I connect a female USB port to pinA0 with a resistor to GND
I need a picture of this. A resistor between A0 and ground will not cause a reading on A0. 5V to A0, with a resistor to ground, will cause differing amounts of current to flow, depending on the resistor. The voltage read at A0 will NOT change, though.
What I want is to make a delay for 1min if you tried to put other values your lock will be locked.
So, "other values" means a different resistor, which means different current, but the same voltage?
this is basicly millis example i hope job benefits
/* Flashing LED Version 2
* ------------------------
*
* Turns on and off a light emitting diode(LED) connected to a digital
* pin, in intervals of 2 seconds using millis() function
*
*/
int ledPin = 13; // LED connected to digital pin 13
unsigned long currentTime;
unsigned long loopTime;
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
currentTime = millis();
loopTime = currentTime;
}
void loop()
{
currentTime = millis();
if(currentTime >= (loopTime + 1000)){
digitalWrite(ledPin, !digitalRead(ledPin)); // toggles the LED on/off
loopTime = currentTime; // Updates loopTime
}
// Other processing can be done here
}