Having trouble using code I downloaded

So i am working on a project where my arduino is connected to a Bluetooth board and some inline sprinkler valves. I got this off of an instructables page which i will link, and i downloaded the code off of there because i don't have the time to write it all out, plus i don't know how to nether do i have the time so if someone could take a peek at it, that would be greatly appreciated.
Here is the link -> http://www.instructables.com/id/Android-Controlled-Pneumatic-Cannon-Powered-By-Ard/

(deleted)

spycatcher2k:
Did you remember to install the softserial library in the correct location (your arduino sketch directory/libraries)!

How do i do this? Because when ever i put my cruiser over the sketchbook option nothing pops up.

ilya2006:
if someone could take a peek at it, that would be greatly appreciated.

Perhaps it would help if you explained what you're asking for.

I'm just asking why its producing an error and how i can fix it.

ilya2006:
I'm just asking why its producing an error and how i can fix it.

post your code in a code box for a look.

Ok so i got past the begining by replacing some code with this: #include <Arduino.h> it was something else and i read that helped it, but now im getting another error.
here is the code im getting an error in:
#ifndef RELAY_H
#define RELAY_H

/* Left relay digital output pin */
#define RELAY_LEFT_PIN  6

/* Right relay digital output pin */
#define RELAY_RIGHT_PIN 7

/* Relay states. The valve state matches the relay state. So, an open relay 
   means air can flow out of the pressurized canister. */
typedef enum
{
    /* Open relay: circuit is open */
    RELAY_OPEN,
    
    /* Closed relay: circuit is closed */
    RELAY_CLOSED
} relay_state_type;

/* Initialize the relay pins */
void relay_init();

/* Set the state of the specified relay */
void relay_set_state(uint8_t pin, relay_state_type state);

#endif /* !RELAY_H */
[code/]

ilya2006:
now im getting another error.

We really need to see the complete code and the complete compiler output, to have any chance of finding the cause of compilation errors.

I'm now having trouble at the timer part.
Here is the entire code:

#include <Arduino.h>
#include "bt.h"

/* The serial port to use for the Bluetooth connection. On the Arduino Uno, 
   there is only one choice. Arduino Megas have the choice of Serial1 through 
   Serial4, if you're interested. */
#define s_bt_serial Serial

/* Input queue: external device to the Arduino */
static  msgq_type*  s_bt_in_msgq  = NULL;

/* Output queue: Arduino to external device */
static  msgq_type* s_bt_out_msgq = NULL;

/* Initialize the Bluetooth module */
void bt_init(msgq_type* bt_in_msgq, msgq_type* bt_out_msgq)
{
    s_bt_in_msgq  = bt_in_msgq;
    s_bt_out_msgq = bt_out_msgq;
    
    /* Either queue may be null. Check before initializing, lest ye blow yer 
       microprocessor into oblivion. */
    if (s_bt_in_msgq)
    {
        msgq_init(s_bt_in_msgq);
    }
    
    if (s_bt_out_msgq)
    {
        msgq_init(s_bt_out_msgq);
    }
    
    /* Initialize serial communication over the port */
    s_bt_serial.begin(BT_BAUD_RATE);
    pinMode(BT_RX_PIN, OUTPUT);
    pinMode(BT_TX_PIN, INPUT);
}

/* Waste energy until a Bluetooth message has been placed in to the queue. If 
   you really wanted to be cool, you'd put the microprocessor to sleep here and 
   have the incoming serial data interrupt wake it up. */
bool bt_wait_for_msgs()
{
    while (!s_bt_serial.available());
    return bt_check_for_msgs();
}

/* Add a message to the incoming Bluetooth queue, if one is available. 
   Returns true if a message was added. */
bool bt_check_for_msgs()
{    
    while (s_bt_serial.available())
    {
        uint8_t msg = 0;
        msgq_rsp_type rsp;
        
        msg = s_bt_serial.read();
        if (msg == BT_MSG_INVALID)
        {
            return false;
        }
        
        rsp = msgq_push(s_bt_in_msgq, msg);
        if (rsp != MSGQ_S_SUCCESS)
        {
            return false;
        }
    }
    
    return true;
}

#ifndef BT_H
#define BT_H

#include "com_inc.h"
#include "msgq.h"
 
/* Invalid message read from serial port. This approach possible because the 
   leftmost bit of a valid ASCII byte is always zero. */
#define BT_MSG_INVALID -1

/* Number of bytes in a valid bluetooth message */
#define BT_MSG_LEN 2

/* Bluetooth transfer pin -> Use the Arduino Uno's hardware serial I/O port. */
#define BT_TX_PIN 0 

/* Bluetooth receive pin */
#define BT_RX_PIN 1 
 
/* Bluetooth serial baud rate. This is the default on the BlueSmirf Silver. */
#define BT_BAUD_RATE 115200

/* Initialize the Bluetooth module */
void bt_init(msgq_type* bt_in_msgq, msgq_type* bt_out_msgq);

/* Waste energy until a Bluetooth message has been placed in to the queue. If 
   you really wanted to be cool, you'd put the microprocessor to sleep here and 
   have the incoming serial data interrupt wake it up. */
bool bt_wait_for_msgs();

/* Add a message to the incoming Bluetooth queue, if one is available. 
   Returns true if a message was added. */
bool bt_check_for_msgs();

#endif /* !BT_H */

#ifndef COM_INC_H
#define COM_INC_H

/* Include common files */
#include <stdint.h>
#include <limits.h>
#include <string.h>

#endif /* !COM_INC_H */

#include <Arduino.h>
#include "com_inc.h"
#include "evt_loop.h"
#include "bt.h"
#include "msgq.h"
#include "relay.h"

/* Timer period, in microseconds */
#define TIMER_DEFAULT_PERIOD 1000000

/* Bluetooth message queue */
static msgq_type bt_q; 

/* Initialize the main program's event loop */
void evt_loop_init()
{
    relay_init();
    bt_init(&bt_q, NULL);    
}

/* Process the data continuously */
void evt_loop_proc()
{
    uint16_t msg;
    msgq_rsp_type rsp;
    
    /* Sit here until a message is received from the Bluetooth queue */
    bt_wait_for_msgs();    
    msg = msgq_pop(&bt_q, &rsp);
    
    /* Reset the queue if there was a problem */
    if (rsp != MSGQ_S_SUCCESS)
    {
        bt_init(&bt_q, NULL);
        return;
    }
    
    /* Open the appropriate relay, and start the timer to close it 
       automatically one second later. */
    if (msg == '1')
    {
        relay_set_state(RELAY_LEFT_PIN, RELAY_OPEN);       
        timer_init(TIMER_DEFAULT_PERIOD);
        timer_set_cb(&evt_loop_handle_timer);
    }
    else if (msg == '2')
    {
        relay_set_state(RELAY_RIGHT_PIN, RELAY_OPEN);       
        timer_init(TIMER_DEFAULT_PERIOD);
        timer_set_cb(&evt_loop_handle_timer);   
    }
}

/* Handle the timer interrupt to close the relay automatically */
void evt_loop_handle_timer()
{
    relay_set_state(RELAY_LEFT_PIN,  RELAY_CLOSED);
    relay_set_state(RELAY_RIGHT_PIN, RELAY_CLOSED);
}

#ifndef EVT_LOOP_H
#define EVT_LOOP_H

#include "com_inc.h"
#include "timer.h"

/* Initialize the main program's event loop */
void evt_loop_init();

/* Process the data continuously */
void evt_loop_proc();

/* Handle the timer interrupt to close the relay automatically */
void evt_loop_handle_timer();

#endif /* !EVT_LOOP_H */


	{
        if (status != NULL)
        {
    		*status = MSGQ_S_EMPTY;
	    }

    	return 0;
	}
	
    if (status != NULL)
    {
	    *status = MSGQ_S_SUCCESS;
	}

	msg = msgq->msgs[msgq->head];
	msgq->head = (msgq->head + 1) & (MSGQ_LEN - 1);
	msgq->size--;
	
	return msg;
}

/* Pop a message off a given queue and populate the callback field. */
uint16_t msgq_pop_cb(msgq_type* msgq, msgq_rsp_type* status, msgq_cb_type cb)
{
	uint16_t msg;
	if (msgq->size <= 0)
	{
        if (status != NULL)
        {
    		*status = MSGQ_S_EMPTY;
	    }

    	return 0;
	}
	
    if (status != NULL)
    {
	    *status = MSGQ_S_SUCCESS;
	}

	msg = msgq->msgs[msgq->head];
	cb  = msgq->cbs[msgq->head];
	msgq->head = (msgq->head + 1) % MSGQ_LEN;
	msgq->size--;
	
	return msg;
}

/* Wait for a message to be added to the queue */
void msgq_wait(msgq_type* msgq)
{
	while(!msgq->size);
}

#ifndef MSGQ_H
#define MSGQ_H

#include "com_inc.h"

/* Maximum number of elements in a message queue */
#define MSGQ_LEN 128

/* Message queue callback function type */
typedef void(*msgq_cb_type)(void);

/* Message queue type */
typedef struct
{
	/* Index of the first element of the queue */
	uint8_t head;
	
	/* Size of the queue */
	uint8_t size;
	
	/* Messages */
	uint16_t msgs[MSGQ_LEN];

	/* Callbacks to be executed after the message is processed */
	msgq_cb_type cbs[MSGQ_LEN];
} msgq_type;

/* Status indicators that can be returned from a push/pope operation */
typedef enum
{
	/* Indicates a successful operation */
	MSGQ_S_SUCCESS,
	
	/* Indicates there was a problem reading */
	MSGQ_S_READ_ERROR,
	
	/* Indicates there was a problem writing */
	MSGQ_S_WRITE_ERROR,
	
	/* Indicates a full queue, write ignored */
	MSGQ_S_FULL,
	
	// Indicates an empty queue, read ignored */
	MSGQ_S_EMPTY
} msgq_rsp_type;

/* Initialize a message queue to default values */
void msgq_init(msgq_type* msgq);

/* Push a message onto a given queue. The return value indicates success or 
   failure. */
msgq_rsp_type msgq_push(msgq_type* msgq, uint16_t msg);

/* Push a message onto a given queue with a callback. Return value indicates 
   success or failure. */
msgq_rsp_type msgq_push_cb(msgq_type* msgq, uint16_t msg, msgq_cb_type cb);

/* Pop a message off of a given queue. Status parameter indicates success or 
   failure. If status is not MSGQ_S_SUCCESS, then the returned message is 0. */
uint16_t msgq_pop(msgq_type* msgq, msgq_rsp_type* status);

/* Same as msgq_pop, but the cb parameter is populated with the callback 
   function, which may be null */
uint16_t msgq_pop_cb(msgq_type* msgq, msgq_rsp_type* status, msgq_cb_type cb);

/* Wait for a message to be added to the queue */
void msgq_wait(msgq_type* msgq);

#endif /* !MSGQ_H */

#include <Arduino.h>
#include "relay.h"

/* Initialize the relay pins */
void relay_init()
{
    /* The relay pins are outputs */
    pinMode(RELAY_LEFT_PIN, OUTPUT);
    pinMode(RELAY_RIGHT_PIN, OUTPUT);
    
    /* Make sure both valves are closed , or this whole project's kinda 
       pointless */
    digitalWrite(RELAY_LEFT_PIN, LOW);
    digitalWrite(RELAY_RIGHT_PIN, LOW);
}

/* Set the state of the specified relay */
void relay_set_state(uint8_t pin, relay_state_type state)
{
    switch (state)
    {
        case RELAY_OPEN:
            digitalWrite(pin, HIGH);
            break;
        
        case RELAY_CLOSED:
        default:
            digitalWrite(pin, LOW);
            break;
    }
}

#ifndef RELAY_H
#define RELAY_H

/* Left relay digital output pin */
#define RELAY_LEFT_PIN  6

/* Right relay digital output pin */
#define RELAY_RIGHT_PIN 7

/* Relay states. The valve state matches the relay state. So, an open relay 
   means air can flow out of the pressurized canister. */
typedef enum
{
    /* Open relay: circuit is open */
    RELAY_OPEN,
    
    /* Closed relay: circuit is closed */
    RELAY_CLOSED
} relay_state_type;

/* Initialize the relay pins */
void relay_init();

/* Set the state of the specified relay */
void relay_set_state(uint8_t pin, relay_state_type state);

#endif /* !RELAY_H */

[code/]
i cant fit it all here hang on

this is the continuation:

#include <Arduino.h>

/* Get the TimerOne library from Google Code: 
       http://code.google.com/p/arduino-timerone/downloads/list 
   Documentation:
       http://arduino.cc/playground/Code/Timer1 */
#include <TimerOne.h>

#include "timer.h"

/* Timer period, in microseconds */
static uint16_t s_timer_per;

/* Timer expiry callback function */
static timer_cb_type s_timer_cb;

/* Timer mode */
static timer_mode_type s_mode;

/* Initialize the timer, but don't start it */
void timer_init(unsigned long period)
{
    s_timer_cb = NULL;
    timer_set_mode(TIMER_MODE_SINGLE_SHOT);
    timer_set_period(period); 
}

/* Set the operating mode */
void timer_set_mode(timer_mode_type mode)
{
    s_mode = mode;
}

/* Set the expiry function callback */
void timer_set_cb(timer_cb_type cb)
{
    s_timer_cb = cb;
}

/* Timer ISR */
void timer_service()
{
    if (s_timer_cb)
    {
        s_timer_cb();
    }
    
    if (s_mode == TIMER_MODE_SINGLE_SHOT)
    {
        Timer1.stop();
    }
}

/* Set the timer period and start ticking */
void timer_set_period(unsigned long period)
{
    s_timer_per = period;
    Timer1.stop();
    Timer1.initialize(period);
    Timer1.attachInterrupt(timer_service, period);
    Timer1.start();
}

#ifndef TIMER_H
#define TIMER_H

#include <Arduino.h>

/* Get the TimerOne library from Google Code: 
       http://code.google.com/p/arduino-timerone/downloads/list 
   Documentation:
       http://arduino.cc/playground/Code/Timer1 */
#include <TimerOne.h>

#include "com_inc.h"

/* Timer operating mode */
typedef enum
{
    /* Single shot: use to schedule an event at a fixed point in the future */
    TIMER_MODE_SINGLE_SHOT,
    
    /* Periodic: use the schedule an event to run at a periodic rate */
    TIMER_MODE_PERIODIC
} timer_mode_type;

/* Timer callback function type */
typedef void(*timer_cb_type)(void);

/* Initialize the scheduler timer, in microseconds */
void timer_init(unsigned long period);

/* Timer interrupt service routine */
void timer_service();

/* Set the timer data report callback function */
void timer_set_cb(timer_cb_type cb);

/* Set the mode to either single-shot or periodic */
void timer_set_mode(timer_mode_type mode);

/* Set the scheduler timer's data period, in microseconds */
void timer_set_period(unsigned long period);

#endif /* !TIMER_H */
[code/]

If your sketch is too big to be included in a post, add it in an attachment.

We also need to see the compiler output.

Theres the INO file i presume thats what you want, but i have no clue where to find the compiler output

sketch_apr03a.ino (2 Bytes)

but i have no clue where to find the compiler output

At the bottom of the IDE. That part that says something other than the size of the sketch in bytes.

PaulS:

but i have no clue where to find the compiler output

At the bottom of the IDE. That part that says something other than the size of the sketch in bytes.

Yeah that's the problem I can't compile it completely because i keep getting an error: 'Timer1' was not declared in this scope

Yeah that's the problem I can't compile it completely because i keep getting an error: 'Timer1' was not declared in this scope

You get more than that. You get the name of the file and the line number. That is the information you need to share.

Have you downloaded and installed (in the proper place) the requisite library(s)?

yeah, I went and downloaded the timer, extracted it, put it in a folder and put that folder into the library folder for the arduino.

This is what i got in the error bar
timer.cpp: In function 'void timer_service()':
timer.cpp:50: error: 'Timer1' was not declared in this scope
timer.cpp: In function 'void timer_set_period(long unsigned int)':
timer.cpp:58: error: 'Timer1' was not declared in this scope

yeah, I went and downloaded the timer

From where?

put it in a folder

Did that folder have a name?

and put that folder into the library folder for the arduino.

Which one? There are two - the right one and the wrong one. The right one is the libraries (not library) folder in the sketch folder. The wrong one is the libraries folder in the arduino-x.x.x folder. That one is for core libraries only.

Yes, I do believe I put it in the correct folder, I did put it in the Libraries folder, I made a separate folder called Timer1 and dragged it into the libraries folder and i got it from here -> Arduino Playground - HomePage