Very Very new to Aduino looking for beginners corner!

Sorry for this
Ive looked and looked and according to the left hand pane others are asking similar,

While I'm an Automotive engineer and have a basic knowledge. I have never tried programming. I have used C++ for basic CFG analysis air flows etc

So Ive built an led strip for the Indicators for my car as a test, ( following this youtube video https://www.youtube.com/watch?v=gqaCwqRQ3gE&t=97s )

but as soon as I upload his sketch I run into all sorts of errors and of course don't know what they mean

Could someone point me in the right direction, either the correct place for this post or nudge in the right direction as to the error messages.

Kind regards

Stephen
PS I have dropped the sketch below and the error codes Just in case hope this is the right thing to do; thank you in advance

home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:1:5: error: found ':' in nested-name-specifier, expected '::'
 Name:  CarInterface.ino
     ^
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:1:1: error: 'Name' does not name a type
 Name:  CarInterface.ino
 ^~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:65:25: error: variable or field 'indicatorAnimation' declared void
 void indicatorAnimation(CRGB *leds) {
                         ^~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:65:25: error: 'CRGB' was not declared in this scope
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:65:25: note: suggested alternative: 'OCR0B'
 void indicatorAnimation(CRGB *leds) {
                         ^~~~
                         OCR0B
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:65:31: error: 'leds' was not declared in this scope
 void indicatorAnimation(CRGB *leds) {
                               ^~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:65:31: note: suggested alternative: 'gets'
 void indicatorAnimation(CRGB *leds) {
                               ^~~~
                               gets
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino: In function 'void setup()':
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:32:2: error: 'FastLED' was not declared in this scope
  FastLED.addLeds<WS2812B, L_INDICATOR_LED_PIN, GRB>(L_Indicator_leds, 3).setCorrection(TypicalLEDStrip);
  ^~~~~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:32:18: error: 'WS2812B' was not declared in this scope
  FastLED.addLeds<WS2812B, L_INDICATOR_LED_PIN, GRB>(L_Indicator_leds, 3).setCorrection(TypicalLEDStrip);
                  ^~~~~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:32:27: error: 'L_INDICATOR_LED_PIN' was not declared in this scope
  FastLED.addLeds<WS2812B, L_INDICATOR_LED_PIN, GRB>(L_Indicator_leds, 3).setCorrection(TypicalLEDStrip);
                           ^~~~~~~~~~~~~~~~~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:32:48: error: 'GRB' was not declared in this scope
  FastLED.addLeds<WS2812B, L_INDICATOR_LED_PIN, GRB>(L_Indicator_leds, 3).setCorrection(TypicalLEDStrip);
                                                ^~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:32:48: note: suggested alternative: 'DDRB'
  FastLED.addLeds<WS2812B, L_INDICATOR_LED_PIN, GRB>(L_Indicator_leds, 3).setCorrection(TypicalLEDStrip);
                                                ^~~
                                                DDRB
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:32:53: error: 'L_Indicator_leds' was not declared in this scope
  FastLED.addLeds<WS2812B, L_INDICATOR_LED_PIN, GRB>(L_Indicator_leds, 3).setCorrection(TypicalLEDStrip);
                                                     ^~~~~~~~~~~~~~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:32:88: error: 'TypicalLEDStrip' was not declared in this scope
  FastLED.addLeds<WS2812B, L_INDICATOR_LED_PIN, GRB>(L_Indicator_leds, 3).setCorrection(TypicalLEDStrip);
                                                                                        ^~~~~~~~~~~~~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:34:24: error: 'BRIGHTNESS' was not declared in this scope
  FastLED.setBrightness(BRIGHTNESS);
                        ^~~~~~~~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:36:11: error: 'L_INDICATOR_INPUT' was not declared in this scope
   pinMode(L_INDICATOR_INPUT, INPUT);
           ^~~~~~~~~~~~~~~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino: In function 'void loop()':
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:43:39: error: 'L_INDICATOR_INPUT' was not declared in this scope
   bool L_IndicatorInput = digitalRead(L_INDICATOR_INPUT);
                                       ^~~~~~~~~~~~~~~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:49:22: error: 'L_Indicator_leds' was not declared in this scope
   indicatorAnimation(L_Indicator_leds);
                      ^~~~~~~~~~~~~~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:49:22: note: suggested alternative: 'L_IndicatorInput'
   indicatorAnimation(L_Indicator_leds);
                      ^~~~~~~~~~~~~~~~
                      L_IndicatorInput
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:49:3: error: 'indicatorAnimation' was not declared in this scope
   indicatorAnimation(L_Indicator_leds);
   ^~~~~~~~~~~~~~~~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:49:3: note: suggested alternative: 'indicatorLEDsLit'
   indicatorAnimation(L_Indicator_leds);
   ^~~~~~~~~~~~~~~~~~
   indicatorLEDsLit
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:53:22: error: 'L_Indicator_leds' was not declared in this scope
   indicatorAnimation(L_Indicator_leds);
                      ^~~~~~~~~~~~~~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:53:22: note: suggested alternative: 'L_IndicatorInput'
   indicatorAnimation(L_Indicator_leds);
                      ^~~~~~~~~~~~~~~~
                      L_IndicatorInput
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:53:3: error: 'indicatorAnimation' was not declared in this scope
   indicatorAnimation(L_Indicator_leds);
   ^~~~~~~~~~~~~~~~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:53:3: note: suggested alternative: 'indicatorLEDsLit'
   indicatorAnimation(L_Indicator_leds);
   ^~~~~~~~~~~~~~~~~~
   indicatorLEDsLit
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:58:14: error: 'L_Indicator_leds' has not been declared
   fill_solid(L_Indicator_leds:: 3, CRGB::Black);
              ^~~~~~~~~~~~~~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:58:33: error: expected unqualified-id before numeric constant
   fill_solid(L_Indicator_leds:: 3, CRGB::Black);
                                 ^
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:58:36: error: 'CRGB' has not been declared
   fill_solid(L_Indicator_leds:: 3, CRGB::Black);
                                    ^~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:58:3: error: 'fill_solid' was not declared in this scope
   fill_solid(L_Indicator_leds:: 3, CRGB::Black);
   ^~~~~~~~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:62:2: error: 'FastLED' was not declared in this scope
  FastLED.show();
  ^~~~~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino: At global scope:
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:65:25: error: variable or field 'indicatorAnimation' declared void
 void indicatorAnimation(CRGB *leds) {
                         ^~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:65:25: error: 'CRGB' was not declared in this scope
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:65:25: note: suggested alternative: 'OCR0B'
 void indicatorAnimation(CRGB *leds) {
                         ^~~~
                         OCR0B
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:65:31: error: 'leds' was not declared in this scope
 void indicatorAnimation(CRGB *leds) {
                               ^~~~
/home/s/Arduino/CarInterface_copy_1/CarInterface_copy_1.ino:65:31: note: suggested alternative: 'gets'
 void indicatorAnimation(CRGB *leds) {
                               ^~~~
                               gets

exit status 1

Compilation error: found ':' in nested-name-specifier, expected '::'

/
from this sketch;


Name:		CarInterface.ino
 Created:	3/17/2021 4:15:11 PM
 Author:	Mr Monkey 
 
 Code and schematic demonstrating how to interface an Arduino with 12V signals
 from a vehicle. This code is for educational purposes only, and should not be
 used on public roads unless you know it is legal where you live.
*/
include <FastLED.h>

define NUM_LEDS			    3
define INDICATOR_MS      30
define BRIGHTNESS        200

// Connections to the 12V signals from vehicle
define L_INDICATOR_INPUT	3

// Connections to the LED strips

define L_INDICATOR_LED_PIN	7


// LED arrays for the lights
define CRGB L_INDICATOR_LEDS[3];


// Used for indicator animation
uint8_t indicatorLEDsLit = 3;

void setup() {

	FastLED.addLeds<WS2812B, L_INDICATOR_LED_PIN, GRB>(L_Indicator_leds, 3).setCorrection(TypicalLEDStrip);
	
	FastLED.setBrightness(BRIGHTNESS);

		pinMode(L_INDICATOR_INPUT, INPUT);

}

void loop() {

	// Read the state of the inputs
		bool L_IndicatorInput = digitalRead(L_INDICATOR_INPUT);
		
	// Brake lights
	
	// Indicators
	if (L_IndicatorInput ) {
		indicatorAnimation(L_Indicator_leds);
	}
	
	else if (!L_IndicatorInput) {
		indicatorAnimation(L_Indicator_leds);
	}
	
	
	else {
		fill_solid(L_Indicator_leds:: 3, CRGB::Black);
			indicatorLEDsLit = 3;
	}

	FastLED.show();
}

void indicatorAnimation(CRGB *leds) {
	for (int i = 0; i < indicatorLEDsLit; i++) {
		leds[i] = CRGB::Orange;
	}
	
	EVERY_N_MILLISECONDS(INDICATOR_MS) {
		indicatorLEDsLit++;
		if (indicatorLEDsLit > 3) indicatorLEDsLit = 3;
	}
}


miss # before include.

#include <FastLED.h>

and here

and here

1 Like
  1. your code should begin with "/*", as many of those top lines are comments
  2. anywhere you have "include" or "define", it should actually be "#include" or "#define"

And these
L_Indicator_leds
are not the same as the #define. Capitalization matters.

Similar problems exist.

Bad copy/paste.

Try this:

/*
Name:		CarInterface.ino
 Created:	3/17/2021 4:15:11 PM
 Author:	Scott Marley
 
 Code and schematic demonstrating how to interface an Arduino with 12V signals
 from a vehicle. This code is for educational purposes only, and should not be
 used on public roads unless you know it is legal where you live.
*/

#include <FastLED.h>

#define NUM_LEDS			    9
#define INDICATOR_MS      30
#define BRIGHTNESS        200

// Connections to the 12V signals from vehicle
#define BRAKE_INPUT			  4
#define L_INDICATOR_INPUT	3
#define R_INDICATOR_INPUT	2

// Connections to the LED strips
#define L_BRAKE_LED_PIN		  8
#define R_BRAKE_LED_PIN		  9
#define L_INDICATOR_LED_PIN	7
#define R_INDICATOR_LED_PIN	6

// LED arrays for the lights
CRGB l_brake_leds[NUM_LEDS];
CRGB r_brake_leds[NUM_LEDS];
CRGB l_indicator_leds[NUM_LEDS];
CRGB r_indicator_leds[NUM_LEDS];

// Used for indicator animation
uint8_t indicatorLEDsLit = 0;

void setup() {
	FastLED.addLeds<WS2812B, L_BRAKE_LED_PIN, GRB>(l_brake_leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
	FastLED.addLeds<WS2812B, R_BRAKE_LED_PIN, GRB>(r_brake_leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
	FastLED.addLeds<WS2812B, L_INDICATOR_LED_PIN, GRB>(l_indicator_leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
	FastLED.addLeds<WS2812B, R_INDICATOR_LED_PIN, GRB>(r_indicator_leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
	FastLED.setBrightness(BRIGHTNESS);

	pinMode(BRAKE_INPUT, INPUT);
	pinMode(L_INDICATOR_INPUT, INPUT);
	pinMode(R_INDICATOR_INPUT, INPUT);
}

void loop() {

	// Read the state of the inputs
	bool brakeInput = digitalRead(BRAKE_INPUT);
	bool LIndicatorInput = digitalRead(L_INDICATOR_INPUT);
	bool RIndicatorInput = digitalRead(R_INDICATOR_INPUT);
	
	// Brake lights
	if (brakeInput) {
		fill_solid(l_brake_leds, NUM_LEDS, CRGB::Red);
		fill_solid(r_brake_leds, NUM_LEDS, CRGB::Red);
	}
	else {
		fill_solid(l_brake_leds, NUM_LEDS, CRGB::Black);
		fill_solid(r_brake_leds, NUM_LEDS, CRGB::Black);
	}

	// Indicators
	if (LIndicatorInput && !RIndicatorInput) {
		indicatorAnimation(l_indicator_leds);
	}
	
	else if (RIndicatorInput && !LIndicatorInput) {
		indicatorAnimation(r_indicator_leds);
	}
	
	// Hazards
	else if (LIndicatorInput && RIndicatorInput) {
		fill_solid(l_indicator_leds, NUM_LEDS, CRGB::Orange);
		fill_solid(r_indicator_leds, NUM_LEDS, CRGB::Orange);
	}
	
	else {
		fill_solid(l_indicator_leds, NUM_LEDS, CRGB::Black);
		fill_solid(r_indicator_leds, NUM_LEDS, CRGB::Black);
		indicatorLEDsLit = 0;
	}

	FastLED.show();
}

void indicatorAnimation(CRGB *leds) {
	for (int i = 0; i < indicatorLEDsLit; i++) {
		leds[i] = CRGB::Orange;
	}
	
	EVERY_N_MILLISECONDS(INDICATOR_MS) {
		indicatorLEDsLit++;
		if (indicatorLEDsLit > NUM_LEDS) indicatorLEDsLit = NUM_LEDS;
	}
}

HTH

a7

Try your code modified simulated here:

Below, your code modified:

/*
  Name:		CarInterface.ino
  Created:	3/17/2021 4:15:11 PM
  Author:	Scott Marley

  Code and schematic demonstrating how to interface an Arduino with 12V signals
  from a vehicle. This code is for educational purposes only, and should not be
  used on public roads unless you know it is legal where you live.
*/
#include <FastLED.h>
#define NUM_LEDS			    3
#define INDICATOR_MS      30
#define BRIGHTNESS        200
#define L_INDICATOR_INPUT	3           // Connections to the 12V signals from vehicle
#define L_INDICATOR_LED_PIN	7         // Connections to the LED strips
CRGB L_INDICATOR_LEDS[NUM_LEDS];      // LED arrays for the lights
uint8_t indicatorLEDsLit = 3;         // Used for indicator animation
//-------------------------------------------------------
void setup() {
  FastLED.addLeds<WS2812B, L_INDICATOR_LED_PIN, GRB>(L_INDICATOR_LEDS, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(BRIGHTNESS);
  pinMode(L_INDICATOR_INPUT, INPUT);
}
//-------------------------------------------------------
void loop() {
  // Read the state of the inputs
  bool L_IndicatorInput = digitalRead(L_INDICATOR_INPUT);
  // Brake lights
  // Indicators
  if (L_IndicatorInput ) {
    indicatorAnimation(L_INDICATOR_LEDS);
  }
  else {
    fill_solid(L_INDICATOR_LEDS, NUM_LEDS, CRGB::Black);
    indicatorLEDsLit = NUM_LEDS;
  }
  FastLED.show();
}
//-------------------------------------------------------
void indicatorAnimation(CRGB *leds) {
  for (int i = 0; i < indicatorLEDsLit; i++) {
    leds[i] = CRGB::Orange;
  }
  EVERY_N_MILLISECONDS(INDICATOR_MS) {
    indicatorLEDsLit++;
    if (indicatorLEDsLit > NUM_LEDS) indicatorLEDsLit = NUM_LEDS;
  }
}

Multi-line comments using '/*' are terminated with a '*/' sequence.

1 Like

@dougp look closely at the first post several lines in you'll find an unpaired

*/

Funny, that whole top section of uncompilable verbiage becomes comment if you just do as I suggested and start with

/*

Sheesh.

Thank you
Yes that was me deleting stuff to see if the error code changed

I had made a simple circuit with one LED and used the code in the tutorial , that worked but when I tried to upscale I got unstuck

Thank you for taking the time to reply

Stephen

Thank you
Thats a big help really good , I can try things out and learn

thank you

really appreciate that and you taking the time
Stephen

Sorry As I noted before , this was me deleting stuff and by this point I was lost and wandering around in circles

And when ur lost , go back to the beginning and try again !

Thank you for taking the time to reply !

Stephen

Ah, I see now.