A Bit of help for a newbie please.

Hi all,
I’m Jason and I am new to all this so please go easy on me. I am trying to make an array of LED’s to replicate the indicators of a new Audi. I have put some code together out of examples on here and other sources.
I have sorted the sweep, and the colour, and I have 2 arrays one for the left and one for the right both operating from there own input. the problem Ihave is I need to activate both at the same time to indicate the Hazard warning lights.
Could any of you nice people have a solution to drive both arrays at the same time.
the LED arrays are WS2812b RGB strips.
here is the code.
Thanks
Jason.

// cd ~/Arduino/libraries // git clone https://github.com/FastLED/FastLED.git

//Now you can create a new .ino file with your IDE of choice (I’ve really been loving Sublime Text) and insert the starter code from the FastLED wiki:

#include “FastLED.h”

// fast led constants
#define DATA_PIN 3 // change to your data pin
#define COLOR_ORDER GRB // if colors are mismatched; change this
#define NUM_LEDS 20 // change to the number of LEDs in your strip
#define DATA_PIN1 5 // change to your data pin
#define COLOR_ORDER GRB // if colors are mismatched; change this
#define NUM_LEDS1 20// change to the number of LEDs in your strip

#define IN_1 10
#define IN_2 12
// change WS2812B to match your type of LED, if different
// list of supported types is here:
// Overview · FastLED/FastLED Wiki · GitHub
#define LED_TYPE WS2812B

int IN_4 = 4; // set up input 4
int IN_6 = 6; // set up input 6
int IN_7 = 7; // set up input 6

// this creates an LED array to hold the values for each led in your strip
CRGB leds[NUM_LEDS]; // Array 1
CRGB leds1[NUM_LEDS1]; // Array 2

// This sets up the Colour pallet

DEFINE_GRADIENT_PALETTE( heatmap_gp ) {
0, 0, 0, 0, //black
128, 255, 0, 0, //red
224, 255,255, 0, //bright yellow
255, 255,255,255 }; //full white

CRGBPalette16 myPal = heatmap_gp;

uint8_t heatindex = (156);

void setup()
{

// the wiki features a much more basic setup line:
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.addLeds<LED_TYPE, DATA_PIN1, COLOR_ORDER>(leds1, NUM_LEDS1);

pinMode(IN_4,INPUT);
pinMode(IN_6,INPUT);
pinMode(IN_7,INPUT);
pinMode(IN_1,OUTPUT);
pinMode(IN_2,OUTPUT);
reset_ports();

}

void blink_left(int port) // Left indicator sequence
{
for(int dot = 0; dot < NUM_LEDS; dot++)
{
leds[dot] = ColorFromPalette( myPal, heatindex); // normal palette access
FastLED.show();
delay(25);
}
delay(200);

for(int dot = 0; dot < NUM_LEDS; dot++)
{
leds[dot] = CRGB::Black;
FastLED.show();
// clear this led for the next time around the loop
leds[NUM_LEDS - dot] = CRGB::Black;
delay(1);
}

delay(200);

}

void blink_right(int port) // Right indicator sequence
{
for(int dot1 = 0; dot1 < NUM_LEDS1; dot1++)
{
leds1[dot1] = ColorFromPalette( myPal, heatindex); // normal palette access
FastLED.show();
delay(25);
}

delay(200);
for(int dot1 = 0; dot1 < NUM_LEDS1; dot1++)
{
leds1[dot1] = CRGB::Black;

FastLED.show();

// clear this led for the next time around the loop
leds1[NUM_LEDS1 - dot1] = CRGB::Black;
delay(1);
}
delay(200);
}

void reset_ports()
{
digitalWrite(IN_1,0);
digitalWrite(IN_2,0);
}

void loop()
{
IN_4 = digitalRead(4);
if (IN_4 == HIGH){

blink_left(IN_2);
reset_ports();
}

IN_6 = digitalRead(6);
if (IN_6 == HIGH){

blink_right(IN_2);
reset_ports();
}

IN_7 = digitalRead(7);
if (IN_7 == HIGH){

// blink_both(IN_2);
reset_ports();
}

}

Open up the Examples folder which came with your Arduino software. Find the Blink-Without-Delay example.

Study it well.

Try to modify it to do one of your functions. Then add more functions.

Next time you post here, use [ code ] tags. (The button looks like </> on the full editor.)

Thanks for the reply, But i'm still not understanding it. as i said i am very new to coding and need a bit more guidance.

@Carlberg1 stop whining about being a newbie and put some effort in. You have already broken at least 3 forum rules (#6, #7, #14) and this won't make you any friends here, no matter how "nice" you tell us we are. So you should 1. go read the forum guidelines; 2. edit your posts and correct where you broke the rules; have a proper go at following MorganS' suggestion and post your best effort.

Hi, Welcome to the forum.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

int IN_4 = 4;             // set up input 4
int IN_6 = 6;             // set up input 6
int IN_7 = 7;             // set up input 6

You could use some identifiable names

int leftturnPin = 4;             // set up input 4
int righturnPin = 6;             // set up input 6
int hazardPin = 7;             // set up input 7

Then keep using the names through your code.

Tom... :)

Thanks Tom for your constructive comments I will go through the code and try and tidy it up. This is my first attempt at Arduino code so it's a massive learning curve, My main objective was to get it running, now I am trying to get it to do what I want. My background is not programming so this is why I asked for help..It's easy to post statments about what to study but I don't yet have the understanding of how it all works to impliment the "blink without delay" into my code to get over the problem. It's like shouting at a french man in english and expecting him to understand what you are saying. I will look up all the forum rules and regulations to keep other members happy, "he" must have been bullied at school and been wedgied daily...;

Carlsburg1: I will look up all the forum rules and regulations to keep other members happy, "he" must have been bullied at school and been wedgied daily...;

It's not that. It's that admonishments to:

  • post code in code tags
  • provide a schematic
  • read forum posting rules appear here about twenty times a day. Some get weary of it.

The demo Several Things at a Time is an extended example of BWoD and illustrates the use of millis() to manage timing without blocking. It may help with understanding the technique.

...R Planning and Implementing a Program