Hi, newbie here :-) Can anyone advise or point me to the basic format

Hi, newbie here :slight_smile:

Can anyone advise or point me to the basic format for using the sin, cos, triwave functions? The fastled wiki mentions them but gives no examples, and elsewhere I can only find heinously complex examples that I don’t understand. As a newbie I want to feed simple numbers into them and serialprint them out so I can see what they’re doing. Ideally make them count up to 255 and back again in their various ways…

I get the impression angles are involved. So I’m doing this:
mysine = sin8(x)
and changing the x to different values and serial printing it, and getting cryptic stuff back. When x is 180 mysine is 9, when x is 0 mysine is 128, when x is 90 mysine is 228…?!?

There’s a pattern here somewhere… :slight_smile:

Cheers!

Just look through this doc…

basically a simplified but faster version of the sin() function.

x should be between 0-255 and the output, mysine in your case will also vary from 0-255.

Just go through the whole range of x = 0 to 255 and you will see the pattern clearly.

Aha ok - here’s my sin8 output from an i input variable counting from 0-255. Cool! Will try the others.
missing/deleted image from Google+

Any other puzzled newbie interested, the script here is:

#include <FastLED.h>

byte mysine; //a byte type variable is 8 bits, 0-255.

void setup() {
Serial.begin(9600); //establish serial connection for output to Serial Monitor
}

void loop() {
for (int i=0; i<256; i++) { //value of i variable counts from 0 to 255
mysine = sin8(i); // sets mysine variable equal to whatever the output of sin8(i) is.

Serial.print(“mysine=”);
Serial.println(mysine);
Serial.print(“sine i=”);
Serial.println(i);
delay(500);
}
}

Here’s all of them. The major difference is really only their start values, plus a slight different in contours between cubicwave and quadwave. Obviously triwave is a straight up and down.
missing/deleted image from Google+

Thanks for your help!