# My code wont work!

**URL:** <https://forum.arduino.cc/t/my-code-wont-work/1342112>\
**Category:** General Guidance\
**Created:** [January 13, 2025, 8:21am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112 "2025-01-13T08:21:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![fireheart123](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fireheart123/32/1160519_2.png) [@fireheart123](https://forum.arduino.cc/u/fireheart123)\
**Post date:** [January 13, 2025, 8:21am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/1 "2025-01-13T08:21:25Z")

</div>

this is on Arduino IDE and it doesnt work. heres the code:

```arduino
;
int red = 11;
int green = 10;
int blue = 9

;char RED_PIN
;char GREEN_PIN
;char BLUE_PIN

  ;
void setup(){
  ;pinMode(RED_PIN, OUTPUT)
    ;pinMode(GREEN_PIN, OUTPUT)
      ;pinMode(BLUE_PIN, OUTPUT)

        ;digitalWrite(RED_PIN, HIGH)
          ;delay(1000) // turns the red color on
  ;digitalWrite(GREEN_PIN, LOW)
    ;delay(1000) // turns the green color off
  ;digitalWrite(BLUE_PIN, LOW)
    ;delay(1000) // turns the blue color off
;}

;
void loop() {

 ;digitalWrite(RED_PIN, LOW)
   ;delay(1000) // turns the red color off
    ;digitalWrite(GREEN_PIN, HIGH)
      ;delay(1000) // turns the green color on
    ;digitalWrite(BLUE_PIN, LOW)
      ;delay(1000) // turns the blue color off

    ;digitalWrite(RED_PIN, HIGH)
      ;delay(1000) // repeats first cycle
    ;digitalWrite(GREEN_PIN, LOW)
      ;delay(1000) // repeats first cycle
    ;digitalWrite(BLUE_PIN, LOW)
      ;delay(1000) // turns the blue color off
;}

```

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [January 13, 2025, 8:23am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/2 "2025-01-13T08:23:22Z")

</div>

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'  
  
Use **code tags** (the \< CODE/ \> icon above the compose window)&nbsp;to make it easier to read and copy for examination   
  
[https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum)

In my experience the easiest way to tidy up the code and add the code tags is as follows  
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

---

<div class="post-metadata">

**Author:** ![fireheart123](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fireheart123/32/1160519_2.png) [@fireheart123](https://forum.arduino.cc/u/fireheart123)\
**Post date:** [January 13, 2025, 8:25am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/3 "2025-01-13T08:25:20Z")

</div>

wow how did you reply so fast!? also i think the code isnt the problem its the breadboard. im trying to copy from fritzing but it wont work.

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [January 13, 2025, 8:31am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/4 "2025-01-13T08:31:55Z")

</div>

Bearing in mind the forum category that you have posted in, are you really using the Arduino Command Line tools or are you using the IDE ?

What should the code do and what does it actually do ? I note that it is formatted very strangely

---

<div class="post-metadata">

**Author:** ![J-M-L](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/j-m-l/32/766245_2.png) [@J-M-L](https://forum.arduino.cc/u/J-M-L)\
**Post date:** [January 13, 2025, 8:32am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/5 "2025-01-13T08:32:02Z")

</div>

> [@fireheart123](#):
>
> how did you reply so fast!? also i think the code isnt the problem

Our mods and helpers are sharp 🙂

the code as posted is a problem for the forum etiquette...

So if you want to receive help here, please correct your post and add code tags around your code.

There is a small pencil ![image](https://europe1.discourse-cdn.com/arduino/original/4X/1/4/9/149dbc7ac50c56bee5ba7e5d09e723c8acd5a1bc.png) below your existing posts.

- click on this pencil ➜ that will let you edit your post.
- Select the part of the text that corresponds to the code
- Click on the `<code/>` icon in the toolbar to indicate that it is code
- click ![image](https://europe1.discourse-cdn.com/arduino/original/4X/1/4/9/149dbc7ac50c56bee5ba7e5d09e723c8acd5a1bc.png) Save Edit

(Also make sure to properly indent the code in the IDE before copying and pasting it here. This can be done by pressing ctrlT on a PC or cmdT on a Mac)

* * *

Note that it's more usual to see the semicolon at the very end of the statement and not at the start of the next line, ie we don't write

```arduino
int blue = 9

;char RED_PIN
;char GREEN_PIN
;char BLUE_PIN

;

```

but

```arduino
int blue = 9;
char RED_PIN;
char GREEN_PIN;
char BLUE_PIN;

```

---

<div class="post-metadata">

**Author:** ![pert](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pert/32/217111_2.png) [@pert](https://forum.arduino.cc/u/pert)\
**Post date:** [January 13, 2025, 8:45am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/6 "2025-01-13T08:45:59Z")

</div>

I moved your topic to a more appropriate forum category @fireheart123.

In the future, please take the time to pick the [forum category](https://forum.arduino.cc/categories) that best suits the subject of your question. There is an " **About the \_\_\_\_\_ category**" topic at the top of each category that explains its purpose.

Thanks in advance for your cooperation.

---

<div class="post-metadata">

**Author:** ![fireheart123](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fireheart123/32/1160519_2.png) [@fireheart123](https://forum.arduino.cc/u/fireheart123)\
**Post date:** [January 13, 2025, 9:39am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/7 "2025-01-13T09:39:40Z")

</div>

it is meant to control an rgb led but when i uploaded it didnt even work on the breadboard

---

<div class="post-metadata">

**Author:** ![fireheart123](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fireheart123/32/1160519_2.png) [@fireheart123](https://forum.arduino.cc/u/fireheart123)\
**Post date:** [January 13, 2025, 9:43am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/8 "2025-01-13T09:43:26Z")

</div>

thanks J-M-L. helps a lot. please check out the code i can probably figure out how to put the fritzing image on here..

---

<div class="post-metadata">

**Author:** ![fireheart123](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fireheart123/32/1160519_2.png) [@fireheart123](https://forum.arduino.cc/u/fireheart123)\
**Post date:** [January 13, 2025, 9:52am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/9 "2025-01-13T09:52:04Z")

</div>

this code wont work..

```arduino
//Library
;char pixels
//Constants
const int dinPin = 4; // Din pin to Arduino pin 4
const int numOfLeds = 8; // Number of leds

// Color takes RGB values, from 0,0,0 up to 255,255,255
// e.g. White = (255,255,255), Red = (255,0,0);
int red = 255; //Value from 0(led-off) to 255(). 
int green = 00; 
int blue = 0;

void setup() {
	pixels.begin(); // Initializes the NeoPixel library
	pixels.setBrightness(80); // Value from 0 to 100%
}

void loop() {
  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
  for(int i=0;i<numOfLeds;i++){
    pixels.setPixelColor(i, pixels.Color(red,green,blue)); 
    pixels.show(); // This sends the updated pixel color to the hardware.
    delay(1000); // Delay for a period of time to change the next led
  }
}

```

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [January 13, 2025, 10:02am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/10 "2025-01-13T10:02:29Z")

</div>

> [@fireheart123](#):
>
> this code wont work.

```arduino
;char pixels

```

The sketch does not even compile because of the line of code above

Then you do

```cpp
    pixels.begin(); // Initializes the NeoPixel library

```

but the library has not been #included and the pixels variable is not an instance of the library so you get an error every time you try to use it

Which library are you trying to use ?

---

<div class="post-metadata">

**Author:** ![fireheart123](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fireheart123/32/1160519_2.png) [@fireheart123](https://forum.arduino.cc/u/fireheart123)\
**Post date:** [January 13, 2025, 10:08am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/11 "2025-01-13T10:08:58Z")

</div>

im a beginner with arduino so i dont know much

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [January 13, 2025, 10:31am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/12 "2025-01-13T10:31:48Z")

</div>

> [@fireheart123](#):
>
> please check out the code i can probably figure out how to put the fritzing image on here..

You shouldn't do fritzing !  
If you have no other source than a fritzing picture for heaven's sake post it.  
Otherwise do a much more informative and easier to create schematic like described in this 3 minutes tutorial

> [@How to provide an easy to read schematic and how not](https://forum.arduino.cc/t/how-to-provide-an-easy-to-read-schematic-and-how-not/989506/1):
>
> This tutorial shall show how to provide an easy to read schematic of your wiring and how you should not post fritzing pictures don't post frizzy-pictures like that! if you look at this pictures please tell me the IO-pin-numbers! What ?? You can't read the IO-pin-numbers? You have to download the picture and than zoom in. Don't you have time? You have to download the datasheet of the chip and then look up which pin is connected to what. take additional time to count through the chip-pins an…

> [@fireheart123](#):
>
> im a beginner with arduino so i dont know much

Take a look into this tutorial:

[Arduino Programming Course](https://startingelectronics.org/software/arduino/learn-to-program-course/)

It is easy to understand and has a good mixture between explaining important concepts and example-codes to get you going. So give it a try and report your opinion about this tutorial.

---

<div class="post-metadata">

**Author:** ![pert](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pert/32/217111_2.png) [@pert](https://forum.arduino.cc/u/pert)\
**Post date:** [January 13, 2025, 10:36am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/13 "2025-01-13T10:36:45Z")

</div>

I have merged your topics due to them appearing to have too much overlap on the same subject matter @fireheart123.

In the future, please only create one topic for each distinct subject matter and be careful not to cause them to converge into parallel discussions.

The reason is that generating multiple threads on the same subject matter can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Thanks in advance for your cooperation.

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [January 13, 2025, 7:33pm UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/14 "2025-01-13T19:33:27Z")

</div>

> [@fireheart123](#):
>
> beginner with arduino

You might be a beginner with Arduino, but not with computers or documents. The Arduino "sketch" is a document that you write in the Arduino IDE for the IDE to compile (turn into machine language) and store on the Arduino.

You are making copy/paste mistakes. The sketches you have posted need only minor corrections (stray characters, missing lines) to compile and run. Be sure to copy/paste correctly, and you will certainly have success.

Here are your two sketches, with minor edits...

**RGBLED**

```arduino
char RED_PIN = 11;
char GREEN_PIN = 10;
char BLUE_PIN = 9;

void setup() {
  pinMode(RED_PIN, OUTPUT);
  pinMode(GREEN_PIN, OUTPUT);
  pinMode(BLUE_PIN, OUTPUT);
}

void loop() {
  digitalWrite(RED_PIN, LOW);
  digitalWrite(GREEN_PIN, HIGH);
  digitalWrite(BLUE_PIN, LOW);
  delay(1000); // turns the blue color off

  digitalWrite(RED_PIN, HIGH);
  digitalWrite(GREEN_PIN, LOW);
  digitalWrite(BLUE_PIN, LOW);
  delay(1000); // turns the blue color off

  digitalWrite(RED_PIN, LOW);
  digitalWrite(GREEN_PIN, LOW);
  digitalWrite(BLUE_PIN, HIGH);
  delay(1000);
}

```

**NEOPIXELS**

```arduino
#include <Adafruit_NeoPixel.h>

const int PIN = 4;
const int NUMPIXELS = 8;
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int red = 255;
int green = 0;
int blue = 0;

void setup() {
  pixels.begin();
  pixels.setBrightness(255); // 0 to 255
}

void loop() {
  for (int i = 0; i < NUMPIXELS; i++) {
    pixels.setPixelColor(i, pixels.Color(red, green, blue));
    pixels.show();
    delay(500);
  }
  pixels.clear(); // a new command
  pixels.show(); // added this command
  delay(500); // added this command
}

```

---

<div class="post-metadata">

**Author:** ![fireheart123](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fireheart123/32/1160519_2.png) [@fireheart123](https://forum.arduino.cc/u/fireheart123)\
**Post date:** [January 14, 2025, 12:16am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/15 "2025-01-14T00:16:00Z")

</div>

[Untitled.ino](https://forum.arduino.cc/uploads/short-url/rFT0GbWeUVX3R2AKUV4WUnOyzGk.ino) (950 Bytes)

---

<div class="post-metadata">

**Author:** ![fireheart123](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fireheart123/32/1160519_2.png) [@fireheart123](https://forum.arduino.cc/u/fireheart123)\
**Post date:** [January 14, 2025, 12:56am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/16 "2025-01-14T00:56:56Z")

</div>

i tried the same breadboard build but it seems to be only doing red rgb led. care to help?

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [January 14, 2025, 1:55am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/17 "2025-01-14T01:55:17Z")

</div>

> [@fireheart123](#):
>
> care to help?

I though I have been helping. Sometimes things take time.

> [@fireheart123](#):
>
> only doing red rgb

LEDs need to be connected in the correct direction. Cathode toward ground, Anode toward power or signal. Your RGBLED has ONE COMMON pin. You need to discover if it is a Common Anode or Common Cathode. I think this will solve your issue.

The best help for yourself and others is to draw a wiring diagram of your circuit. That makes you know the pins you are using are connected correctly. The drawing will help others see your work. Then, post a picture, so the actual wiring can be verified.

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [January 14, 2025, 2:12am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/18 "2025-01-14T02:12:10Z")

</div>

HI, @fireheart123  
Welcome to the forum.

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?  
Hand drawn and photographed is perfectly acceptable.  
Please include ALL hardware, power supplies, component names and pin labels.

We need this so we can check your hardware connections.

Can you post some images of your project?  
So we can see your component layout.

Thanks.. Tom.. 😃 👍 ☕ 🇦🇺

---

<div class="post-metadata">

**Author:** ![fireheart123](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fireheart123/32/1160519_2.png) [@fireheart123](https://forum.arduino.cc/u/fireheart123)\
**Post date:** [January 14, 2025, 4:03am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/19 "2025-01-14T04:03:55Z")

</div>

[document1.pdf](https://forum.arduino.cc/uploads/short-url/loJF84YUHjUfii7zgMIpMoytlGd.pdf) (270.0 KB)

> [@TomGeorge](#):
>
> Can you post some images of your project?

the link is up above for the breadboard and arduino uno view

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [January 14, 2025, 4:04am UTC](https://forum.arduino.cc/t/my-code-wont-work/1342112/20 "2025-01-14T04:04:51Z")

</div>

Please, post an image (assuming the document is an image).

[Next page](https://forum.arduino.cc/t/my-code-wont-work/1342112.md?page=2)
