Hi, we don't have any experience programming and need to program an adruino uno with an hc-06 bluetooth transmitter to control a servo. It is a 180 degree servo and we need it go to 0 degrees or 180 degrees based on an on/off input from the bluetooth on a mac computer. Here's what we have so far:
Here is our setup. From bluetooth to board: power is 5v, gnd is gnd, tx is to rx 0, and rx is to tx 1. The servo is connected to the 5V, gnd, and pin 9.
I know nothing about bluetooth, but surely there's enough sample code around to get you started with sending a "code" to the Arduino through BT?
Then I'm sure that "code" would be a variable, just as you have it called "switch"?
But right now your code won't compile since the variable "switch" isn't defined at the top of the sketch.
If I were you, I'd declare a variable called "switch" and put an actual switch (or just a piece of wire) on a pin. Then read that pin into the variable "switch".
This example shows how to read a switch; they read it into a variable called "buttonState".
Get that sorted, then look at the BT side of things, that's my advice.
Ah btw, I can't get a compile using the variable name "switch" even if I declare it, since it's a word used elsewhere in Arduinoland. So I used "switch1", that compiles.