can someone help with a problem ps im not the best at this bigness
so help please
all im trying to do is from a high output from pin d2 i would like run say a void go () { stuff } then say a void go 1 (){stuff} without repeating the 1st void go() {stuff}
if (digitalRead(CS) == LOW){
allstop();delay(50);dBackVEL();delay(500);} this will repeat allstop then dBackVEL over and over
what im looking for is to run allstop then jump to dBackVEL without running allstop again
help please ??????
neilmac1:
all im trying to do is from a high output from pin d2 i would like run say a void go () { stuff } then say a void go 1 (){stuff} without repeating the 1st void go() {stuff}
Basically: Declare a boolean flag variable. Give it a nice name like maybe, doStuff. Set it equal to true in the declaration. Down in loop() there's a statement like
if(doStuff == true){
go();
doStuff = false; // this stops go() from executing any more
}
neilmac1:
if (digitalRead(CS) == LOW){
allstop();delay(50);dBackVEL();delay(500);} this will repeat allstop then dBackVEL over and over
It will only repeat those 2 functions over and over if CS is permanently LOW.
If you want them to run only once even if CS stays low for ever then you need to look at the StateChangeDetection example in the IDE. Then you can run the functions only when CS changes from HIGH to LOW instead of whenever it happens to be LOW.
this i think will explaine my problem a bit better i need run void SlowSpeeddFwd then void dbackvel
then only dbackvel without looping round back to SlowSpeeddFwd on the same command
as you can see (cs)==low keep repeating
SlowSpeeddFwd dbackvel
Do you actually need to keep calling dBackVEL? It's hard to be sure without seeing all your code, but it doesn't appear to do anything different on subsequent calls.
what im looking to do is start a motor at a set speed the run at full speed as long as cs is low with out repeating the slow speed i just cant stop repeating slow / fast thanks for the replies