edit: posted, no longer need help. thank how tried help.
i know, delay question...
i have been trying days remove delay , replace millis. have looked through many tutorials , can't figure out make changes. have following, doesn't scan correctly.
this larson scanner code on mega, leds, resistors...
please help!!! thank you!!!
i know, delay question...

i have been trying days remove delay , replace millis. have looked through many tutorials , can't figure out make changes. have following, doesn't scan correctly.
this larson scanner code on mega, leds, resistors...
please help!!! thank you!!!
code: [select]
int scanpinarray[] = {36,37,38,39,40,41,42,43,44,45};
int scanlen = 9 ; // sizeof(scanpinarray) / sizeof(int);
int scandir = 1;
void setup()
{
for (int scanpin = 0; scanpin < scanlen; scanpin++)pinmode(scanpinarray[scanpin], output);
}
void pulse_width_modulation(int pos)
{
if(scandir==1)
{
scandir = 0;
for (int scanled=scanlen; scanled>0; --scanled)fadein(scanled);
}
else{
scandir = 1;
for (int scanled=0; scanled<scanlen; ++scanled)fadein(scanled);
}
}
void fadein(int pos)
{
for(int bri = 150; bri < 256; ++bri)
{ if (millis() > scantimermillis1){
if(scandir==1 && pos>0)analogwrite(scanpinarray[pos-1], 255-bri);
if(scandir==0 && pos<scanlen)analogwrite(scanpinarray[pos+1], 255-bri);
analogwrite(scanpinarray[pos], bri);
scantimermillis1 = millis() + 700; }
// delaymicroseconds(700);
}
}
void loop() {
static uint8_t pos=0;
while(pos<scanlen)
{
pulse_width_modulation(pos);
++pos;
}
while(pos>0)
{
--pos;
pulse_width_modulation(pos);
}
}
several things wrong this:-
1) no code tags !!! - read "how use forum sticky post".
2) have not said hardware nor have posted schematic - read "how use forum sticky post".
3) not code supposed , - read "how use forum sticky post".
so if want - read "how use forum sticky post".
1) no code tags !!! - read "how use forum sticky post".
2) have not said hardware nor have posted schematic - read "how use forum sticky post".
3) not code supposed , - read "how use forum sticky post".
so if want - read "how use forum sticky post".
Arduino Forum > Using Arduino > Project Guidance > delay help needed
arduino
Comments
Post a Comment