Results 1 to 5 of 5

Thread: Blink LED for 5 seconds with 1Hz rate

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2013
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Red face Blink LED for 5 seconds with 1Hz rate

    hi

    i want to toggle LED for 5 seconds like ON and OFF. with 1 hz rate... can anyone give me suggestion..how to do that??

    thanks
    Sammey

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Blink LED for 5 seconds with 1Hz rate

    Write code that will be triggered once a second (e.g. using a timer) that toggles the led.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Blink LED for 5 seconds with 1Hz rate

    How are you controlling the LED ? Qt cannot do that directly.

    For the logic,,
    Qt Code:
    1. myclass::myclass()
    2. {
    3. timer.setInterval(1000); // 1Hz = 1 sec
    4. }
    5.  
    6. void startBlinkLED()
    7. {
    8. timer.start()
    9. count = 0;
    10. }
    11.  
    12. void onTimerTimeout()
    13. {
    14. if( count++ > 5)
    15. { count = 0;
    16. timer.stop();
    17. return;
    18. }
    19.  
    20. led->blink(); // Actual API to be called
    21. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Aug 2013
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Blink LED for 5 seconds with 1Hz rate

    i work on linux platform
    for turning on led system("echo 1 > /sys/class/leds/highbright-led/brightness")
    and turning off system("echo 0 > /sys/class/leds/highbright-led/brightness")

    anyway tanx for the reply aamer4yu ..i wil make some changes and i will check whether it is working or not...

  5. #5
    Join Date
    Jul 2011
    Location
    BRAZIL-RIO DE JANEIRO
    Posts
    47
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Blink LED for 5 seconds with 1Hz rate

    sammey,


    It is unusual perform control of hardware devices at X86 platform, as was implicitly mentioned by aamer4yu.
    I presume you are working on some embedded linux platform such as an ARM one.
    If the case, take a look on source code examples which is commonly provided at design tool ( hello word / blink led / etc... )


    +++

Similar Threads

  1. Blink Text in QTextEdit
    By Vaishnavi in forum Newbie
    Replies: 18
    Last Post: 22nd November 2012, 09:26
  2. baud rate
    By adriana in forum Newbie
    Replies: 5
    Last Post: 6th May 2011, 17:18
  3. How to wait 2 seconds before continue
    By raphaelf in forum Newbie
    Replies: 3
    Last Post: 25th June 2008, 14:36
  4. How to make an object blink in Qt?
    By thirupathiuppu007 in forum Qt Programming
    Replies: 2
    Last Post: 22nd February 2008, 10:30
  5. Window Blink/Flash
    By VireX in forum Newbie
    Replies: 21
    Last Post: 16th April 2007, 11:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.