SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By jped
#147609
is there anything wrong with this code? The arduino code editior says it is ok, but it doesnt work.
int d1a=13;
int d2a= 12;
int s1= 10;
int d1b=11;
int d2b=8;
int sb=9;
int sensorPin = 5;
void setup () {
  Serial.begin(9600);
  pinMode (d1a, OUTPUT);
  pinMode (d2a, OUTPUT);
  pinMode (s1, OUTPUT);
  pinMode (d1b, OUTPUT);
  pinMode (d2b, OUTPUT);
  pinMode (sb, OUTPUT);
}
void loop () {
  int val= analogRead (sensorPin);
  Serial.println (val);
    if (val > 520) {
    analogWrite (10, 0);
digitalWrite (13 , LOW);
digitalWrite (12, HIGH);
analogWrite (9, 255);
digitalWrite (11 , LOW);
digitalWrite (8, HIGH);

    }
    else {
        analogWrite (10, 255);
digitalWrite (13 ,LOW);
digitalWrite (12, HIGH);
analogWrite (9, 255);
digitalWrite (11 , LOW);
digitalWrite (8, HIGH);
    }
}
By trialex
#147612
Well, people are going to (correctly) state that we don't know what it is SUPPOSED to do, nor do we know what it ACTUALLY does, so how can we know what's wrong?
By jped
#147615
very good question....i think i fixed it myself FOr now
By Philba
#147663
There's something wrong with my car. It seems to be making a strange noise and doesn't work right. Could some one fix it please.
By skimask
#147666
I can fix it. I'll paint it blue. That should cure the noise and the whiteness.
And I'll swap the visors and see if that makes it work right.
By stevech
#147775
where's the comments and explanations of what this is supposed to do?
Not wise to omit comments.. for your own sake 3 months from now.