Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am using the Arduino Uno and basically I am looking at If and Then Statements.

ID: 2988390 • Letter: I

Question

I am using the Arduino Uno and basically I am looking at If and Then Statements. I'll try to explain this as simple as possible.

I am trying to make it so that If power is going through one pin (not connected to servo) The servo will turn to 180 degrees. If the pin stops getting power then the servo will turn back to 0 degrees.

Since I am using the Digital pins it will be along the lines of If pin11 is 1 then servo will turn to 180 degrees, else if it will go to 0.

But I am not even sure which pin should be the one or zero "Sensor". Also the only part of the servo that will be connected to the Micro controller will be the yellow chord that receives the signals. The ground and power will be connected directly to the battery. Please help and let me know if I need to clear up anymore things.

Explanation / Answer

void setup()
{
Serial.begin(115200);//set baud value
}
void loop()
{
int n=analogRead(A0);//define A0 as the received port
float vol=n*(5.0/1023*100);//voltage signal to temperature
upload_sensor(vol);//sub-function
delay(5000);
}

void upload_sensor(float vol)
{
// send the HTTP PUT request:
char buf[200];
memset(buf,0,200);
int ret;
ret=sprintf(buf,"GET /upload.php?uid=ycf&ps=ycf&sensor_name=a...
//protocol setting
Serial.print(buf); //stored at buf temporally
Serial.print(vol);//use temperature data vol
Serial.println(" HTTP/1.1"); //HTTP protocol name
Serial.println("Host: api.cduino.com");//set server website
Serial.println("Connection: close");//data transmission is finished, and connection is closed.
Serial.println();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote