Kaleidoscope Eyes - some simple code

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
DomMorley
 
Posts: 7
Joined: Mon Nov 24, 2014 10:54 am

Kaleidoscope Eyes - some simple code

Post by DomMorley »

Hello - I've recently bought and built this project (https://learn.adafruit.com/kaleidoscope ... a/overview) and it's all working and really great. The thing is, I need it for a specific thing, and I just want the lights to be white, and on all the time. I've tried to decipher the code of it all (using examples I've found on various sites), but I think I'm better with a soldering iron than with coding! If anyone has the simple code to just make these rings shine white all the time - or can point me to where it can be found - it would be deeply appreciated.

Thanks!

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Kaleidoscope Eyes - some simple code

Post by adafruit_support_bill »

just make these rings shine white all the time
Replace your loop() function with the following:

Code: Select all

void loop()
{
  for (int i = 0; i < 32; i++)
  {
     setPixelColor(i, 100, 100, 100);
  }
}
To make it brighter, use higher numbers (up to 255).
To make it dimmer, use smaller numbers.

User avatar
DomMorley
 
Posts: 7
Joined: Mon Nov 24, 2014 10:54 am

Re: Kaleidoscope Eyes - some simple code

Post by DomMorley »

Wow - that was fast!

Thank you so much. I'll try that tonight!


Dom

User avatar
DomMorley
 
Posts: 7
Joined: Mon Nov 24, 2014 10:54 am

Re: Kaleidoscope Eyes - some simple code

Post by DomMorley »

OK, so I've hacked it onto some previously working code I have, ending up in this:

Code: Select all

#include <Adafruit_NeoPixel.h>
 
#define PIN 0
 
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(32, PIN);
 
uint8_t  mode   = 0, // Current animation effect
         offset = 0; // Position of spinny eyes
uint32_t color  = 0x000000; // Start red
uint32_t prevTime;
 
void setup() {
  pixels.begin();
  pixels.setBrightness(85); // 1/3 brightness
  prevTime = millis();
}
 
void loop()
{
  for (int i = 0; i < 32; i++)
  {
     setPixelColor(i, 100, 100, 100);
  }
}
   
but now I get the error:
error: 'setPixelColor' was not declared in this scope
Did I mention that I'm a noob! ;-)

Any ideas what's going wrong there?

Thanks again.
Last edited by Franklin97355 on Mon Nov 24, 2014 1:10 pm, edited 1 time in total.
Reason: Please use [code] tags when posting code they look like </> above the reply window

User avatar
Franklin97355
 
Posts: 23912
Joined: Mon Apr 21, 2008 2:33 pm

Re: Kaleidoscope Eyes - some simple code

Post by Franklin97355 »

That line should read pixels.setPixelColor(i, 100, 100, 100);

User avatar
DomMorley
 
Posts: 7
Joined: Mon Nov 24, 2014 10:54 am

Re: Kaleidoscope Eyes - some simple code

Post by DomMorley »

That's much happier (no errors) although I've found it just has the effect of pausing the previous programming as opposed to re-setting it and turning it all white.

The spinning rainbows have now stopped going round and are stationary, so it's obviously having some controlling effect, just not doing the 'all just white' thing I was hoping for :-(

Sorry if I'm being a pain!

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Kaleidoscope Eyes - some simple code

Post by adafruit_support_bill »

I've found it just has the effect of pausing the previous programming as opposed to re-setting it and turning it all white.
You have to completely replace your loop() function with the one I posted (plus Franklin's correction)

User avatar
DomMorley
 
Posts: 7
Joined: Mon Nov 24, 2014 10:54 am

Re: Kaleidoscope Eyes - some simple code

Post by DomMorley »

Ah - sorry. I thought I had! I replaced everything after void loop() with what you said, and I've just tried erasing all manner of combinations as it's clear there's more to the loop() function than I thought. I either make it go to error or it has no effect though. It's painful being a noob :-(

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Kaleidoscope Eyes - some simple code

Post by adafruit_support_bill »

The loop function is everything from "void loop()" to the end of the file.

This should do what you want.

Code: Select all

// Low power NeoPixel goggles example.  Makes a nice blinky display
// with just a few LEDs on at any time.

#include <Adafruit_NeoPixel.h>
#ifdef __AVR_ATtiny85__ // Trinket, Gemma, etc.
 #include <avr/power.h>
#endif

#define PIN 0

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(32, PIN);

uint8_t  mode   = 0, // Current animation effect
         offset = 0; // Position of spinny eyes
uint32_t color  = 0xFF0000; // Start red
uint32_t prevTime;

void setup() {
#ifdef __AVR_ATtiny85__ // Trinket, Gemma, etc.
  if(F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
  pixels.begin();
  pixels.setBrightness(85); // 1/3 brightness
  prevTime = millis();
}
 
void loop()
{
  for (int i = 0; i < 32; i++)
  {
     pixels.setPixelColor(i, 100, 100, 100);
  }
}
   

User avatar
DomMorley
 
Posts: 7
Joined: Mon Nov 24, 2014 10:54 am

Re: Kaleidoscope Eyes - some simple code

Post by DomMorley »

Thanks so much for your effort here - truly appreciated.

I fear there must be something more fundamental wrong with my unit though, as this still doesn't work. In fact, if I load this code when I turn it on, it doesn't do anything at all. I have to load another bit of code (I have a flashy rainbow one that works), and then load this one to get it to do something. And then it just pauses the flashing and moving of the coloured lights from the rainbow display. Nothing white and a couple of the LEDs out (as per the movement of the previous code). Perhaps I have a dodgy Trinket or something?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Kaleidoscope Eyes - some simple code

Post by adafruit_support_bill »

Sorry, I forgot a line. Try this one:

Code: Select all

// Low power NeoPixel goggles example.  Makes a nice blinky display
// with just a few LEDs on at any time.

#include <Adafruit_NeoPixel.h>
#ifdef __AVR_ATtiny85__ // Trinket, Gemma, etc.
 #include <avr/power.h>
#endif

#define PIN 0

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(32, PIN);

uint8_t  mode   = 0, // Current animation effect
         offset = 0; // Position of spinny eyes
uint32_t color  = 0xFF0000; // Start red
uint32_t prevTime;

void setup() {
#ifdef __AVR_ATtiny85__ // Trinket, Gemma, etc.
  if(F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
  pixels.begin();
  pixels.setBrightness(85); // 1/3 brightness
  prevTime = millis();
}
 
void loop()
{
  for (int i = 0; i < 32; i++)
  {
     pixels.setPixelColor(i, 100, 100, 100);
  }
  pixels.show();
}
   

User avatar
DomMorley
 
Posts: 7
Joined: Mon Nov 24, 2014 10:54 am

Re: Kaleidoscope Eyes - some simple code

Post by DomMorley »

EUREKA!!!!

FANTASTIC - thank you so much. You have no idea the hours I've spent trawling the web until I got onto this forum, just trying to learn enough code to make this happen.

Thank you very, very much.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”