crono

hi every one im new to arduino and programming i play airsoft and wanted to make my own crono and found some code online but seem to be having some problems getting it working if any one could help that would be great

////////////////////////
//
// Arduino Uno
//
////////////////////////
//
// Sketch: Chronograph
//

#include <util / delay.h>

double data;

volatile unsigned char s1 = 0;
volatile unsigned char s2 = 0;

// Timer / Counter 0 initialization
void Timer0_Init (void)
{
TCNT0 = 0;

// Bits: COM0A1 COM0A0 COM0B1 COM0B0 - - WGM01 WGM00
TCCR0A = 0;

// Bits: FOC0A FOC0B - - WGM02 CS02 CS01 CS00
TCCR0B = 0;

// Bits: - - - - - OCIE0B OCIE0A TOIE0
TIMSK0 = 0;

// Bits: - - - - - OCF0B OCF0A TOV0
TIFR0 = 0;
}

// Timer / Counter 1 initialization
void Timer1_Init (void)
{
TCNT1 = 0;

// Bits: COM1A1 COM1A0 COM1B1 COM1B0 - - WGM11 WGM10
TCCR1A = 0;

// Bits: ICNC1 ICES1 - WGM13 WGM12 CS12 CS11 CS10
TCCR1B = 0;

// Bits: FOC1A FOC1B - - - - - -
TCCR1C = 0;

// Bits: - - ICIE1 - - OCIE1B OCIE1A TOIE1
TIMSK1 = 0;

// Bits: - - ICF1 - - OCF1B OCF1A TOV1
TIFR1 = 0;
}

void setup ()
{
// Global disable interrupts
cli ();

// Timer / Counter 0 initialization
Timer0_Init ();

// Timer / Counter 1 initialization
Timer1_Init ();

// Global enable interrupts
sei ();

Serial.begin (9600);

attachInterrupt (0, sensor_1, FALLING);
attachInterrupt (1, sensor_2, FALLING);
}

void loop ()
{
while (s1 == 0 && s2 == 0);
_delay_ms (800); // wait 800 ms

if (s1! = 0 && s2! = 0)
{
data = 0.06 / (TCNT1 * (1.0 / 16000000.0)); // v = s / t
}
else
{
data = 0;
}

Serial.println (data);

TCCR1B = 0;
TCNT1 = 0;

s1 = 0;
s2 = 0;
}

void sensor_1 ()
{
if (s1 == 0)
{
TCCR1B = (1 << CS10); // Timer / Counter 1 running (no prescaling)
s1 = 1;
}
}

void sensor_2 ()
{
if (s2 == 0)
{
TCCR1B = 0; // Timer / Counter 1 stopped (no clock source)
s2 = 1;
}
}

//
// End
//
////////////////////////

You have some improperly posted code that does something. You expect it to do something. You forget to tell us what it actually does. You forgot to tell us what you expect, or what your problems are.

it has 2 infared leds facing 2 ifared sensors and once the first and second sensor get broken it posts a reading on the screen on what ms it was so the person on line says it should do

So, what problem are you having?

when i go to compile it comes up with this

C:\Users\karen\Documents\Arduino\sketch_apr04a\sketch_apr04a.ino\sketch_apr04a.ino.ino: In function 'void loop()':

sketch_apr04a.ino:81: error: expected ')' before '!' token

if (s1! = 0 && s2! = 0)

^

exit status 1
expected ')' before '!' token

Looks like somehow you got a space between the ! And = of !=.

thanks johnwasser that work but nothing is working so il have to go back and look see what the problem is as once i break the sensors nothing come up on the display