Go Down

Topic: Wireless Stopwatch (Read 94 times) previous topic - next topic

LePitstop

I made a wireless stop watch with a 433mhz transmitter and receiver. I want to start the stopwatch with a pushbutton and stop it with a knocksensor at 30 feet wider. My problem is i cannot go over 6 inches. Everything works at 6 inches but more than that the stopwatch didn't stop. If someone can help me.

Code: [Select]

//Transmitter
#define rfTransmitPin 4

const int code = 1234;
 int ledPin = 13;
int knockSensor = A2;               
byte val = 0;
int statePin = LOW;
int THRESHOLD = 175;

void setup() {
pinMode(rfTransmitPin, OUTPUT);
pinMode(ledPin,OUTPUT);
pinMode(rfTransmitPin,LOW);
  Serial.begin(9600);
 
 
}

void loop() {
val = analogRead(knockSensor);

if (val >= THRESHOLD) {        // check the piezo
    digitalWrite(rfTransmitPin, HIGH);
    digitalWrite (ledPin,HIGH);
     Serial.println ("hit");
    Serial.println (rfTransmitPin);
    delay (5000);
    digitalWrite(ledPin, LOW);// turn on or off the LED
   
   
   
   
 
 
 
  }
 
}

 // RECEIVER
#include<Wire.h>
#include <LiquidCrystal_I2C.h>

//SDA= A4 et SCL = A5
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

#define rfReceivePin 9 // Le receiver rf doit etre sur le 3v
#define ledPin 13
int buzzer = 3;
int data =0;


void setup()
{
   lcd.begin (16,2);
  Serial.begin (9600);
  lcd.print ("REALISE PAR:");
  delay(2000);
  lcd.setCursor (3,1);
  lcd.print ("REAL GAMER");
  delay (2000);
  lcd.clear();
  lcd.setCursor(6,0);
  lcd.print("POUR");
  delay(2000);
  lcd.setCursor (3,1);
  lcd.print ("AIRSOFT QC.");
  delay (4000);
  lcd.clear();
  lcd.setCursor (1,0);
  lcd.print("APPUYEZ START"); 
  pinMode(ledPin, OUTPUT);
 
 
  Serial.begin(9600);
  pinMode (buzzer,OUTPUT);
  pinMode(8, INPUT);
  digitalWrite(8, HIGH);
  pinMode(9, INPUT);
  digitalWrite(9, HIGH);
  pinMode(13, OUTPUT);
 
}
double i = 0;
double a = millis();
double c ;

void loop()
{
delay(100);
 
 if(digitalRead(8) == LOW)// switch button
 {
digitalWrite (buzzer,HIGH);
        delay(500);
        digitalWrite (buzzer,LOW);
        delay(500);
        digitalWrite (buzzer,HIGH);
        delay(500);
        digitalWrite (buzzer,LOW);
        delay(500);
        digitalWrite (buzzer,HIGH);
        delay (500);
        digitalWrite (buzzer,LOW);
        delay(500);
        digitalWrite (buzzer,HIGH);
        delay(1000);
        digitalWrite (buzzer,LOW);
    lcd.clear();
 a = millis();
   while(digitalRead(9) == HIGH)
   {
   
     c = millis();
   i = (c - a) / 1000;
   lcd.print(i);
   lcd.setCursor(11,0);
   lcd.print("Sec's");
   lcd.setCursor(0,0);
   Serial.println(c);
   Serial.println(a);
   Serial.println(i);
   Serial.println("......");
     delay(100);
   }
   
   if(digitalRead(9) == LOW)// cible switch
   {
    digitalWrite (buzzer,HIGH);
       delay (200);
       digitalWrite (buzzer,LOW);
       delay (200);
       digitalWrite(buzzer,HIGH);
       delay(200);
       digitalWrite(buzzer,LOW);
     while(digitalRead(8) == HIGH)
     {
               
       lcd.setCursor(0,0);
       lcd.print(i);
       lcd.setCursor(11,0);
       lcd.print("Sec's");
       lcd.setCursor(0,0);
       delay(1000);
       lcd.setCursor (1,3);
       delay(2000);
         
       lcd.print ("REJOUER/START");
     }
   }

 }
 
 

}

weedpharma

Where is your list of parts (with links) and circuit? We need full description of the project not just a program.

Weedpharma

musskopf

You haven't provide much details but if you're using those $1 RF modules just reconsider it. Those modules are not very reliable and, as you already discovered, they have very limited range. You could try to check the Max voltage for the transmitter and check the antenna sizer you're using to increase the range

Other option is to move to a more sophisticated RF module like RFM69 or nrf24l01. They will cost a bit more, but you'll have additional features and learn skills that can be used on other projects.

Cheers
http://talk2.wisen.com.au

jremington

#3
Jul 06, 2016, 05:40 am Last Edit: Jul 06, 2016, 06:00 am by jremington
It looks like you are trying to use the 433 MHz modules as binary on/off transmitters, but the receivers won't work that way. You need to use something like the VirtualWire or RadioHead libraries to transmit and receive on/off codes, which allow error detection to prevent false starts and stops.

Alternatively, you can use pushbutton keyfob transmitter and receiver modules like these, which create and send the codes when you push a button.

Note that sending and receiving a code takes a few tens of milliseconds, so if your stopwatch timing is critical, you need to take that delay into account.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy