We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everybody,
i will post my code below, what im trying to accomplish is that when my x and y variables reach certain value and stay in those valuse for 5 sec, i want R, G and B values to change after that,and than reset that timer again, this is what i have come up with for now, but what happens is, when x and y fulfill that IF statement it instantly changes those R G B values , it doesnt wait for 5 sec like i would want to.. pls help if you can...
int start, timer1;
int R=0, G=0, B=0;
int leftSensor, rightSensor;
void Setup(){
...
start = millis();
...
}
void draw(){
...
red(leftSensor, rightSensor, timer1);
...
}
void red(int x, int y, int t)
{
if(x <= 62 && x >=58 && y<=65 && y >= 63 )
{
t = millis()-start;
if(t >= 5000){
R = 204; G = 0; B = 0;
}
}
t = 0;
}
Answers
cant get my code show properlynvmYup, this one should work, where did u find it if i may ask, is there example for it or it was your doing?
Thank You very much mate :)
I wrote it, just now. And now I depart, in search of pancakes and coffee.
I wish you luck than, in your pursuit.
nvm, thx again, got it
How would i make this counter to work, i want it to reset every time it reaches 3000ms, i tried this but it doesnt work at all
it just instantly changes the RGB values, it doesnt wait at all,
Meh, i just removed it from void function and put in draw(), and made type boolean as a condition... now it works
@BodegaB -- one tip --
red()
is a language built-in -- if you are making a color function you should probably name it something else, like turnRed, redBG, redTimer etc.Didn't know that, thank you ;)