Hello,im doing a stopwatch project regarding runner's training.In my main arduino(master) i want to use an nrf24l01 to get feedback from the runner(heart rate etc.) and i want to use at the same time an sd card module to store data such as time,heart rate,body temp.I know that using both of them at the same time is not feasible or very very difficult so i thought of using the protocol I2C to connect another arduino(slave) to the master one so to have the sd module there implemented to store the data.Now the problem that occurs is that i cannot send the time as it is for example as a float(or double).Is there anyway to achieve sending more bytes or is my whole thinking wrong.
#include <LiquidCrystal.h>
#include <Wire.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
void setup()
{
lcd.begin(16, 2);
lcd.clear();
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600);
pinMode(8, INPUT);
digitalWrite(8, HIGH);
pinMode(9, INPUT);
digitalWrite(9, HIGH);
pinMode(10, INPUT);
digitalWrite(10, HIGH);
}
float i = 0;
double a = millis();
double c ;
void loop()
{
lcd.clear();
lcd.print("press start");
delay(200);
if(digitalRead(8) ==HIGH)
{
lcd.clear();
a = millis();
while(digitalRead(9) == LOW)
{
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(200);
}
if(digitalRead(9) == HIGH)
{
while(digitalRead(8) == LOW)
{
lcd.setCursor(0,0);
lcd.print(i);
lcd.setCursor(11,0);
lcd.print("Sec's");
lcd.setCursor(0,0);
delay(100);
}
Wire.beginTransmission(9); // transmit to device #4
Wire.write("TIME IS "); // sends five bytes
Wire.write( i); // sends one byte
Wire.endTransmission(); // stop transmitting
}
}
}