Tab Content
Tab Title
Instructions
Tab Content
  1. Before writing the code for the loop, use the Bluetooth Communication Worksheet or your Thinkabit Lab notebook to determine what code you will need to write.

graphs

if (BTData == ‘Code Received’){if(BTData == ‘A’){

Arduino Action CodedigitalWrite(led, HIGH);

 

2. Click between the curly brackets ({ and }) of the loop function and type the following code:

void loop(){

if BTConnect.available()){

    BTData = BTConnect.read();

    if(BTData == ‘A’){

        digitalWrite(led, HIGH);

    }

    if (BTData == ‘B’){

        digitalWrite(led, LOW);

    }

    if (BTData == ‘C’){

        myservo.write(0);”

    }

    if (BTData == ‘D’){

        myservo.write(180);

    }

}

delay(100);

}

Tab Title
Implementation
Tab Content

The curly brackets in the code can be very difficult for students. At the Thinkabit Lab, we find it easier to walk students through the code to see that the closed brackets are placed automatically when an open bracket is used. Although we typically use a large font size on the display screen, a smaller font size displays the entire code. Using a smaller font size on the display for students to see the entire code, show them when you click on a closed bracket, it shows the corresponding open bracket. This will be a great help for students to see the opening and closed brackets of the code.

Tab Title
Troubleshooting
Tab Content
  1. There are extra closed brackets at the end of the code
  • Double check that you have all the brackets needed to complete the loop function and then delete any extra brackets.

 

  1. Colors don’t change like they do in the video

Several words should change colors as they are recognized functions in Arduino. If they did not change colors as shown in the video, check the following:

  • Check the spelling of the words and for proper capitalization.
  • Check the spacing, watch the video and read the instructions carefully.
  • If the color is changed, but to a different color than the video, the Arduino software may have been updated. If these words are colored, the code should still work properly.
Instruction Category
Video