Show Posts
Pages: [1] 2 3 ... 9
1  Forum 2005-2010 (read only) / Troubleshooting / Re: Software Date Time library, uploads, then what? on: February 24, 2009, 12:17:27 am
Thanks Lefty.  I looked that up, it is a possibility.

2  Forum 2005-2010 (read only) / Troubleshooting / Re: Software Date Time library, uploads, then what? on: February 23, 2009, 08:16:19 pm

MEM stated:
  Hi pakrat, the sketch is waiting for the time to be set from the pc.

If you add the following line in setup, the clock will start from Jan 1 2009 when the sketch starts:

Thanks Mem.  I got the sample sketch to operate, using the whole sketch by itself, but I'm not sure of how to use the datetime library in another sketch.
I triied using parts of the sample code in another sketch and got decimal numbers to start at zero and increase by one per second,
 using this much of the sample code:

#include <DateTime.h>
#include <DateTimeStrings.h>

void setup(){

void  loop(){
  unsigned long  prevtime;
  prevtime =;
  Serial.print("Clock synced at: ");

It appears to me that the whole dateTime sample code needs to be applied in whatever sketch is being used.  So I tried that, but it didn't work.  

I notice that after the sketch is stopped or shut down,  upon restarting the timing starts right from the beginning.  It seems that this code will be useful in a chip that is in continuous use, but in a chip that will be stopped or disconnected then moved, things could get confusing, especially if used for intermittant data logging.

3  Forum 2005-2010 (read only) / Troubleshooting / Software Date Time library, uploads, then what? on: February 23, 2009, 02:25:49 am
I found this: Software Date Time library in arduino playground.  I downloaded it into arduino-0013 > hardware > libraries.  There is a read only memo that gives directions and a sample sketch to upload to your arduino.  I did all this.  The verify and upload went just fine, but nothing happened.
 What else needs to be done?
It can be found here:""
It seems to me that LED-13 should blink, and info should appear on the serial monitor, but none of this happens.

I would like to know how to use this software.  


// DateTime.pde
// example sketch for the DateTime library

#include <DateTime.h>
#include <DateTimeStrings.h>

#define TIME_MSG_LEN  11   // time sync to PC is HEADER followed by unix time_t as ten ascii digits
#define TIME_HEADER  255   // Header tag for serial time sync message

void setup(){
  pinMode(13,OUTPUT); // we flash the LED each second

void  loop(){
  unsigned long  prevtime;
  if( getPCtime()) {  // try to get time sync from pc
    Serial.print("Clock synced at: ");
  if(DateTime.available()) { // update clocks if time has been synced
    digitalWrite(13,LOW);  // first flash the LED
    prevtime =;
    while( prevtime == )  // wait for the second to rollover
    DateTime.available(); //refresh the Date and time properties
    digitalClockDisplay( );   // update digital clock

    // send our time to any app at the other end of the serial port
    Serial.print( TIME_HEADER,BYTE); // this is the header for the current time

boolean getPCtime() {
  // if time sync available from serial port, update time and return true
  while(Serial.available() >=  TIME_MSG_LEN ){  // time message consists of a header and ten ascii digits
    if( == TIME_HEADER ) {        
      time_t pctime = 0;
      for(int i=0; i < TIME_MSG_LEN -1; i++){  
        char c=;          
        if( c >= '0' && c <= '9'){  
          pctime = (10 * pctime) + (c - '0') ; // convert digits to a number    
      DateTime.sync(pctime);   // Sync Arduino clock to the time received on the serial port
      return true;   // return true if time message received on the serial port
  return false;  //if no message return false

void digitalClockDisplay(){
  // digital clock display of current date and time
  Serial.print(" ");
  Serial.print(" ");
  Serial.print(" ");

void printDigits(byte digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  if(digits < 10)


4  Forum 2005-2010 (read only) / Syntax & Programs / Re: What is " uint8_t" ? on: March 16, 2009, 11:23:15 am
Posted by: mem Posted on: Today at 17:30:45
uint8_t is the same as a byte.

Thank you

5  Forum 2005-2010 (read only) / Syntax & Programs / What is " uint8_t" ? on: March 16, 2009, 10:23:14 am
What is uint8_t?  What is it used for?  
It appears to be a designation for integers or functions.  I see it used in sketches, such as, "uint8_t count", but am not sure what it does.

6  Forum 2005-2010 (read only) / Syntax & Programs / Re: using pulseIn, how can/should interrupts be used? on: February 18, 2009, 09:16:18 pm
Thanks everybody.  I believe I've got it.
What I would like to do, is attach the output of a multivibrator to pin 2, or 3, then count the pulses per a chosen time period, for instance pulses per second.  If I can use the method of interrupts to do so.

7  Forum 2005-2010 (read only) / Syntax & Programs / Re: using pulseIn, how can/should interrupts be used? on: February 17, 2009, 12:50:42 am
Posted by: billh
If you decide to use interrupts you will have to switch to a different pin. The Arduino only supports hardware interrupts on digital pins 2 and 3. You can read about that here:

I went to the address you give, and after the interrupt explanation, this example is given.  But I don't see where pins 2 or 3 fit in

int pin = 13;
volatile int state = LOW;

void setup()
  pinMode(pin, OUTPUT);
  attachInterrupt(0, blink, CHANGE);
void loop()
  digitalWrite(pin, state);

void blink()
  state = !state;

How is pin 2 or pin 3 affected?
How is one or the other connected?
Thanks for the help
8  Forum 2005-2010 (read only) / Syntax & Programs / using pulseIn, how can/should interrupts be used? on: February 15, 2009, 04:03:03 pm
I have used the included code to read pulse length.  The input to pin-7 is square waves from a multivibrator at approximately 80 pulses/ second.  The code puts out readings every 1000ms.
There are two things that I need to ask about this code.
(1) Will there be any benefit to using interrupts?  This code is a practice run for me, since I'm quite new at this.  I understand the concept of interrupts, but I don't know how to use them.  I tried putting the pulseIn command in during the time counting procedure - "time = millis()"  (as part of a while statement) but it didn't work, so I put it before  "time = millis();" .  Would interrupts make it possible to do other things while the timing is proceeding?

(2) If there is no input to pin-7 before upoading to board, everything locks up, computer and all.  I had a lot of problems getting things back in order after this happened.  How can I prevent such a lockup?


unsigned long time;
unsigned long oldtime = 0;
 int x;
 int pin = 7;
 unsigned long hpulse;
void setup(){
  pinMode(pin, INPUT);
void loop(){
  hpulse = pulseIn(pin, HIGH,8000);
  time = millis();
  x = (time - oldtime);
  if (x >= 997){       [glow]//OTHER PROCEDURES ADDED TIME RESULTING IN X > 1000[/glow]
   Serial.print("x: ");
   Serial.print("PULSE: ");
   Serial.print("time: ");
     //prints time since program started
   oldtime = time;


I'm using this code as a base to learn more about arduino code by
adding more code and procedures: adding an LCD, performing math procedures; things that will take more time in between pulse readings.
Thank you
9  Forum 2005-2010 (read only) / Interfacing / Re: How to transfer dat from serial port to PCsoftware on: March 31, 2010, 08:07:54 pm
[size=14]Thank you, Coding Badly and  retrolefty.[/size]
10  Forum 2005-2010 (read only) / Interfacing / How to transfer dat from serial port to PCsoftware on: March 31, 2010, 01:00:30 am
I can read data from 24LC512 external EEPROM via I2C. The data shows up ina serial port, in -0017 COM4.  How can I transfer that data from serial port to another PC software, such as notepad or even a spreadsheet?

24LC512 I2C code

#include <Wire.h>
int runs;
unsigned int x = 0;
int i = 1;
const int deviceaddress = 80;
unsigned int endaddress;
int startaddress;
unsigned int eeadd;
unsigned int diff;
int r = 0;
int a = 1;
void setup(){

void loop(){
  while (a == 1){
    diff = i2c_eeprom_read_byte(deviceaddress, 2 );//endaddress-startaddress
    Serial.print("diff :");
    runs = i2c_eeprom_read_byte(deviceaddress, 3 );
    i2c_eeprom_write_byte(deviceaddress, 3, 1 );

    Serial.print("runs :");
    a = (a + 1);

  endaddress = i2c_eeprom_read_byte(deviceaddress, 0 );//last addr. filled
  while (i <=(runs * diff) && i <= endaddress ){
    //if (i == (endaddress - 5)){
    //i2c_eeprom_write_byte( deviceaddress, eeaddress, (byte)CPS);  
    // }
    r =  i2c_eeprom_read_byte(deviceaddress, 3 );
    Serial.print("r :");

    Serial.print("endaddress 1023 :");
    startaddress =  i2c_eeprom_read_byte(deviceaddress, 1 );
    startaddress =  (startaddress - ((runs - 1)* diff));
    if (startaddress <= 0 || startaddress > (endaddress - 10)){
      startaddress = 0;
    Serial.print("startaddress :");
    for (eeadd = startaddress; eeadd < endaddress; eeadd++) {
      x = i2c_eeprom_read_byte(deviceaddress, eeadd );
      x = x*10;

      Serial.print(eeadd, DEC),
      Serial.print(" "),

      i = (i + 1);

byte i2c_eeprom_read_byte( int deviceaddress, unsigned int eeaddress ) {
  byte rdata = 0xFF;
  Wire.send((int)(eeaddress >> smiley-cool); // MSB
  Wire.send((int)(eeaddress & 0xFF)); // LSB
  if (Wire.available()) rdata = Wire.receive();
  return rdata;

void i2c_eeprom_write_byte( int deviceaddress, unsigned int eeaddress, byte data ) {
  int rdata = data;
  Wire.send((int)(eeaddress >> smiley-cool); // MSB
  Wire.send((int)(eeaddress & 0xFF)); // LSB

Data shows up on COM4, but I can't transfer or copy from COM4.
Thanks PO'T
11  Forum 2005-2010 (read only) / Development / Re: Frequency Counter Library on: February 13, 2009, 01:01:06 am
I've downloaded this›

copied and entered this code into my Arduino - 0012
#include <FreqCounter.h>

void setup() {
  Serial.begin(57600);                    // connect to the serial port
  Serial.println("Frequency Counter");

long int frq;
Void loop() {

 FreqCounter::f_comp= 8;             // Set compensation to 12
 FreqCounter::start(100);            // Start counting with gatetime of 100ms
 while (FreqCounter::f_ready == 0)         // wait until counter ready
 frq=FreqCounter::f_freq;            // read result
 Serial.println(frq);                // print result

When I attempt to verify the "frequency counter" code I get :
error: FreqCounter.h: no such file or directory

I've downloaded and unzipped into :Arduino-12 > hardware > libraries.  Where it is now quietly residing, but arduino-alpha doesn't seem to know that.

Posted by: Kyle McDonald Posted on: 06.02.2009 at 22:12:18
Yes, it's working well for me now. I've modified mine to be "PulseCounter" rather than "FreqCounter", as I'm more curious about how many pulses occur over a short period of time, and not very worried about compensating with delays, etc. (If you're doing capacitive sensing and normalizing the output, the exact frequency isn't really necessary.)

I would also like to use this or similar code as a pulse counter.  Will this code do the trick?   Or is there more to it than that?


I've also downloaded and extracted:
After attempting to verify I get:25: error: FreqCounter.h: no such file or directory In function 'void loop()';

12  Forum 2005-2010 (read only) / Troubleshooting / Re: Please help!!! on: April 04, 2009, 10:07:51 pm
This problem usually has something to do with "port selection".  On the arduino main operating window, look under tools for "serial port"(its right after "Board").  There should be one or more port selections, pick one and try that out.

You can observe the port activity in the PC's "device manager", by going to (1)control panal >(2)Hardware & sound >(3)device manager.  If you have your arduino plugged into a USB port it will show up in ports(COM & LPT).  You need to click on ports(COM & LPT), to see which port is being used.  I don't know if this is recommended, but when this problem happens to me, I pull the USB plug out and watch what happens to "ports(COM & LPT)".  It dissappears, then when USB is reconnected it reappears and shows the port # again.  For me, it took that procedure to get things kicked into shape.
But, with that "procedure", you might have to check with the more knowledgeable folks, since I'm also a "NEWBIE".  As I stated , it might not be recommended.

I'm assuming the diecimila operates via USB.  I have an Arduino compatable RBBB that I had to get a seperate TTL to USB conversion ckt,  I had the problem you're having until I disvovered that the RX and TX leads neaded to be switched around.

13  Forum 2005-2010 (read only) / Interfacing / Re: 12v dc motor controller on: February 08, 2010, 10:16:57 pm


You need to know what kind of motor you have.  Can you find a model number or a name or something on the motor?  If so, you can just google it up on the internet; find out as much info on the motor as you can.

Small dc motors don't cost too much.  Check the address (ALLELECTRONICS) that I posted in a previous post.
I've found small dc motors in hardware stores for $1.00 or just a few bucks.
14  Forum 2005-2010 (read only) / Interfacing / Re: 12v dc motor controller on: February 08, 2010, 07:20:15 pm
If you're looking for small DC motors, 12v or so, look here:

True, the article youi referred to concerned AC motors.

15  Forum 2005-2010 (read only) / Interfacing / Re: 12v dc motor controller on: February 08, 2010, 07:07:16 pm
Single phase usually refers to single phase AC, as opposed to three phase AC. smiley
Pages: [1] 2 3 ... 9