I need some help.. im new in arduino
i desperately need help.. have arduino uno, sd shield, serial lcd display, , tipping bucket.
my goal make digital tipping bucket.
procedure:
1. read data tipping bucket every time ticked.
2. display data serial lcd display.
3. save data sd shield including time , date when tipping bucket tipped.
my question how program clock without using external hardware, , how sync tipping bucket?
here code
my goal make digital tipping bucket.
procedure:
1. read data tipping bucket every time ticked.
2. display data serial lcd display.
3. save data sd shield including time , date when tipping bucket tipped.
my question how program clock without using external hardware, , how sync tipping bucket?
here code
code: [select]
#include <softwareserial.h>
#include <sd.h>
#define modepin 2
file myfile;
const int switchpin = 7; // // reed switch digital pin 7
int counter;
int infinite; // (/)
int tipped;
int nt;
float pertipped; // (/)
//---------------------
void setup(){
serial.begin(9600);
delay(1500); // allow time serial lcd set up
digitalwrite(modepin, high);
pinmode(switchpin, input); // switchpin input
digitalwrite(switchpin, high); // activate internal pullup resistor
serial.write(0x02);
serial.print("f");
serial.write(0x03);
serial.write(0x02); //stx code
serial.print("c"); //c - clear lcd function
serial.write(0x03); //etx code
while (!serial) {
; // wait serial port connect. needed leonardo only
}
serial.write(0x02);
serial.print("1");
serial.print("starting sd card...");
serial.write(0x03);
pinmode(10, output);
if (!sd.begin(4)) {
serial.write(0x02);
serial.print("2");
serial.print("starting failed!");
serial.write(0x03);
return;
}
serial.write(0x02);
serial.print("2");
serial.println("starting done.");
serial.write(0x03);
serial.write(0x02); //stx code
serial.print("c"); //c - clear lcd function
serial.write(0x03); //etx code
};
void loop(){
tipped = digitalread(switchpin); //
delay(70);
pertipped += 0.50;
nt += 1;
myfile = sd.open("robin.txt", file_write);
myfile.print(pertipped);
myfile.print(" ");
myfile.println(nt);
myfile.close();
serial.write(0x02); //stx
serial.print(">"); // send position info
serial.print(a);
serial.write(0x03); //etx
serial.write(0x02); //stx
serial.print("3");
serial.print(pertipped); //
serial.write(0x03); //etx
//---------------------------------------
serial.write(0x02); //stx
serial.print(">"); // send position info
serial.print(a);
serial.write(0x03); //etx
serial.write(0x02); //stx
serial.print("4");
serial.print(nt); //
serial.write(0x03); //etx
};
firstly time issue
there library managing time http://playground.arduino.cc/code/time
however you'd need somehow set this, , there no way without sort of external hardware, i.e either realtime clock module, or other clever solutions getting time via wifi connection etc.
re: triggering when bucket tipped
firstly you'll need debounce switch see http://playground.arduino.cc/code/bounce
secondly, in loop need wait "switchpin" change state (ie function of debounce code)
i.e if switch active high, without debounce need this
there library managing time http://playground.arduino.cc/code/time
however you'd need somehow set this, , there no way without sort of external hardware, i.e either realtime clock module, or other clever solutions getting time via wifi connection etc.
re: triggering when bucket tipped
firstly you'll need debounce switch see http://playground.arduino.cc/code/bounce
secondly, in loop need wait "switchpin" change state (ie function of debounce code)
i.e if switch active high, without debounce need this
code: [select]
void loop(){
while(!digitalread(switchpin)); // poll waiting switch go high (note needs debounced !!!!)
// delay(70); // pointless if use debounce
pertipped += 0.50;
nt += 1;
myfile = sd.open("robin.txt", file_write);
myfile.print(pertipped);
myfile.print(" ");
myfile.println(nt);
myfile.close();
serial.write(0x02); //stx
serial.print(">"); // send position info
serial.print(a);
serial.write(0x03); //etx
serial.write(0x02); //stx
serial.print("3");
serial.print(pertipped); //
serial.write(0x03); //etx
//---------------------------------------
serial.write(0x02); //stx
serial.print(">"); // send position info
serial.print(a);
serial.write(0x03); //etx
serial.write(0x02); //stx
serial.print("4");
serial.print(nt); //
serial.write(0x03); //etx
};
Arduino Forum > Using Arduino > Programming Questions > I need some help.. im new in arduino
arduino
Comments
Post a Comment