Tab Content
Tab Title
Instructions
Tab Content
  1. Click between the curly brackets ({ and }) of the setup function.
  2. Type “BTConnect.begin(9600);”
  3. Press enter and type “pinMode(led, OUTPUT);”
  4. Press enter and type “myservo.attach(9);”

 

STEM Connections

The first line of code in the setup function, “BTConnect.begin(9600);” begins the SoftwareSerial connection at a speed (baud rate) of 9600. The next two lines are used in previous activities: “pinMode(led, OUTPUT);” sets up pin 13 (remember led = 13) as an output, and “myservo.attach(9);” sets up pin 9 to control the Servo.

Tab Title
Implementation
Tab Content

If you are modeling this code on a screen for students to follow along, go slowly through these steps as there is a lot of code to write. If you prefer to have students write code independently, print the final code and distribute to students or use the Thinkabit Lab notebook. At the Thinkabit Lab, we typically guide students through this process before showing them the completed version so that we can explain in detail the code needed in the loop function.

Tab Title
Troubleshooting
Tab Content
  1. Colors don’t change like they do in the video

The words “begin”, “pinMode”, “OUTPUT” and “attach” should all change colors as they are recognized functions in Arduino. If the colors do not change 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 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