can any one help fix sketch ??
still getting to know language
it keeps saying
sketch_jun09a.cpp: In function 'void loop()':
sketch_jun09a:35: error: 'ledPin' was not declared in this scope
sketch_jun09a:38: error: expected `}' at end of input
// Random flasher by mark oldroyd
// Simple random number flasher
// generation and integration into your circuit on the
// arduino.
//
// Circuit build : Simply connect 8 LED's to pins 3,4,5,6,7,8,9,10
// Be sure to connect a resistor to each LED. I used 330 ohms.
//
//
int ranNum;
int ranDel;
void setup() {
// Seed RNG from analog port.
randomSeed(analogRead(0));
// Setup 8 output ports for LED's
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop() {
//Generate random number between 8 and 10
ranNum=random(3,11);
// Generate random delay time
ranDel=random(100,400);
//Turn on the LED
digitalWrite(ranNum, HIGH);
delay(ranDel);
// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
Move the edit cursor immediately AFTER the final closing "}" in the code. Visually scan the code and you will see that the opening "{" in:
"for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {"
is HIGHLIGHTED, meaning that these two 'curly braces' are a matching pair!
Place the edit cursor immediately AFTER the opening "{" in:
"void loop() {"
Visually scan the code, but you will NOT find any highlighted closing "}" because there isn't one to make a matching pair, and there MUST be a matching pair, or you will get a compile error ... which is exactly what is happening.
You have to add a closing "}" at the proper place to match the opening "{" in "void loop() {".
Be CAREFUL to always provide matching symbols where pairs are required. If you think THIS was fun, sometime delete a matching quote mark (") from a pair and see what headaches it yields! Unfortunately, quote mark pairings are NOT highlighted like other pairings.
Blessings in abundance, all the best, & ENJOY!
Art in Carlisle, PA USA
im here
sketch_jun09b.cpp: In function 'void loop()':
sketch_jun09b:35: error: 'ledPin' was not declared in this scope
so what is wrong now
// Random flasher by mark oldroyd
// Simple random number flasher
// generation and integration into your circuit on the
// arduino.
//
// Circuit build : Simply connect 8 LED's to pins 3,4,5,6,7,8,9,10
// Be sure to connect a resistor to each LED. I used 330 ohms.
//
//
int ranNum;
int ranDel;
void setup() {
// Seed RNG from analog port.
randomSeed(analogRead(0));
// Setup 8 output ports for LED's
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop() {
//Generate random number between 8 and 10
ranNum=random(3,11);
// Generate random delay time
ranDel=random(100,400);
//Turn on the LED
digitalWrite(ranNum, HIGH);
delay(ranDel);
// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5)
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
No. You really NEED to learn how to fix this issue yourself. Look at the declaration of ranNum and ranDel. Those statements declare that the variables exist, and that they have a specific type. Only you know what type ledPin should have. Only you know what value should be assigned to the variable.