this is on Arduino IDE and it doesnt work. heres the code:
;
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
;}
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.
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 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 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
int blue = 9
;char RED_PIN
;char GREEN_PIN
;char BLUE_PIN
;
but
int blue = 9;
char RED_PIN;
char GREEN_PIN;
char BLUE_PIN;
I moved your topic to a more appropriate forum category @fireheart123.
In the future, please take the time to pick the forum category 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.
//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
}
}
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
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.
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.
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
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
#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
}
I though I have been helping. Sometimes things take time.
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.
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.