element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Arduino
  • Products
  • More
Arduino
Arduino Forum inverse signal by timer millis
  • Blog
  • Forum
  • Documents
  • Events
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Arduino requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 6 replies
  • Subscribers 101 subscribers
  • Views 415 views
  • Users 0 members are here
Related

inverse signal by timer millis

balexfox
balexfox over 1 year ago

i need a help i cant create single inverse signal by millis. my code cyclical delay but i need single by millis

please who can help to show me example

  • Reply
  • Cancel
  • Cancel

Top Replies

  • balexfox
    balexfox over 1 year ago +1

    i need a two single also needs a shift for the second signal

     

    1. int ledPin1 =  12;  // the number of the LED pin
    2. int ledState1 = LOW;  // ledState used to set the LED
    3. unsignedlong previousMillis1 = 0;  // will store…
Parents
  • balexfox
    balexfox over 1 year ago

    i need a two single also needs a shift for the second signal

     

    1. int ledPin1 =  12;  // the number of the LED pin
    2. int ledState1 = LOW;  // ledState used to set the LED
    3. unsignedlong previousMillis1 = 0;  // will store last time LED was updated
    4. longOnTime1 = 250;  // milliseconds of on-time
    5. longOffTime1 = 750;  // milliseconds of off-time
    6. int ledPin2 =  13;  // the number of the LED pin
    7. int ledState2 = LOW;  // ledState used to set the LED
    8. unsignedlong previousMillis2 = 0;  // will store last time LED was updated
    9. longOnTime2 = 330;  // milliseconds of on-time
    10. longOffTime2 = 400;  // milliseconds of off-time
    11. void setup()
    12. {
    13. // set the digital pin as output:
    14.   pinMode(ledPin1, OUTPUT); 
    15.   pinMode(ledPin2, OUTPUT); 
    16. }
    17. void loop()
    18. {
    19. // check to see if it's time to change the state of the LED
    20. unsignedlong currentMillis = millis();
    21. if((ledState1 == HIGH) && (currentMillis - previousMillis1 >= OnTime1))
    22.   {
    23.   ledState1 = LOW;  // Turn it off
    24.   previousMillis1 = currentMillis;  // Remember the time
    25.   digitalWrite(ledPin1, ledState1);  // Update the actual LED
    26.   }
    27. elseif ((ledState1 == LOW) && (currentMillis - previousMillis1 >= OffTime1))
    28.   {
    29.   ledState1 = HIGH;  // turn it on
    30.   previousMillis1 = currentMillis;  // Remember the time
    31.   digitalWrite(ledPin1, ledState1);  // Update the actual LED
    32.   }
    33. if((ledState2 == HIGH) && (currentMillis - previousMillis2 >= OnTime2))
    34.   {
    35.   ledState2 = LOW;  // Turn it off
    36.   previousMillis2 = currentMillis;  // Remember the time
    37.   digitalWrite(ledPin2, ledState2);  // Update the actual LED
    38.   }
    39. elseif ((ledState2 == LOW) && (currentMillis - previousMillis2 >= OffTime2))
    40.   {
    41.   ledState2 = HIGH;  // turn it on
    42.   previousMillis2 = currentMillis;  // Remember the time
    43.   digitalWrite(ledPin2, ledState2);  // Update the actual LED
    44.   }
    45. }
    • Cancel
    • Up +1 Down
    • Reply
    • Cancel
  • balexfox
    balexfox over 1 year ago in reply to balexfox

    its a repeat cycle of pwm i need a single

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
Reply
  • balexfox
    balexfox over 1 year ago in reply to balexfox

    its a repeat cycle of pwm i need a single

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
Children
No Data
Element14

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2022 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube