Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bitlash demo - blink does not blink #59

Open
rmd13 opened this issue Feb 23, 2019 · 5 comments
Open

bitlash demo - blink does not blink #59

rmd13 opened this issue Feb 23, 2019 · 5 comments

Comments

@rmd13
Copy link

rmd13 commented Feb 23, 2019

Hi, I followed the tutorial and run a blink startup function to make LED connected to D7 pin blink.

After I run startup, I found that the LED was always on, and no blink.

Then I run a command to modify the callee toggle7 to see if something changed:

function toggle7 {d7=0;} // I founs that LED was suddenly off
function toggle7 {d7=1;}// I founs that LED was suddenly on
function toggle7 {d7=!d7;} // I expect LEDto blink, but it failed.

@rmd13
Copy link
Author

rmd13 commented Feb 23, 2019

I found that when I just define the fucntion:
function toggle7 {d7=!d7;}
The D7 LED suddenly turned on after define the function.

@rmd13
Copy link
Author

rmd13 commented Feb 24, 2019

I found the reason:
The dr function or d7 always return 0 no matter the voltage is high or low.
perhaps before reading d7, the pinmode was converted to input, and the power was shutoff on d7, so the read value was always 0.

@rmd13
Copy link
Author

rmd13 commented Feb 24, 2019

A better way is to use gobal variable a-z to make switch.
below is the matlab code anf it works well:

aStr = 'a=0;';
fprintf(obj1,'%s\n',aStr);
aStr = 'function toggle7 {pinmode(7,1);if(a==0){dw(7,1);a=1;}else{dw(7,0);a=0;}}';
fprintf(obj1,'%s\n',aStr);
pause(0.3)
aStr = 'function blink7 {run toggle7,1000;}';
fprintf(obj1,'%s\n',aStr);
pause(0.3)
aStr = 'blink7()';
fprintf(obj1,'%s\n',aStr);

@rmd13
Copy link
Author

rmd13 commented Feb 24, 2019

I also found that when run blink in background, the LED intensity was not stable at high frequency,.
However, if I run it in foreground, LED is very stable.

aStr = 'i=0; while(i<1000){toggle7();i++}';
fprintf(obj1,'%s\n',aStr);

@billroy
Copy link
Owner

billroy commented Feb 24, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants