Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Tick Tock Still Hacking Away At My Binary Clock on: January 30, 2013, 03:03:31 pm
Thanks again PaulS for putting up with my learner questions, only at the start of my learning but im sure i will get there (im half way through my first tutorial book). As for my Clock it is now taking good time from the RTC and working as desired, Your a star buddy.

Cheers Again.
2  Using Arduino / Programming Questions / Re: Tick Tock Still Hacking Away At My Binary Clock on: January 30, 2013, 02:45:58 pm
Im down to my last problem.

round_Clock_v1_4.ino: In function 'void setOutput(int*, int, int)':
round_Clock_v1_4:83: error: invalid conversion from 'int*' to 'uint8_t'
round_Clock_v1_4:83: error: initializing argument 1 of 'void digitalWrite(uint8_t, uint8_t)'

I dont really understand what its trying to say by "invalid conversion"? on this part of the code

Code:
void setOutput(int *ledArray, int numLEDs, int value)
{
    for (int i = 0; i < numLEDs; i++)
    {
     digitalWrite(ledArray, bitRead(value, i));
    }
3  Using Arduino / Programming Questions / Re: Tick Tock Still Hacking Away At My Binary Clock on: January 30, 2013, 01:52:52 pm
Look at the pinMode statements in setup() in the old code and the new code:
old:      pinMode(hourLEDs[i], OUTPUT);
new:     pinMode(hourLEDs, OUTPUT);

I have Been a prize plum, thanks for pointing out the obvious! Too long looking at the same thing over and over.

I will try go through the rest of my errors, Thanks PaulS
4  Using Arduino / Programming Questions / Re: Tick Tock Still Hacking Away At My Binary Clock on: January 30, 2013, 01:35:38 pm
Thanks for the fast replies, this was my original code before adding in the RTC part of it and it compile just fine, now i know that means what ever im adding is the problem but im not sure where the conflict is as this works fine without the RTC code and the time is displayed.

Code:
// binary clock code V1.2

#include <Time.h>

int hourLEDs[] = {1, 2, 3, 4}; // Hours LED (Digital Pin 1-4)
int minuteLEDs[] = {10, 9, 8, 7, 6, 5}; // Minutes Led (Digital Pin 10-5)
int secondLEDs[] = {16, 15, 14, 13, 12, 11}; // Seconds Led (Digital Pin 12-11 Analog Pin 2-0)

int loopLEDs[] = {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; // Spin Led In this order

int switchPin = 17 ; // Used for setting time, hold to advance. (to be used for interupt once RTC is avalible)

void setup()       
{
  for (int i = 0; i < 4; i++)
  {
     pinMode(hourLEDs[i], OUTPUT);
  }
  for (int i = 0; i < 6; i++)
  {
     pinMode(minuteLEDs[i], OUTPUT);
  }
  for (int i = 0; i < 6; i++)
  {
     pinMode(secondLEDs[i], OUTPUT);
  }
  setTime(0);
}

void loop()                     
{
  if (digitalRead(switchPin))
  {
     adjustTime(1);
  }
  else if (minute() == 0 && second() == 0)
  {
    spin(hour());
  }
  updateDisplay();
  delay(1);
}

void updateDisplay()
{
  time_t t = now();
  setOutput(hourLEDs, 4, hourFormat12(t));
  setOutput(minuteLEDs, 6, minute(t));
  setOutput(secondLEDs, 6, second(t));
}


void setOutput(int *ledArray, int numLEDs, int value)
{
    for (int i = 0; i < numLEDs; i++)
    {
     digitalWrite(ledArray[i], bitRead(value, i));
    }
}


void spin(int count)
{
  for (int i = 0; i < count; i++)
  {
      for (int j = 0; j < 16; j++)
      {
         digitalWrite(loopLEDs[j], HIGH);
         delay(50);
         digitalWrite(loopLEDs[j], LOW);
      }
  }
}
5  Using Arduino / Programming Questions / [SOLVED many thanks] Tick Tock Still Hacking Away At My Binary Clock on: January 30, 2013, 01:20:52 pm
Ok so i took a bit of a break from my project over christmas and thought i better finish it off but im having a bit of problem with some programming strangely enough being in the programming section!

I have used some code found on the forum to include my RTC clock DS3231, (not DS1307 as stated in my code but they work the same) the problem is im getting some "invalid conversion from 'int*' to 'uint8_t'" errors and wondered if someone could point me in the right direction? Many thanks

Code:
// Lilypad binary clock - Set using RTC


#include <Time.h>  
#include <Wire.h>  
#include <DS1307RTC.h>  // a basic DS1307 library that returns time as a time_t


int hourLEDs[] = {1, 2, 3, 4}; // Hours LED (Digital Pin 1-4)
int minuteLEDs[] = {10, 9, 8, 7, 6, 5}; // Minutes Led (Digital Pin 10-5)
int secondLEDs[] = {16, 15, 14, 13, 12, 11}; // Seconds Led (Digital Pin 12-11 Analog Pin 2-0)

int loopLEDs[] = {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; // Spin Led In this order

int switchPin = 17 ; // Used for setting time, hold to advance. (to be used for interupt once RTC is avalible)

void setup()      
{
  for (int i = 0; i < 4; i++)
  {
     pinMode(hourLEDs, OUTPUT);
  }
  for (int i = 0; i < 6; i++)
  {
     pinMode(minuteLEDs, OUTPUT);
  }
  for (int i = 0; i < 6; i++)
  {
     pinMode(secondLEDs, OUTPUT);
  }
  time_t t = now();
  setSyncProvider(RTC.get);   // the function to get the time from the RTC
  Serial.begin(9600);

  
}

void loop()                    
{
  if (digitalRead(switchPin))
  {
    adjustTime(60-second());  // Move the clock forward to the next minute    
    RTC.set(now());  // Set the RTC to the new time
  }
  else if (minute() == 0 && second() == 0)
  {
    spin(hour());
  }
  updateDisplay();
  delay(1);
  
}

void updateDisplay()
{
  
  setSyncProvider(RTC.get);
  time_t t = now();
  setOutput(hourLEDs, 4, hourFormat12(t));
  setOutput(minuteLEDs, 6, minute(t));
  setOutput(secondLEDs, 6, second(t));
  
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.println();
}


void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  Serial.print(":");
  if(digits < 10)
  Serial.print('0');
  Serial.print(digits);
}


void setOutput(int *ledArray, int numLEDs, int value)
{
    for (int i = 0; i < numLEDs; i++)
    {
     digitalWrite(ledArray, bitRead(value, i));
    }
  
}


void spin(int count)
{
  for (int i = 0; i < count; i++)
  {
      for (int j = 0; j < 16; j++)
      {
         digitalWrite(loopLEDs[j], HIGH);
         delay(50);
         digitalWrite(loopLEDs[j], LOW);
      }
  }
}

Errors


round_Clock_v1_4.ino: In function 'void setup()':
round_Clock_v1_4:21: error: invalid conversion from 'int*' to 'uint8_t'
round_Clock_v1_4:21: error: initializing argument 1 of 'void pinMode(uint8_t, uint8_t)'
round_Clock_v1_4:25: error: invalid conversion from 'int*' to 'uint8_t'
round_Clock_v1_4:25: error: initializing argument 1 of 'void pinMode(uint8_t, uint8_t)'
round_Clock_v1_4:29: error: invalid conversion from 'int*' to 'uint8_t'
round_Clock_v1_4:29: error: initializing argument 1 of 'void pinMode(uint8_t, uint8_t)'
round_Clock_v1_4:32: error: 'RTC' was not declared in this scope
round_Clock_v1_4.ino: In function 'void loop()':
round_Clock_v1_4:43: error: 'RTC' was not declared in this scope
round_Clock_v1_4.ino: In function 'void updateDisplay()':
round_Clock_v1_4:57: error: 'RTC' was not declared in this scope
round_Clock_v1_4.ino: In function 'void setOutput(int*, int, int)':
round_Clock_v1_4:83: error: invalid conversion from 'int*' to 'uint8_t'
round_Clock_v1_4:83: error: initializing argument 1 of 'void digitalWrite(uint8_t, uint8_t)'
6  Using Arduino / Programming Questions / Re: Tick Tock Another Binary Clock on: January 06, 2013, 01:53:05 pm
Great i will have a go with ether method one or two and see how it plays out. Thanks again for your help tom, hope i can get this all togethere and running this is my 3-4th project now and would like to get it portable and battery powered maybe so thats the next step after getting this section of it working and i think you have set me in the right direction.

Cheers
7  Using Arduino / Programming Questions / Re: Tick Tock Another Binary Clock on: January 06, 2013, 11:46:23 am
Cheers Tom for the quick reply and fast response i have a RTC on order now and going to give the sleep on Digital pin 0 a go later tonight. is it just a matter of pulling the pin to GND or do i need to do a bit more research and reading on how to wire up an interrupter on a digital pin?

Thanks again
8  Using Arduino / Programming Questions / Re: Tick Tock Another Binary Clock on: January 06, 2013, 08:52:00 am
Now my problem is with the best way to go about this with out using 'if' statements too much and slowing the clock down and losing time.
The time library keeps track of the time using an interrupt.  Your code will have very little impact on it losing track of time.   You might miss updating the seconds display by a few hundred miliseconds, but us slow humans won't notice.

The most power efficient and accurate way to keep track of time is to use a RTC like the DS1307 or DS3231 (more expensive but much more accurate).  That way you can put your 328 to sleep and wake it up every so often.

Using delay() does not save you any power.


Thanks for your quick reply, im looking into the RTC method and putting the 328 to sleep my only problem now is i only have Digital pin 0 (RX) Free after using the last to analog inputs 4-5 for the RTC. Would i be able to make an interrupt to wake with this pin or by moving others around? any suggestions welcome?
9  Using Arduino / Programming Questions / Tick Tock Another Binary Clock on: January 05, 2013, 01:03:52 pm
Hello world. Right i have been slowly teaching my self through different projects and have hit a bit of a mental break down on the best way to achieve what i want from my project.

I am building a Binary clock using an atmega328p on a breadboard for now, then the hope is to move it forward to a full working pocket watch once i am happy with the prototype.

*Now the problem is power consumption of the LEDS and the watch lasting for a reasonable time.*

I Know this can be done by making the 328 carry on counting time but to switch off the LEDS say 30 seconds after a switch is activated like a push button or when i open the watch case.

Now my problem is with the best way to go about this with out using 'if' statements too much and slowing the clock down and losing time.

This is the code so far.... and any suggestions would be more than appreciated in solving my problem and even if code is the right way to do this and if not maybe a better hardware solution is out there?

Code:
// CSM
// binary clock code V1.2, on atmega328p-pu breadboard.

#include <Time.h> // Using the basic Time library

int hourLEDs[] = {1, 2, 3, 4}; // Hours LED 
int minuteLEDs[] = {10, 9, 8, 7, 6, 5}; // Minutes LED
int secondLEDs[] = {16, 15, 14, 13, 12, 11}; // Seconds LED

int loopLEDs[] = {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; // The order in which to spin the LEDS

int switchPin = 17 ; // Used for setting the time, hold to advance time

void setup()       
{
  for (int i = 0; i < 4; i++)
  {
     pinMode(hourLEDs[i], OUTPUT);
  }
  for (int i = 0; i < 6; i++)
  {
     pinMode(minuteLEDs[i], OUTPUT);
  }
  for (int i = 0; i < 6; i++)
  {
     pinMode(secondLEDs[i], OUTPUT);
  }
  setTime(0);
}

void loop()                     
{
  if (digitalRead(switchPin))
  {
     adjustTime(1);
  }
  else if (minute() == 0 && second() == 0)
  {
    spin(hour());
  }
  updateDisplay();
  delay(1);
}

void updateDisplay()
{
  time_t t = now();
  setOutput(hourLEDs, 4, hourFormat12(t));
  setOutput(minuteLEDs, 6, minute(t));
  setOutput(secondLEDs, 6, second(t));
}


void setOutput(int *ledArray, int numLEDs, int value)
{
    for (int i = 0; i < numLEDs; i++)
    {
     digitalWrite(ledArray[i], bitRead(value, i));
    }
}


void spin(int count)
{
  for (int i = 0; i < count; i++)
  {
      for (int j = 0; j < 16; j++)
      {
         digitalWrite(loopLEDs[j], HIGH);
         delay(50);
         digitalWrite(loopLEDs[j], LOW);
      }
  }
}








Many Thanks
10  Using Arduino / LEDs and Multiplexing / Re: 8x8 Matrix, only half the LED's at full brightness on: July 05, 2012, 08:08:57 am
One common cause for very dim outputs is failing to call pinMode(pin, OUTPUT), so you only get the weak internal pullups sourcing current.
Cheers I will check that out, like I said new to it but learning through trial and error and laughing at my stupidity all the way

Video off my problem


11  Using Arduino / LEDs and Multiplexing / 8x8 Matrix, only half the LED's at full brightness on: July 04, 2012, 12:52:19 pm
Ok so I’m new to this so please go easy on me. This is my 4-5 project with my new Arduino Mega2560 board and I’m following a tutorial from http://oomlout.com/8X8M/8X8M-Guide.pdf.
ok so i have built the breadboard up as described and double checked all my connections twice now.

THE PROBLEM.
So i have uploaded the sketch from http://tinyurl.com/yjozkrr to my board at that went through with zero problems but my 8x8 matrix is only lit on the bottom 4 rows as if you were looking from above. The top 4 rows are lit but very dim. Now these rows are connected to PWM pins 13-8 so i tested these with a simple blink LED test and they light the LED to 100% brightness???? so i tried the Knight Rider array from the examples and this works fine on PWM pins 7-2 but if i move and alter the sketch for PWM 13-8 i get dim led's.

Am i doing something really stupid here or am I just not understand the board and the sketch??

All Help given will be appreciated.
Many thanks!!
Pages: [1]