I'm trying to make a wireless firework fireing system with my meca 2560.

I need help.

I’m trying to make a wireless firework fireing system with my meca 2560.

I’m have issues with the receiver. The issues I got is I want it to make all of 16 output pin individually high when they told to go high for about 30 seconds and then go low. But I don’t want to stop the program running for that 30 seconds. I’ve got all the program work apart from that 1 thing.
If any one can help I would appreciate it.

this is what ive got so far

//* RECIEVER CODE
  
  #include <VirtualWire.h>

void setup()
{
    Serial.begin(9600);	// Debugging only
    Serial.println("setup");

    // Initialise the IO and ISR
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);	 // Bits per sec
    vw_set_rx_pin(2);
    vw_rx_start();       // Start the receiver PLL running
pinMode(13, OUTPUT);
pinMode(3, OUTPUT);

pinMode(22, OUTPUT);
pinMode(23, OUTPUT);
pinMode(24, OUTPUT);
pinMode(25, OUTPUT);
pinMode(26, OUTPUT);
pinMode(27, OUTPUT);
pinMode(28, OUTPUT);
pinMode(29, OUTPUT);
pinMode(30, OUTPUT);
pinMode(31, OUTPUT);
pinMode(32, OUTPUT);
pinMode(33, OUTPUT);
pinMode(34, OUTPUT);
pinMode(35, OUTPUT);
pinMode(36, OUTPUT);
pinMode(37, OUTPUT);



  digitalWrite(13, LOW);
  digitalWrite(3, HIGH);
 
  digitalWrite(22, HIGH);
  digitalWrite(23, HIGH);
  digitalWrite(24, HIGH);
  digitalWrite(25, HIGH);
  digitalWrite(26, HIGH);
  digitalWrite(27, HIGH);
  digitalWrite(28, HIGH);
  digitalWrite(29, HIGH);
  digitalWrite(30, HIGH);
  digitalWrite(31, HIGH);
  digitalWrite(32, HIGH);
  digitalWrite(33, HIGH);
  digitalWrite(34, HIGH);
  digitalWrite(35, HIGH);
  digitalWrite(36, HIGH);
  digitalWrite(37, HIGH);
 
}

void loop()
{
  
  
  
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
	int i;

        digitalWrite(13, true); // Flash a light to show received good message
	// Message with a good checksum received, dump it.
	Serial.print("Got: ");
	
	for (i = 0; i < buflen; i++)
	{
	    Serial.print(buf[i]);
        if(buf[i] == '0') {digitalWrite(3, LOW);} //firelive
        if(buf[i] == 'a') {digitalWrite(22, LOW);} //cue 1 
        if(buf[i] == 'b') {digitalWrite(23, LOW);} //cue 2 
        if(buf[i] == 'c') {digitalWrite(24, LOW);} //cue 3
        if(buf[i] == 'd') {digitalWrite(25, LOW);} //cue 4
        if(buf[i] == 'e') {digitalWrite(26, LOW);} //cue 5
        if(buf[i] == 'f') {digitalWrite(27, LOW);} //cue 6
        if(buf[i] == 'g') {digitalWrite(28, LOW);} //cue 7
        if(buf[i] == 'h') {digitalWrite(29, LOW);} //cue 8
        if(buf[i] == 'i') {digitalWrite(30, LOW);} //cue 9
        if(buf[i] == 'j') {digitalWrite(31, LOW);} //cue 10
        if(buf[i] == 'k') {digitalWrite(32, LOW);} //cue 11
        if(buf[i] == 'l') {digitalWrite(33, LOW);} //cue 12
        if(buf[i] == 'm') {digitalWrite(34, LOW);} //cue 13
        if(buf[i] == 'n') {digitalWrite(35, LOW);} //cue 14
        if(buf[i] == 'o') {digitalWrite(36, LOW);} //cue 15
        if(buf[i] == 'p') {digitalWrite(37, LOW);} //cue 16
        
               
	    Serial.print(" ");
	}
	Serial.println("");
        digitalWrite(13, false);

   }
}

Moderator edit: italics removed by adding code tags. Why is it so hard to read a few simple guidelines before posting?

RECIEVER_CODE2.ino (3.68 KB)

But I don't want to stop the program running for that 30 seconds. I've got all the program work apart from that 1 thing.
If any one can help I would appreciate it.

Suppose the time frame was 30 days, instead, and you are to do the job you want the Arduino do perform. You could set a timer for 30 days, and hang around waiting for it to go off. That's the delay() way.

Or, you could write down when you turned the pins on. Periodically, you'd check to see if the required time had passed. That's the blink without delay way.

In either case, when the time was up, you turn all the pins off.

hi all. im new to arduino. I’m having issues with the receiver - i need some help with writing the programme. The issue I have, is I want to make 16 output pin individually high, when they are told to go high - for about 30 seconds and then go low again. But I don’t want to stop the program running for that 30 seconds that they are high for. I’ve got all the program to work, apart from that 1 thing. if some one can help i would appreciate it. would love to get this working for all my fireworks

This is my working programming.

//* RECIEVER CODE

#include <VirtualWire.h>

void setup()
{
Serial.begin(9600); // Debugging only
Serial.println(“setup”);

// Initialise the IO and ISR
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_set_rx_pin(2);
vw_rx_start(); // Start the receiver PLL running
pinMode(13, OUTPUT);
pinMode(3, OUTPUT);

pinMode(22, OUTPUT);
pinMode(23, OUTPUT);
pinMode(24, OUTPUT);
pinMode(25, OUTPUT);
pinMode(26, OUTPUT);
pinMode(27, OUTPUT);
pinMode(28, OUTPUT);
pinMode(29, OUTPUT);
pinMode(30, OUTPUT);
pinMode(31, OUTPUT);
pinMode(32, OUTPUT);
pinMode(33, OUTPUT);
pinMode(34, OUTPUT);
pinMode(35, OUTPUT);
pinMode(36, OUTPUT);
pinMode(37, OUTPUT);

digitalWrite(13, LOW);
digitalWrite(3, HIGH);

digitalWrite(22, HIGH);
digitalWrite(23, HIGH);
digitalWrite(24, HIGH);
digitalWrite(25, HIGH);
digitalWrite(26, HIGH);
digitalWrite(27, HIGH);
digitalWrite(28, HIGH);
digitalWrite(29, HIGH);
digitalWrite(30, HIGH);
digitalWrite(31, HIGH);
digitalWrite(32, HIGH);
digitalWrite(33, HIGH);
digitalWrite(34, HIGH);
digitalWrite(35, HIGH);
digitalWrite(36, HIGH);
digitalWrite(37, HIGH);

}

void loop()
{

uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;

if (vw_get_message(buf, &buflen)) // Non-blocking
{
int i;

digitalWrite(13, true); // Flash a light to show received good message
// Message with a good checksum received, dump it.
Serial.print("Got: ");

for (i = 0; i < buflen; i++)
{
Serial.print(buf*);*
_ if(buf == ‘0’) {digitalWrite(3, LOW);} //firelive_
_ if(buf == ‘a’) {digitalWrite(22, LOW);} //cue 1
if(buf == ‘b’) {digitalWrite(23, LOW);} //cue 2
if(buf == ‘c’) {digitalWrite(24, LOW);} //cue 3
if(buf == ‘d’) {digitalWrite(25, LOW);} //cue 4
if(buf == ‘e’) {digitalWrite(26, LOW);} //cue 5
if(buf == ‘f’) {digitalWrite(27, LOW);} //cue 6
if(buf == ‘g’) {digitalWrite(28, LOW);} //cue 7
if(buf == ‘h’) {digitalWrite(29, LOW);} //cue 8
if(buf == ‘i’) {digitalWrite(30, LOW);} //cue 9
if(buf == ‘j’) {digitalWrite(31, LOW);} //cue 10
if(buf == ‘k’) {digitalWrite(32, LOW);} //cue 11
if(buf == ‘l’) {digitalWrite(33, LOW);} //cue 12
if(buf == ‘m’) {digitalWrite(34, LOW);} //cue 13
if(buf == ‘n’) {digitalWrite(35, LOW);} //cue 14
if(buf == ‘o’) {digitalWrite(36, LOW);} //cue 15
if(buf == ‘p’) {digitalWrite(37, LOW);} //cue 16_

* // cue off*
_ if(buf == ‘b’) {digitalWrite(22, HIGH);} //off cue 1
if(buf == ‘c’) {digitalWrite(23, HIGH);} //off cue 2
if(buf == ‘d’) {digitalWrite(24, HIGH);} //off cue 3
if(buf == ‘e’) {digitalWrite(25, HIGH);} //off cue 4
if(buf == ‘f’) {digitalWrite(26, HIGH);} //off cue 5
if(buf == ‘g’) {digitalWrite(27, HIGH);} //off cue 6
if(buf == ‘h’) {digitalWrite(28, HIGH);} //off cue 7
if(buf == ‘i’) {digitalWrite(29, HIGH);} //off cue 8
if(buf == ‘j’) {digitalWrite(30, HIGH);} //off cue 9
if(buf == ‘k’) {digitalWrite(31, HIGH);} //off cue 10
if(buf == ‘l’) {digitalWrite(32, HIGH);} //off cue 11
if(buf == ‘m’) {digitalWrite(33, HIGH);} //off cue 12
if(buf == ‘n’) {digitalWrite(34, HIGH);} //off cue 13
if(buf == ‘o’) {digitalWrite(35, HIGH);} //off cue 14
if(buf == ‘p’) {digitalWrite(36, HIGH);} //off cue 15
if(buf == ‘q’) {digitalWrite(37, HIGH);} //off cue 16_

* Serial.print(" ");*
* }*
* Serial.println("");*
* digitalWrite(13, false);*
* }*
}

Have you looked at the Blink Without Delay example in the tutorials? Seems to me all you want to do is lots of long blinks.....

Perhaps you and this guy:

http://forum.arduino.cc/index.php?topic=189392.msg1401161#msg1401161

should get together.

Not liking the answers you got in one thread is not a reason to start a new thread.

Topics merged.

A couple of things that you missed when you read the guidlelines:
DO NOT CROSS-POST
Do use tags when posting code.

hi all. sorry i am new to this forum
ive try the blink without delay and couldn't get it to work how i need it to. just go high straight away
thanks for your help

ive try the blink without delay and couldn't get it to work how i need it to. just go high straight away

So, rewrite it so that the outputs go low first.

ive try the blink without delay and couldn't get it to work how i need it to.

That code seems to be missing from your post.

hi thank u
now its stays low. will not come on

OK.
Thanks for letting us know.

if i put it at the beginning of the loop it woks. thank u so much

if i put it at the beginning of the loop it woks.

It? What is it?

woks? When will lunch be ready? I'm hungry.

The blink without delay if its at the end of the loop it will not turn pin high. but if i put it at the beginning it works
5 of Nov

The blink without delay if its at the end of the loop it will not turn pin high. but if i put it at the beginning it works

But, still no code...

Will put it on here when I've finish it. Only just done one ch. 15 to go lol

Only just done one ch. 15 to go lol

That's cutting and pasting one line of code, and changing the pin number. If the pin numbers were in an array, it would be a matter of changing the loop count. Something is wrong with your approach. Stop now, and post your code.

hi here my code its a bit of a mess

  #include <VirtualWire.h>
const int ledPin =  22;      // the number of the LED pin

// Variables will change:
int ledState = HIGH;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated


long interval = 1000;           // interval at which to blink (milliseconds)

void setup() {
  
    unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;
      

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  
     
	
        digitalWrite(13, false); }
  
   // Initialise the IO and ISR
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);	 // Bits per sec
    vw_set_rx_pin(2);
    vw_rx_start();       // Start the receiver PLL running
  
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT); 
  digitalWrite(ledPin, HIGH);
  
}

void loop()
{
   uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
	int i;

        digitalWrite(13, true); // Flash a light to show received good message
	// Message with a good checksum received, dump it.
	Serial.print("Got: ");
	
	for (i = 0; i < buflen; i++)
	{
	    Serial.print(buf[i]);
      
        if(buf[i] == 'a') {digitalWrite(ledPin, LOW);} //cue 1 
  

        
}}}

I suggest you start looking at how arrays will shorten your code, and make it easier to read and debug, whether or not you decide to use the "blink-without-delay" approach.

void setup() {
  
    unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > interval) {

When setup() is called, considerably less than 1000 milliseconds will have elapsed. This block of code will never be executed. Therefore, the whole thing looks silly here.

The random indenting and inconsistent placement of curly braces makes your code hard to read. Put each { on a new line. Put each } on a new line. Use Tools + Auto Format.