element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum arduino single signal digital
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 5 replies
  • Answers 2 answers
  • Subscribers 389 subscribers
  • Views 1189 views
  • Users 0 members are here
Related

arduino single signal digital

balexfox
balexfox over 4 years ago

I ask for help I'm not good at Arduino
I need to send a single signal to the outputs only without delay. oscillogram attached time. signal for a certain time high then low then high again. thanks for the help. second signal high then low to the end. thank you

 

image

  • Sign in to reply
  • Cancel

Top Replies

  • javagoza
    javagoza over 4 years ago +1 verified
    Can this help? #define SIGNAL1_PIN 5 #define SIGNAL2_PIN 8 #define SIGNAL1_PULSE_LENGTH_MS 2000 #define SIGNAL2_START_DELAY_MS 500 void setup() { pinMode(SIGNAL1_PIN, OUTPUT); pinMode(SIGNAL2_PIN, OUTPUT…
  • balexfox
    balexfox over 4 years ago in reply to javagoza +1 suggested
    delay is not suitable because it slows down the code and I have a lot of it. Here's an example I don't know how to fix it. unsigned long currentMillis = millis(); unsigned long currentMillis2 = millis…
  • balexfox
    balexfox over 4 years ago in reply to javagoza +1
    thank you very much
Parents
  • javagoza
    0 javagoza over 4 years ago

    Can this help?

     

    #define SIGNAL1_PIN  5
    #define SIGNAL2_PIN  8
    #define SIGNAL1_PULSE_LENGTH_MS 2000
    #define SIGNAL2_START_DELAY_MS 500 
    
    void setup() {
    pinMode(SIGNAL1_PIN, OUTPUT);
    pinMode(SIGNAL2_PIN, OUTPUT);
    digitalWrite(SIGNAL1_PIN, HIGH);
    digitalWrite(SIGNAL2_PIN, HIGH);
    }
    
    void pulseS1LowS2() {
    digitalWrite(SIGNAL1_PIN, LOW);
    delay(SIGNAL2_START_DELAY_MS);
    digitalWrite(SIGNAL2_PIN, LOW);
    delay(SIGNAL1_PULSE_LENGTH_MS - SIGNAL2_START_DELAY_MS);
    digitalWrite(SIGNAL1_PIN, HIGH);
    }
    
    void loop() {
      // call pulseS1LowS2() when needed
    }

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • balexfox
    0 balexfox over 4 years ago in reply to javagoza

    thank you very much

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • javagoza
    0 javagoza over 4 years ago in reply to balexfox

    I'm glad you've solved!

     

    if later you need to do things while waiting to change state, then instead of using blocking delays you can use timers or any library for no-blocking delays:

     

    GitHub - contrem/arduino-timer: Non-blocking library for delaying function calls

    or

    How to code Timers and Delays in Arduino (forward.com.au)

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • javagoza
    0 javagoza over 4 years ago in reply to balexfox

    I'm glad you've solved!

     

    if later you need to do things while waiting to change state, then instead of using blocking delays you can use timers or any library for no-blocking delays:

     

    GitHub - contrem/arduino-timer: Non-blocking library for delaying function calls

    or

    How to code Timers and Delays in Arduino (forward.com.au)

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
No Data
element14 Community

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 © 2025 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

  • X
  • Facebook
  • linkedin
  • YouTube