Go Down

Topic: [SOLVED many thanks] Tick Tock Still Hacking Away At My Binary Clock (Read 820 times) previous topic - next topic

monsteryeti

Jan 30, 2013, 07:20 pm Last Edit: Jan 30, 2013, 09:24 pm by monsteryeti Reason: 1
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: [Select]
// 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)'
Help Help Help

AWOL

Code: [Select]
pinMode(hourLEDs, OUTPUT);
No subscript for array.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

PaulS

Code: [Select]
     pinMode(hourLEDs, OUTPUT);
You can't initialize a whole array of pins at once. Doing so in a loop wouldn't make sense, if you could. You are missing the [ and ] and the index value.

monsteryeti

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: [Select]
// 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);
      }
  }
}
Help Help Help

PaulS

Look at the pinMode statements in setup() in the old code and the new code:
old:      pinMode(hourLEDs[i], OUTPUT);
new:     pinMode(hourLEDs, OUTPUT);

Go Up