RGB led lighting project code malfunction
hello all, thank helping me out. totally new arduino code (and answer problem) going simple. have tested hardware several times both multimeter , serial moniter. first serious project, , trying construct lighthouse. want light house turn on when light level low. want motor turn on , spin mirror around. trying make motor speed adjustable based on state of potentiometer. additional feature have able switch between solid white light , alternating colors. when ran code however, nothing whatsoever happened. observation had (and don't know if helps) realized led connected pin 13 dimly lit. offer me, newbie, appreciated.
here code:
int potentiometer=a2;
int swtch=a5;
int threshold=1000;
int photo=a0;
int blue=13;
int green=12;
int red=11;
int val=0;
int motor=9;
void setup(){
pinmode;(motor,output);
pinmode;(blue=output);
pinmode;(green=output);
pinmode;(red=output);
}
void loop(){
val=analogread(photo); //checking light conditions//
int swtchstate=analogread(swtch); //check switch//
if(val<threshold && swtchstate>500){
analogwrite(motor,potentiometer); //turns motor on if light conditions low// //sets motor speed based on potentiometer//
digitalwrite;(blue,high); //if switch on turn on white light//
digitalwrite;(green,high);
digitalwrite;(red,high);
;}
else if(val<threshold && swtchstate<500){ //if switch turned offand light conditions low led alternate color//
analogwrite(motor,potentiometer); //turns motor on if light conditions low// //sets motor speed based on potentiometer//
digitalwrite;(blue=high); //blue//
delay(100);
digitalwrite;(blue=low); //green//
digitalwrite;(green=high);
delay(100);
digitalwrite;(green=low); //red//
digitalwrite;(red=high);
delay(100);
digitalwrite;(red=low); //teal//
digitalwrite;(blue=high);
digitalwrite;(green=high);
delay(100);
digitalwrite;(blue=low);//yellow//
digitalwrite;(red=high);
delay(100);
digitalwrite;(blue=high); //purple//
delay(100); }
else{}}
here code:
int potentiometer=a2;
int swtch=a5;
int threshold=1000;
int photo=a0;
int blue=13;
int green=12;
int red=11;
int val=0;
int motor=9;
void setup(){
pinmode;(motor,output);
pinmode;(blue=output);
pinmode;(green=output);
pinmode;(red=output);
}
void loop(){
val=analogread(photo); //checking light conditions//
int swtchstate=analogread(swtch); //check switch//
if(val<threshold && swtchstate>500){
analogwrite(motor,potentiometer); //turns motor on if light conditions low// //sets motor speed based on potentiometer//
digitalwrite;(blue,high); //if switch on turn on white light//
digitalwrite;(green,high);
digitalwrite;(red,high);
;}
else if(val<threshold && swtchstate<500){ //if switch turned offand light conditions low led alternate color//
analogwrite(motor,potentiometer); //turns motor on if light conditions low// //sets motor speed based on potentiometer//
digitalwrite;(blue=high); //blue//
delay(100);
digitalwrite;(blue=low); //green//
digitalwrite;(green=high);
delay(100);
digitalwrite;(green=low); //red//
digitalwrite;(red=high);
delay(100);
digitalwrite;(red=low); //teal//
digitalwrite;(blue=high);
digitalwrite;(green=high);
delay(100);
digitalwrite;(blue=low);//yellow//
digitalwrite;(red=high);
delay(100);
digitalwrite;(blue=high); //purple//
delay(100); }
else{}}
code: [select]
digitalwrite;(blue=high);
delete semi-colon after digitalwrite , correct syntax too.similarly @ pinmode command syntax
Arduino Forum > Using Arduino > Programming Questions > RGB led lighting project code malfunction
arduino
Comments
Post a Comment