You can not return more than one value from a function.
To affect multiple variables pas in to the function a pointer to the variables and work on that. When you return the variables will have the new value. You can also return a pointer to ann array.
I guess I should work on how I make the functions and multiple call them.
So when I "get_time" it returns hour, minute, second.
Although the RTC library "returns" time in now.hours() now.minutes() and now.seconds().
So I would have to make my block read a variable to determine if it is Hrs, Mns, or Secs to return.
Thanks. I'll keep working on it.
Probably go with global variables for now.
(Alas this may have other problems with other codes too.)
/*
This is my sketch for a NEO PIXEL ring LED clock.
*/
// Includes below:
#include <Wire.h>
#include <stdio.h>
#include <Adafruit_NeoPixel.h>
#include <RTClib.h>
int rtc[7];
RTC_DS1307 RTC; // Create RTC object
// Define things here and set things up.
# define Loop 60
#define PIN 6 // This is defining which Arduino pin is driving the Pixel ring
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(Loop, PIN, NEO_GRB + NEO_KHZ800);
// Now you do the initial setup of things here.
//
//
// Need work. It is 24 bit colours. RGB (So "int" is not really correct)
int HR_Colour = 0x055550;
int MN_Colour = 0x550000;
int SE_Colour = 0x000055;
void setup()
{
// put your setup code here, to run once:
delay(2000); // This is just to give you time to open the window and watch.
Serial.begin(9600);
Serial.println("-------------------------------");
Serial.println("Setting up");
Wire.begin();
strip.begin();
strip.show(); // Initialize all pixels to 'off'
int LED[Loop];
Serial.begin(9600);
Serial.println("Setting up");
Serial.println("Done setting up");
Serial.println("-------------------------------");
}
void loop()
{
// put your main code here, to run repeatedly:
//
// Get time
DateTime now = RTC.now();
int hr = now.hour();
int mins = now.minute();
int second_led = now.second();
//
// calculate leds
int hour_led = ((Loop/12) * hr) + (6 * (Loop/mins));
int minute_led = mins;
//
// Show LEDs
strip.setPixelColor(hour_led,HR_Colour);
strip.setPixelColor(minute_led,MN_Colour);
strip.setPixelColor(second_led,SE_Colour);
strip.show();
//
// show alarms
//
}
//==================================================================
//==================================================================
//
// end of code
//
//==================================================================
What is that line supposed to do?
It seems to create an array within setup() that is never used.
Maybe it should come before setup() ?
Loop is a very confusing (I'm being polite) name for a value in a programming environment where loop() is such an important part.
...R
Granted it is confusing.
It was broken down more when I had separate blocks. Alas only being able to send/return ONE variable kind of killed that.
LED[Loop] sets up ...... Ah. I see what you mean.
That was used when I had separate blocks..... Deja vous.
Why do you say it is not right to put it in SETUP?
Granted it could go BEFORE, but why is it a problem where it is - apart from the fact it isn't used?
AWOL,
Not exactly sure which part you mean, but isn't that what was done with the hour_led, minute_led and second_led?
lost_and_confused:
Why do you say it is not right to put it in SETUP?
Granted it could go BEFORE, but why is it a problem where it is - apart from the fact it isn't used?
Because it was not used in setup() I had assumed it was intended to be a global variable rather than a local variable within setup().