0

Please help me! Once I click the upload button. I get the following error:

'serialWrite' was not declared in this scope

Here is my code:

int buttonPin
void setup ()
{
beginSerial(9600);
pinMode (buttonPin, INPUT);
}
void loop ()
{
if (digitalRead(buttonPin) == HIGH)
serialWrite('H');
else
serialwrite('L');
delay(1000);
}
  • 1
    Where did you see that anything called "serialWrite" is supposed to exist? – Ignacio Vazquez-Abrams Jul 6 '16 at 3:38
  • Pay attention to the examples. They would have had Serial.begin (9600); - not beginSerial(9600);. You can't just re-arrange words and drop off punctuation. – Nick Gammon Jul 6 '16 at 6:55
  • 1
    Also, int buttonPin won't compile. – Johnny Mopp Jul 6 '16 at 13:18
  • Same code! After I upload it. It was an error. avrdude: stk500v2_getsync(): timeout (something like that – karryl jim Jul 8 '16 at 5:13
-4

It should be Serial.write to notice the period.

Which would make your code:

int buttonPin
void setup ()
{
    Serial.begin(9600);  # There was an error on this line as well
    pinMode (buttonPin, INPUT);
}
void loop ()
{
    if (digitalRead(buttonPin) == HIGH)
    Serial.write('H');
    else
    Serial.write('L');
    delay(1000);
}

Have a look at https://www.arduino.cc/en/Serial/Write for a complete example

  • 1
    Actually Serial.write - notice the capital "S" and the lower-case "w". – Nick Gammon Jul 6 '16 at 6:54
  • 9
    If you are going to answer a question, which involves mis-spelling of Arduino function names, it helps to not mis-spell them yourself. Please test your code before posting a "correction". – Nick Gammon Jul 6 '16 at 6:58
  • Hey guys, I know I could have written my own answer, but in the interests of improving what is here and well, just because I'ma nice guy (hehehehhe) I felt like giving this answer a hand up :) – Madivad Jul 30 '16 at 1:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.