I am trying to get last week's assignment to work before going into this weeks
it seems to not like line 2 (int switchPin = 7;)
why do i get a:
error: redefinition of 'int switchPin' In function 'void setup()':
In function 'void loop()':
for this:
int ledPin = 13;
int switchPin = 7;
int pulsePin = 3;
int pulseLevel1 = 500;
int pulseLevel2 = 5000;
int pulseWidth = 1000;
int switchValue;
void setup() {
// make ledPin an output pin for mr. led
pinMode(ledPin, OUTPUT);
// make switchPin an input pin
pinMode(switchPin, INPUT);
//set internal pull up resistor
digitalWrite(switchPin, HIGH);
}
void loop() {
switchValue = digitalRead(switchPin);
if (switchValue == 0) { //i.e.: you've pushed the switch
//remember we're normally HIGH
// because of the internal pullup
pulseWidth = pulseLevel2;
} else {
pulseWidth = pulseLevel1;
}
//we actually do the pulsing here
digitalWrite(pulsePin, HIGH);
delayMicroseconds(pulseWidth);
digitalWrite(pulsePin, LOW);
delayMicroseconds(pulseWidth);
}
Thanks
k.
Monday, February 26, 2007
why does this happen?
Posted by
Kenzan
at
1:08 PM
0
comments
Thursday, February 15, 2007
debug time.
I am pretty proud of myself for writing this little program, its a lot easier than the LED, counting all that crap. But I have written this from scratch, and I cannot figure out why this is happening. ideas?
Posted by
Kenzan
at
2:58 PM
0
comments
Subscribe to:
Comments (Atom)