I'm having some serious probs here with my serial connections. i have this sketch witch should print hello world when the button is pressed, but it keeps giving this error:
In function 'void setup()':
error: 'serial' was not declared in this scope In function 'void loop()':
its kinda irritating, so please help me.
int sw = 3;
int led = 13;
void setup(){
serial.begin(9600);
pinMode(sw, INPUT);
pinMode(led,OUTPUT);
}
void loop()
{
if (sw == LOW) {
serial.print ("Hello World");
digitalWrite(led,LOW);
}
if (sw ==HIGH) {
digitalWrite(led,HIGH);
}
}
You need to capitalize Serial; the compiler is case-sensitive.
great i got it working now!! but the next problem arises.... it sends now data, but every time on the same line like this:
123456789101112131415161718192021222324252627282930313233343536373839
int ledPin = 13;
int ledcount;
int incomingByte;
void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
ledcount++;
Serial.print(ledcount); //sends how many times the led was switched on.
}
123456789101112131415161718192021222324252627282930313233343536373839
And if you look carefully at this, it reads:
1 2 3 4 5 6 7 8 9 10 11 12 13 14...39
Try "Serial.println(ledcount);"
or
"Serial.print (ledcount); Serial.print(" " ); "