Go Down

Topic: why won't it add? (Read 943 times) previous topic - next topic

TECH GEEK

here is code:
Code: [Select]
 int rgbV = 26;
 int pV = 13;
 int V = 0;
 int V2 = 0;
 
void setup() {
   
 #define p1 13    
 #define p2 9
 #define p3 5
 #define p4 22
 #define p5 12
 #define p6 8
 #define p7 4
 #define p8 23
 #define p9 11
 #define p10 7
 #define p11 3
 #define p12 24
 #define p13 10
 #define p14 6
 #define p15 2
 #define p16 25
 #define r1 26
 #define g1 27
 #define b1 28  
 #define r2 29  
 #define g2 30  
 #define b2 31  
 #define r3 32  
 #define g3 33  
 #define b3 34  
 #define r4 35  
 #define g4 36  
 #define b4 37
 
 pinMode(22, OUTPUT);
 pinMode(23, OUTPUT);
 pinMode(24, OUTPUT);
 pinMode(25, OUTPUT);
 pinMode(2, OUTPUT);
 pinMode(3, OUTPUT);
 pinMode(4, OUTPUT);
 pinMode(5, OUTPUT);
 pinMode(6, OUTPUT);
 pinMode(7, OUTPUT);
 pinMode(8, OUTPUT);
 pinMode(9, OUTPUT);
 pinMode(10, OUTPUT);
 pinMode(11, OUTPUT);
 pinMode(12, OUTPUT);
 pinMode(13, OUTPUT);
 pinMode(26, OUTPUT);
 pinMode(27, OUTPUT);
 pinMode(28, OUTPUT);
 pinMode(29, OUTPUT);
 pinMode(30, OUTPUT);
 pinMode(31, OUTPUT);
 pinMode(32, OUTPUT);
 pinMode(33, OUTPUT);
 pinMode(34, OUTPUT);
 pinMode(35, OUTPUT);
 pinMode(36, OUTPUT);
 pinMode(37, OUTPUT);
}

void loop() {
 digitalWrite(rgbV, HIGH);  
 digitalWrite(p1, HIGH);
 delay(500);              
 digitalWrite(rgbV, LOW);
 digitalWrite(p1, LOW);
 delay(500);      
 if (rgbV = 37) {
   rgbV = 26;
 }
 else {
   [glow]++rgbV;[/glow]  }
}
As always... Thanks for posting!!!

mowcius

define's go outside setup(){}

PaulS

Code: [Select]
if (rgbV = 37) {
This assigned the value 37 to rgbV. It did not compare the value in rgbV to 37. The comparison operator (==) would have done that.

robtillaart

Code: [Select]
if (rgbV = 37) {
   rgbV = 26;
 }
 else {
   ++rgbV;  }

PaulS is completely right,  
The assignment gives rgbV the value 37. In the if statement all values not equal to zero are evaluated true so the statement rgbV =26 will be executed all the time.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

AWOL

Quote
define's go outside setup(){}

#defines can go just about anywhere you like as long as they're before any references to them.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

mowcius

Quote
#defines can go just about anywhere you like as long as they're before any references to them.

You learn something new every day :)

retrolefty

Quote
You learn something new every day  


Not me, at my age I'm lucky if I learn something new once a week. And yes, my lawn is off limits.  ;)

Lefty

Go Up