0

Code this please. I'm lost.
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Code this please. I'm lost.

by philosocrates on Mon Nov 13, 2017 2:12 am

I am very new at this and am looking for anyone who wouldn't mind coding the animation linked below. I have 5v Trinket and Trinket pro with RGB Neopixel strip. So far I am able to turn on and off a light or 2 and that is where my coding knowledge is right now. (literally just started)

I have found lots of cut and paste code, but nothing like this. Any takers?

https://youtu.be/f8wpjmtjmFM

philosocrates
 
Posts: 6
Joined: Sun Nov 12, 2017 7:30 pm

Re: Code this please. I'm lost.

by adafruit_support_mike on Mon Nov 13, 2017 5:31 am

We don't do that here, for lots of reasons. First, there are way too many people in the world willing to exploit a free, on-demand software development service.

Second, asking someone else to do unpaid work almost always leads to an ugly situation. The person getting free code tends to fall into a pattern of saying, "okay, now make it do this" without ever learning whether that's easy or hard.. the thing they learn is to give orders and expect someone else to make it happen.

We're here to help people learn to be Makers, not 'big picture' middle-management.

We'll be happy to help you learn to write the code for yourself, and can break it down into pieces that won't overwhelm you. That offer operates on a 'show your work' basis though.

If you're interested, the first step is to light a single LED. The function to do that is .setPixelColor(), and you can find an example of how to set things up in the 'simple' example that comes with the NeoPixel library:

https://github.com/adafruit/Adafruit_Ne ... simple.ino

Look it over, and post back with any questions you have about the existing code.

adafruit_support_mike
 
Posts: 45198
Joined: Thu Feb 11, 2010 2:51 pm

Re: Code this please. I'm lost.

by philosocrates on Tue Nov 14, 2017 12:51 pm

Will do. Is there an explanation of the code anywhere? For example if I want an explanation of what "Void Setup()" does. Please don't get me wrong. I want to learn and usually do things by myself, but I feel like I was blindly cutting and pasting and changing values to see what happened with no real understanding of why.

philosocrates
 
Posts: 6
Joined: Sun Nov 12, 2017 7:30 pm

Re: Code this please. I'm lost.

by jerryn on Tue Nov 14, 2017 1:05 pm

It sounds like you are very new to the Arduino environment. this may be a good place to start:
https://www.arduino.cc/en/Tutorial/Sketch

jerryn
 
Posts: 438
Joined: Sat Sep 14, 2013 9:05 am

Re: Code this please. I'm lost.

by philosocrates on Tue Nov 14, 2017 3:32 pm

jerryn wrote:It sounds like you are very new to the Arduino environment. this may be a good place to start:
https://www.arduino.cc/en/Tutorial/Sketch



Thanks!

philosocrates
 
Posts: 6
Joined: Sun Nov 12, 2017 7:30 pm

Re: Code this please. I'm lost.

by adafruit_support_mike on Wed Nov 15, 2017 2:33 am

philosocrates wrote:Will do. Is there an explanation of the code anywhere? For example if I want an explanation of what "Void Setup()" does.

That's an excellent question.

In the programming language C, 'void' is term for 'no data'.

As far as the C compiler is concerned, functions have three important parts: their name, the data you send into them, and the data that comes out of them. With that information, you can make pieces that plug together kind of like Legos.. "put these pieces of data here, use this name to do something, then look here for an output value". When you write code, those pieces of information get arranged like so:

Code: Select all | TOGGLE FULL SIZE
    output_data function_name( input_data )
If you wanted to write a function named 'foo' that takes two integers as input and returns an integer as output, you'd tell that to the compiler like this:

Code: Select all | TOGGLE FULL SIZE
    int foo( int a, int b )
To tell the compiler a function doesn't return data at all, you use void:

Code: Select all | TOGGLE FULL SIZE
    void no_return_value( int a, int b )
You can also use void to say the function doesn't take any input:

Code: Select all | TOGGLE FULL SIZE
    int no_input( void )
but the compiler also understands empy paretheses to mean 'no input':

Code: Select all | TOGGLE FULL SIZE
    int no_input()
Every program has to start somewhere, and in C that place is a function named main(). The Arduino environment actually defines the main() function behind the scenes, and the code looks something like this:

Code: Select all | TOGGLE FULL SIZE
    int main () {
        setup();    //  do user-defined setup
       
        while ( 1 ) {   //  loop forever
            loop();
        }
    }
The microcontroller will execute your setup() function once, as soon as the power is connected, then will run the loop() function over and over until you disconnect power.

Those functions are where you put your own code to make it work in the Arduino environment.

adafruit_support_mike
 
Posts: 45198
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.