element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • 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
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • 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 Relay sketch required for a charity project.
  • 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 15 replies
  • Subscribers 402 subscribers
  • Views 1344 views
  • Users 0 members are here
Related

Relay sketch required for a charity project.

Former Member
Former Member over 13 years ago

A big hello from the UK!

 

I have a charity car project that is ongoing to raise funds for Help for Heroes. Our vehicle will be customised with lights, motors and sounds.

 

I have a standard arduino and a 4-relay board which is working well using various sketches I have found on the net.

 

I was wondering if anyone could help me with a sketch that will turn on 3, or 4 of these relays at a time interval that I can set from a single N/O momentery switch. I also need it to reset after a certain time so that when the button is pressed again the sequence will start again.

 

I have an HD44780 LCD that I'd like to work into the design that could display text just before the relevent relay becomes active. (This is not essential as the relays are my priority just now)

 

As it stands my relays, 1-4 are connected to pins 2-5 although I don't need the 4th relay at this time.

 

Basically the car will loosely resemble a helicopter and will have a set up of lights, motors and a cheap MP3 player that has a physical switch that when made instantly starts the helicopter sound file.

 

If I'm totally honest i think I need a 'pro' to write me a sketch that is really basic as I lack the skills to do it myself.

 

The lights, motors and mp3 will be powered externally and will be initiated with the arduino like this:

 

1. User presses a N/O momentery switch.

 

2. Relay 1 makes & MP3 plays, engine start up - and remains on for duration of file (1:52).

 

3. After 10 secs - Relay 2 makes and Navigation lights iluminate.

 

4. After engine warm-up 22secs relay 3 makes and 'rotors' start.

 

5. After 1:40 relay 3 breaks, rotors stop.

 

6. After 1:52 relays 1 & 2 break.

 

7. Next press of button, steps 1-6 start again.

 

If it is easier I can use a locking switch, would that would solve the re-set?

 

I know this is a big ask but i severely lack the programming knowledge to do this.

 

I hope someone can help, i'm sure it's not too difficult for you pros!

 

I really appreciate people reading this and taking the time to reply.

 

Many thanks in advance.

 

VB

  • Sign in to reply
  • Cancel

Top Replies

  • ntewinkel
    ntewinkel over 13 years ago +2
    Here we go. I had forgotten the 10k resistor to ground, so it took me a while to figure out why the button press was behaving so oddly! I tested using a momentary-on switch (gives 5 volts (high) when pressed…
  • ntewinkel
    ntewinkel over 13 years ago +1
    Challenge... accepted!
  • ntewinkel
    ntewinkel over 13 years ago in reply to Former Member +1
    Hi Kris, I wrote it so that a line going HIGH means "ON", which I guess happens to be backwards To reverse that we just need to switch my HIGHs and LOWs wherever it says "digitalWrite(RELAY...". I just…
Parents
  • Former Member
    Former Member over 13 years ago

    Hi Nico,

     

    I have tried the sketch connected up to my 20x4, all I'm getting is a blank line, a white line (solid blocks), blank line, white line (solid blocks).

     

    I changed the display from 16,2 to 20,4 but this made no difference. The sketch when I compile it with

     

    void updateDisplay(char *line1, char *line2, char *line3, char *line4) {

        lcd.setCursor(0,0);

        lcd.print(line1);

        lcd.setCursor(0,1);

        lcd.print(line2);

        lcd.setCursor(0,2);

        lcd.print(line3);

        lcd.setCursor(0,3);

        lcd.print(line4);

    }

     

    Reports "too few arguments to function 'void updateDisplay(char*, char*, char*, char*)'"

     

    Any ideas?

     

    Thanks again

     

    Kris

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • ntewinkel
    ntewinkel over 13 years ago in reply to Former Member

    Hi Kris,

     

    It's best to get it working on the 20x4 display first, and then updating the rest of the code to allow more messages to be displayed.

     

    The reason you get the "too few arguments" message is because every single one of the lines that look like

          updateDisplay("Fasten seatbelts", "Press button...");

    should be changed to look like:

          updateDisplay("Fasten seatbelts", "Press button...", "line 3 message      ", "line 4 message      ");

    to match the new method. ie, each line needs 4 messages to match the 4 parts of that new method (line1, line2, line3, line4 = 4 messages).

     

    The 20x4 display should work with the same code, assuming the display has the same kind of driver chip, and the same line hookups. I'm using 4 bit parallel.

    I'm not very familiar with LCD displays, so I'm not sure what could be going on there. From what I understood, as long as the chip is the same, they all hookup the same and communicate the same way. I have a 40x2 display that I could never get to work - it has a different chip that claims to be compatible, but apparently isn't, which is why I bought the 16x2 display.

     

    Maybe someone else can help you get the display going? I've seen some tutorials on the arduino.cc site that might be of help. Maybe get the display going independently first?

     

    Or wait for the 16x2 to come in, I guess.

     

    Sorry I can't be more help there.

     

    Cheers,

    -Nico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • ntewinkel
    ntewinkel over 13 years ago in reply to Former Member

    Hi Kris,

     

    It's best to get it working on the 20x4 display first, and then updating the rest of the code to allow more messages to be displayed.

     

    The reason you get the "too few arguments" message is because every single one of the lines that look like

          updateDisplay("Fasten seatbelts", "Press button...");

    should be changed to look like:

          updateDisplay("Fasten seatbelts", "Press button...", "line 3 message      ", "line 4 message      ");

    to match the new method. ie, each line needs 4 messages to match the 4 parts of that new method (line1, line2, line3, line4 = 4 messages).

     

    The 20x4 display should work with the same code, assuming the display has the same kind of driver chip, and the same line hookups. I'm using 4 bit parallel.

    I'm not very familiar with LCD displays, so I'm not sure what could be going on there. From what I understood, as long as the chip is the same, they all hookup the same and communicate the same way. I have a 40x2 display that I could never get to work - it has a different chip that claims to be compatible, but apparently isn't, which is why I bought the 16x2 display.

     

    Maybe someone else can help you get the display going? I've seen some tutorials on the arduino.cc site that might be of help. Maybe get the display going independently first?

     

    Or wait for the 16x2 to come in, I guess.

     

    Sorry I can't be more help there.

     

    Cheers,

    -Nico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • ntewinkel
    ntewinkel over 13 years ago in reply to ntewinkel

    ps, just to make sure - did you see my notes on where the wires go? ie, LCD 4,5,6,7 goes to digital pin 7, 8, 9, 10, which is different from the tutorials.

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