hello everybody Im new in arduino world and before I write my question excuse me for my english.
I want to make 10 buttons to be inputs on arduino_one, every button is start and stop for its own
“stopwatch” and that arduino_one sends that time over rf 433 to arduino_two.
Arduino_two then receives that 10 times and compare its to threshold of 90sec if any time is biger then threshold then arduino_two print that time to LCD and print “lap time” to pc over serial and next to that time lap actual time meaning date and time.
As now:
I have no idea how to get “timestamp”
have only one “stopwatch”
On serial i get time every second not the “lap time” start-stop time.
I have figured out lcd print of the time and if time is biger then threshold serial output is displayed.
I found a way to recognize 10 times over rf433 by changing bitlenght // if (mySwitch.available()) {
if (( mySwitch.getReceivedBitlength()) == 32 ){""
code of sending arduino_one
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
const int buttonPin = 9; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
const int ledica = 11;
int ledState = HIGH; // the current state of the output pin
int buttonState; // the current reading from the input pin
int lastButtonState = LOW;// the previous reading from the input pin
unsigned long vrijeme = 0;
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
unsigned long debounceDelay = 50; // the debounce time; increase if the output flickers
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
pinMode(ledica, OUTPUT);
// set initial LED state
digitalWrite(ledPin, ledState);
mySwitch.enableTransmit(10);
}
void loop() {
// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);
// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing:
if (reading != lastButtonState) {
// reset the debouncing timer
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
// if the button state has changed:
if (reading != buttonState) {
buttonState = reading;
// only toggle the LED if the new button state is HIGH
if (buttonState == HIGH) {
ledState = !ledState;
}
}
}
// set the LED:
digitalWrite(ledPin, ledState);
// save the reading. Next time through the loop,
// it'll be the lastButtonState:
vrijeme = (millis() - lastDebounceTime);
lastButtonState = reading;
vrijeme_loop();
seriski_ispis();
}
void vrijeme_loop(void)
{
Serial.print(vrijeme/1000);
(mySwitch.send((vrijeme/1000) ,32));
}
void seriski_ispis(void)
{
if (vrijeme/1000 > 10)
{
digitalWrite(ledica, HIGH);
}
else{
digitalWrite(ledica, LOW);
}
}
code of reciver arduino_two
/*
Simple example for receiving
http://code.google.com/p/rc-switch/
*/
#include <RCSwitch.h>
#include <LiquidCrystal.h>
RCSwitch mySwitch = RCSwitch();
LiquidCrystal lcd(7, 6, 5, 4, 3, 8);
unsigned long time=0;
const int led = 13;
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2
lcd.begin(16, 2);
pinMode(13, OUTPUT);
}
void loop()
{
read_data();
lcd_display();
}
//**********************************************************
void read_data(void)
{
if (mySwitch.available()) {
if (( mySwitch.getReceivedBitlength()) == 32 ){
unsigned long time1 = mySwitch.getReceivedValue();
time = time1;
}
}
if (time > 90){
digitalWrite(led, HIGH);
Serial.print("1600/2: ");
Serial.print(time);
Serial.print('\n');
}
else{
digitalWrite(led, LOW);
}
}
//***************************************************
void lcd_display()
{
lcd.setCursor(0, 0);
lcd.print("1600/2");
lcd.setCursor(0, 1);
lcd.print("time pased");
lcd.print(time);
delay(300);
lcd.clear();
}
//**************************