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 5v pulse input to run code
  • 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
  • Replies 9 replies
  • Subscribers 387 subscribers
  • Views 1942 views
  • Users 0 members are here
Related

5v pulse input to run code

Phrostedflakes
Phrostedflakes over 3 years ago

I have a basic car alarm and i want to replace the blinking led with a attiny85 (or something similar) and a neopixel strip to run when the alarm is active. But the power to the factory led is not constant. It is a pulsed 5v, (5v hot for a couple seconds, then no power, then repeat)   Is it possible to still use the pulsed voltage to trigger the attiny85 to run my code when the alarm is active and stop it when the alarm is deactivated? This is the code I wish to run

#include <Adafruit_NeoPixel.h>
#define PIN D1
#define NUMPIXELS 11
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delay_time = 125; // 200 msec = 1/5th of a second

void setup() {
  pixels.begin();
}

void loop() {

  // from left to right
  for(int i=0; i<NUMPIXELS; i++){
    pixels.setPixelColor(i, 0, 0, 255);
    pixels.show();
    delay(delay_time);
    pixels.setPixelColor(i, 0, 0, 0);
    pixels.show();
  }

  // from right to left
  for(int i=NUMPIXELS; i>0; i--){
    pixels.setPixelColor(i, 0, 0, 255);
    pixels.show();
    delay(delay_time);
    pixels.setPixelColor(i, 0, 0, 0);
    pixels.show();
  }


}

  • Sign in to reply
  • Cancel

Top Replies

  • kmikemoo
    kmikemoo over 3 years ago in reply to Phrostedflakes +2
    Phrostedflakes The teacher in me is just screaming right now; "Teach them to fish!" You've already altered other sketches, so we're heading in the right direction. Your current loop [ void loop() ] can…
  • robogary
    robogary over 3 years ago +1
    Does the flashing LED change flash rate on an alarm ? Maybe count the rising edge of the 5V LED pulses ? If they happen every 2-3 seconds then life is good. Check the LED pulsing for what is expected in…
  • beacon_dave
    beacon_dave over 3 years ago in reply to kmikemoo +1
    kmikemoo said: I personally like the second one better, but I am the exception to the rule. When starting out, the second option may tend to be more readable if you have nesting going on as all the braces…
Parents
  • robogary
    robogary over 3 years ago

    Does the flashing LED change flash rate on an alarm ? Maybe count the rising edge of the 5V LED pulses ? If they happen every 2-3 seconds then life is good. Check the LED pulsing for what is expected in the alarm state ? 

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Phrostedflakes
    Phrostedflakes over 3 years ago in reply to robogary

    Yes the led flashes about every 2-3 seconds. I run a meter on the led wires and when it's live it is around 5 volts, then power shuts off, then live again, and so on.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • Phrostedflakes
    Phrostedflakes over 3 years ago in reply to robogary

    Yes the led flashes about every 2-3 seconds. I run a meter on the led wires and when it's live it is around 5 volts, then power shuts off, then live again, and so on.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • 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