Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 10 months ago.
what is the frequency of the clock?
If the code is like this below, how long will the led be on every loop? Of course, actually, we cannot see it's on.
- include "mbed.h"
DigitalOut myled(LED1);
int main() { while(1) { myled = 1; myled = 0; wait(1); } }
1 Answer
10 years, 10 months ago.
Hello Shenghao, with your code you switch on the led and switch off it direct after that. This will take some instructions, because of the mbed classes, but it will be in the range of < 1 us. After you switch off the led you wait for 1s.
try:
int main() { while(1) { myled = 1; wait(1) ; myled = 0; wait(1); } }
to see 1s on - 1s off
Regards, Peter