Show Posts
Pages: [1] 2 3 ... 187
1  Using Arduino / General Electronics / Re: Powering LEDs on: September 18, 2014, 06:13:29 am
If you don't limit the current,  they can consume everything you throw at them until it burns out, melts whatever...

There are a few ways to limit the current, the easiest is a series resistor... obviously that depends on the led in question
2  Using Arduino / General Electronics / Re: Not all breadboards created equal on: September 18, 2014, 12:34:18 am
He kept using puff... top many puffs stick to 'pf' or pico farad  dave not 12puffs lol
3  Using Arduino / Project Guidance / Re: How to update 1000's of ardunio's on: September 17, 2014, 11:24:44 am
The slow response comes from the ftdi chip...

No idea how... but what if you have just 1 usb > ttl ic then multiplex the send/recv pins between a load of atmega328p's systematically programming one by one...

Or

1 ftdi/atmega16u2 chip, and some kind of clip/ extension drop the nano / clip it and hit start, unclip insert new one, repeat?
4  Community / Bar Sport / 60 capacitors? on: September 17, 2014, 10:24:32 am
See the attached photo...

This to me looks like a way of selling unused stock, anyone happen to know if there's any benefit to using this method ie 60 small caps vs several large capacitors instead? Except less soldering that is...
5  Using Arduino / General Electronics / Re: Lesson Learned on Vishay VO14624 Solid State Relay on: September 17, 2014, 09:23:27 am
If you can get inside it, replace the optocoupler?  Other than that there should be a triac unless it's a solid metal block.
6  Using Arduino / General Electronics / Re: Not all breadboards created equal on: September 17, 2014, 09:09:35 am
I just wiggle the wires if I find a loose connection,  the worsr board I had was the all milky white, binned.

I don't mind so much  because first chance I get I'll move it to perfboard or pcb it
7  Community / Bar Sport / Re: Strings or woodwinds? on: September 17, 2014, 09:02:49 am
Var
YourString: String;

YourString [1]:='A';

Now under pascal what determines the endpoint is the null char / #0

Exactly the same in C,  except it's no where near type casted as pascal but... Strings have always been strings if they consist of an array of characters, well before object oriented programming existed...

I hate all objective forms of variables.. eg  mystring.concat   (just wrong) including the 'string' class in Arduino, I bet the string object was there to help beginners no doubt but created more problems in the long term.

 
8  Community / Bar Sport / Re: How to start an argument on internet on: September 17, 2014, 08:53:21 am
We'd not have this problem if atmel decided to write a pascal compiler!

If (thevar=1) {}

Would simply not be allowed...

If (thevar:=1) begin end;

 is illegal syntax.

If (thevar=1 )

Valid syntax

But the masses have spoken and it seems we're stuck with c style syntax... java, php..
9  Community / Bar Sport / Re: Who hasn't accidentally touched a mains voltage once or twice? on: September 17, 2014, 08:44:52 am
Tom...... smiley
ps, all touches with the mains are accidental.

Electric Chair...
Suicide (sticking  metal objects into plug sockets)

And mental people climbing power poles.
10  Using Arduino / Programming Questions / Re: I HATE C!!!! - DaysBetween on: September 17, 2014, 07:26:36 am
Thank you.
11  Using Arduino / Programming Questions / Re: I HATE C!!!! - DaysBetween on: September 17, 2014, 05:09:32 am
Screw it, I'll start again regarding the countdown..

Anyone seen, come across code to simply get the number of seconds between two time stamps?
12  Using Arduino / Programming Questions / Re: I HATE C!!!! - DaysBetween on: September 17, 2014, 02:10:14 am
Segment of Code not working
Code:
void GetAndDrawTime()
{
   byte h,m,s, d;
   int y;
   char TimeStr[30];
 
//  DisplayCountDown();
 
  //This code below WAS in displayCountDown();
 
  long targetDate =secondsSince2000(targetYear, targetMonth, targetDay, targetHour, targetMinute, targetSecond);

  Serial.println(targetDate);
//  Serial.println(RTC.now);
 
  Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
  Serial.print(":");
  Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
  Serial.print(":");
  Serial.print(RTC.get(DS1307_SEC,false));//read seconds
  Serial.print(" ");                 // some space for a more happy life
  Serial.print(RTC.get(DS1307_DOW,false));
  Serial.print(" ");
  Serial.print(RTC.get(DS1307_DATE,false));//read date
  Serial.print("/");
  Serial.print(RTC.get(DS1307_MTH,false));//read month
  Serial.print("/");
  Serial.println(RTC.get(DS1307_YR,false)); //read


int year = RTC.get(DS1307_YR,false);
int month = RTC.get(DS1307_MTH,false);
if (century) year += 100;
int day = RTC.get(DS1307_DATE,false);
int hour = RTC.get(DS1307_HR,true);

if ((h24) && (ampm)) hour += 12;
int minute = RTC.get(DS1307_MIN,false);
int second = RTC.get(DS1307_SEC,false);

   //    Serial.println("year: "+year);
   //    Serial.println("month: "+month);
   //    Serial.println("day: "+day);
   //    Serial.println("hour: "+hour);
   //    Serial.println("minute: "+minute);
   //    Serial.println("second: "+second);

  Now = secondsSince2000(year, month, day, hour, minute, second);
 
   
// Are we past the countdown?
if (Now >= targetDate) {
//celebrate();
}

// Here's the time remaining.
dT = targetDate - Now;

// Figure out whole days remaining
int remDays = dT/SECONDSINDAY;

// Here's the leftover HMS
int remSeconds = dT%SECONDSINDAY;

// Figure out the whole hours remaining
int remHours = remSeconds/SECONDSINHOUR;

// Here's the leftover MS
// remSeconds = remSeconds%SECONDSINHOUR;

// Figure out the whole minutes remaining
// int remMinutes = remSeconds/SECONDSINMINUTE;

// Here's the leftover S
// remSeconds = remSeconds%SECONDSINMINUTE;


   sprintf(TimeStr,"%d days until Christmas!",remDays);
     
   Serial.println(TimeStr);

shakes head... pours a glass of wine.
13  Using Arduino / Programming Questions / I HATE C!!!! - DaysBetween on: September 17, 2014, 02:08:20 am
Code:
[quote]
#include <SPI.h>        //SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include <DMD.h>        //
#include <TimerOne.h>   //
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#include <Wire.h>
#include <DS1307.h>

//Fire up the DMD library as dmd
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
#define SECONDSINDAY 86400
#define SECONDSINHOUR 3600
#define SECONDSINMINUTE 60


// Put your target date here.
int targetYear = 14;
byte targetMonth = 12;
byte targetDay = 25;
byte targetHour = 0;
byte targetMinute = 0;
byte targetSecond = 0;



unsigned int monthdays[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};

bool century, h24, ampm;
unsigned long targetDate;
unsigned long Now, dT;



/*--------------------------------------------------------------------------------------
  Interrupt handler for Timer1 (TimerOne) driven DMD refresh scanning, this gets
  called at the period set in Timer1.initialize();
--------------------------------------------------------------------------------------*/
void ScanDMD()
{
  dmd.scanDisplayBySPI();
}





void setup(void)
{

   //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
   Timer1.initialize( 5000 );           //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
   Timer1.attachInterrupt( ScanDMD );   //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()
   Serial.begin(9600);

   //clear/init the DMD pixels held in RAM
   dmd.clearScreen( true );   //true is normal (all pixels off), false is negative (all pixels on)
 
}

int strLength(char *buffer){
  int i = 0, length =0;
  while (buffer != '\0'){  
    if (buffer[i+1] == '\0') {
    length = i+1;
    return length;
    }
    i++;
  }
}


void ScrollText()
{
     long start=millis();
   long timer=start;
   boolean ret=false;
   while(!ret){
     if ((timer+55) < millis()) {
       ret=dmd.stepMarquee(-1,0);
       timer=millis();
     }
   }

}

//code directly from a C snippet...

/* time_t timeFromDate( int year, int month, int day ) {
     time_t rawtime;
     struct tm * my_time;
  
     // Create a filled in time structure
     time( &rawtime );
     my_time = localtime( &rawtime );
      
     // Reassign our date
     my_time->tm_year     = year - 1900; // Different sources say 1900 and 1970?
     my_time->tm_mon        = month - 1;    // tm uses uses january + months [0..11]  
     my_time->tm_mday     = day;
  
     // Return it as seconds since epoch
     return( mktime( my_time ) );
 } */
  

unsigned long secondsSince2000(unsigned long year, byte month, byte day, byte hour, byte minute, byte second)
{
// This code stolen from someene else's DS1337 library. It was called
// "date_to_epoch_seconds()" there, but it didn't do epoch seconds,
// just seconds since 2000. That's fine in this case, since seconds
// since 2000 is sufficient for this purpose.
  unsigned long sse = (((unsigned long)year)*365*24*60*60)   +   ((((unsigned long)year+3)>>2) + ((unsigned long)year%4==0 && (unsigned long)month>2))*24*60*60   +   \
         ((unsigned long)monthdays[month-1] + (unsigned long)day-1) *24*60*60   +   ((unsigned long)hour*60*60)   +   ((unsigned long)minute*60)   + (unsigned long)second;

  return sse;
}


void GetAndDrawTime()
{
   byte h,m,s, d;
   int y;
   char TimeStr[30];
 
//  DisplayCountDown();
  
  //This code below WAS in displayCountDown();
  
  long targetDate =secondsSince2000(targetYear, targetMonth, targetDay, targetHour, targetMinute, targetSecond);

  Serial.println(targetDate);
//  Serial.println(RTC.now);
  
  Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
  Serial.print(":");
  Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
  Serial.print(":");
  Serial.print(RTC.get(DS1307_SEC,false));//read seconds
  Serial.print(" ");                 // some space for a more happy life
  Serial.print(RTC.get(DS1307_DOW,false));
  Serial.print(" ");
  Serial.print(RTC.get(DS1307_DATE,false));//read date
  Serial.print("/");
  Serial.print(RTC.get(DS1307_MTH,false));//read month
  Serial.print("/");
  Serial.println(RTC.get(DS1307_YR,false)); //read


int year = RTC.get(DS1307_YR,false);
int month = RTC.get(DS1307_MTH,false);
if (century) year += 100;
int day = RTC.get(DS1307_DATE,false);
int hour = RTC.get(DS1307_HR,true);

if ((h24) && (ampm)) hour += 12;
int minute = RTC.get(DS1307_MIN,false);
int second = RTC.get(DS1307_SEC,false);

   //    Serial.println("year: "+year);
   //    Serial.println("month: "+month);
   //    Serial.println("day: "+day);
   //    Serial.println("hour: "+hour);
   //    Serial.println("minute: "+minute);
   //    Serial.println("second: "+second);

  Now = secondsSince2000(year, month, day, hour, minute, second);
 
    
// Are we past the countdown?
if (Now >= targetDate) {
//celebrate();
}

// Here's the time remaining.
dT = targetDate - Now;

// Figure out whole days remaining
int remDays = dT/SECONDSINDAY;

// Here's the leftover HMS
int remSeconds = dT%SECONDSINDAY;

// Figure out the whole hours remaining
int remHours = remSeconds/SECONDSINHOUR;

// Here's the leftover MS
// remSeconds = remSeconds%SECONDSINHOUR;

// Figure out the whole minutes remaining
// int remMinutes = remSeconds/SECONDSINMINUTE;

// Here's the leftover S
// remSeconds = remSeconds%SECONDSINMINUTE;


   sprintf(TimeStr,"%d days until Christmas!",remDays);
      
   Serial.println(TimeStr);

   dmd.clearScreen( true );
   dmd.drawMarquee(TimeStr,strLength(TimeStr),(32*DISPLAYS_ACROSS)-1,0);      


   boolean ret=false;
   long timer = 0;
   while(!ret){
     if ((timer+95) < millis()) {
       ret=dmd.stepMarquee(-1,0);
       timer=millis();
     }
   }
  
  dmd.clearScreen( true );
  
  
  
   h = RTC.get(DS1307_HR,true);
   m = RTC.get(DS1307_MIN,true);
   s = RTC.get(DS1307_SEC,true);
   if (h>=12)
      sprintf(TimeStr,"Time: %d:%dpm",h,m);
       else
      sprintf(TimeStr,"Time: %d:%dam",h,m);
      
   Serial.println(TimeStr);
   dmd.clearScreen( true );
  
    
   dmd.drawMarquee(TimeStr,strLength(TimeStr),(32*DISPLAYS_ACROSS)-1,0);      
   long start=millis();
   timer=start;
   ret=false;
   while(!ret){
     if ((timer+95) < millis()) {
       ret=dmd.stepMarquee(-1,0);
       timer=millis();
     }
   }
  
  dmd.clearScreen( true );
  Serial.println(TimeStr);


    d = RTC.get(DS1307_DATE,true);
    m = RTC.get(DS1307_MTH,true);
    y = RTC.get(DS1307_YR,true);

    sprintf(TimeStr,"Date: %d/%d/%d",d,m,y);
      
   Serial.println(TimeStr);

   dmd.clearScreen( true );
   dmd.drawMarquee(TimeStr,strLength(TimeStr),(32*DISPLAYS_ACROSS)-1,0);      


   ret=false;
   while(!ret){
     if ((timer+95) < millis()) {
       ret=dmd.stepMarquee(-1,0);
       timer=millis();
     }
   }
  
  dmd.clearScreen( true );

  
 

}





void prettystuff()
{
//     half the pixels on
   dmd.drawTestPattern( PATTERN_ALT_0 );
   delay( 1000 );

   // the other half on
   dmd.drawTestPattern( PATTERN_ALT_1 );
   delay( 1000 );
 
}

void loop(void)
{
   byte b;
  
   // 10 x 14 font clock, including demo of OR and NOR modes for pixels so that the flashing colon can be overlayed
   dmd.clearScreen( true );
   dmd.selectFont(Arial_Black_16);

   GetAndDrawTime();
/*  Serial.print("\nActual time : ")
 Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true//
 Serial.print(":");
 Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
 Serial.print(":");
 Serial.print(RTC.get(DS1307_SEC,false));//read seconds
 Serial.print(" ");                 // some space for a more happy life
 Serial.print(RTC.get(DS1307_DOW,false));
 Serial.print(" ");
 Serial.print(RTC.get(DS1307_DATE,false));//read date
 Serial.print("/");
 Serial.print(RTC.get(DS1307_MTH,false));//read month
 Serial.print("/");
 Serial.println(RTC.get(DS1307_YR,false)); //read year
*/
 
}

here's the Serial Debug Dump...

Quote
472780800
16:32:40 4 17/9/2014
15252 days until Christmas!
Time: 16:33pm
Time: 16:33pm
Date: 17/9/2014
472780800
16:33:37 4 17/9/2014
15252 days until Christmas!


it's more like 98 days to Christmas....  I also don't really understand why the code i stole calculates the date from 2000, surely the date and time stamp NOW - EncodedDate(Christmas) = Seconds between/days/hours etc... why is calculating the date from 2000 required?

link

http://physics.csuchico.edu/~eayars/code/countdown.pde.html


Anyone know how to simply Encode the time stamp as of NOW (Time now)  deduct from CalculatedTimeStamp? (future Date) thanks!
14  Using Arduino / Motors, Mechanics, and Power / Re: Question from a really new Newbie :) on: September 16, 2014, 07:02:48 pm
If you have a flyback diode to protect the arduino and the motor will /not/ consume more than 40ma then yeah you could....

Those tiny motors in phones consume how much power?
15  Using Arduino / LEDs and Multiplexing / Re: Using pots to control rgb values of an rgb strip? on: September 16, 2014, 05:51:48 pm
Pot's are adjustable resistors sorta...

But what's important to remember here is watts, an led of 20ma(0.020x12v) vs a strip of of leds consuming 2000ma (2000x12v).

That's 0.24watts vs 24watts.  (Do you have a 25watt capable potentiometer? )  1 led requires little current.
Pages: [1] 2 3 ... 187