Kabar Terkini

Video Materi Dasar Robotika





//SKETCH 01 - Blink Led onboard Esp8266 - by Fajar Himawan

void setup() {
    pinMode(D4, OUTPUT);
}

void loop() {
    digitalWrite(D4, HIGH);
    delay(500);
    digitalWrite(D4, LOW);
    delay(500);
}

_______________
_______________


//SKETCH 02 - Mengendalikan Led onboard ESP8266 dg Komunikasi Serial - by Fajar Himawan

void setup() {
    Serial.begin(9600);
    pinMode(D4, OUTPUT);
}

void loop() {
    if(Serial.available()){
        int state = Serial.parseInt();
        
        if(state == 1){
            digitalWrite(D4, HIGH);
            Serial.println("Led Mati");
        }
        
if(state == 2){
            digitalWrite(D4, LOW);
            Serial.println("Led Menyala");
        }
        

    }
}

_______________
_______________


//SKETCH 03 -  Control Servo motor using Arduino Serial monitor


#include <Servo.h>
Servo myservo;
int pos = 0;
void setup()
{
Serial.begin(9600);
while (!Serial);
Serial.println("-------------------------");
Serial.println("ARos is loading....");
delay(1000);
Serial.println("ARos loaded succesfully");
Serial.println("-------------------------");
myservo.attach(D4);
Serial.println("calibrating servo...");
for (pos = 0; pos <= 180; pos += 1)
myservo.write(0);
delay(1000);
myservo.write(180);
delay(1000);
myservo.write(90);
delay(1000);
Serial.println("servo calibrated");
Serial.println("-------------------------");
Serial.println("Comand input online, write command to perform action");
Serial.println("-------------------------");
}
void loop() {
for (pos = 0; pos <= 180; pos += 1)
if (Serial.available())
{
int state = Serial.parseInt();
if (state < 10)
{
Serial.print(">");
Serial.println(state);
Serial.println("Cannot execute command, too low number");
Serial.read();
Serial.read();
}
if (state >= 10 && state < 170)
{
Serial.print(">");
Serial.println(state);
Serial.print("turning servo to ");
Serial.print(state);
Serial.println(" degrees");
myservo.write(state);
Serial.read();
Serial.read();
}
}
}




No comments

Featured Post

INILAH 6 PROGRAM PRIORITAS Kemendikdasmen Versi Abdul Mu'ti, Usung Pendidikan Bermutu untuk Semua

INILAH 6 PROGRAM PRIORITAS Kemendikdasmen Versi Abdul Mu'ti, Usung Pendidikan Bermutu untuk Semua INILAH 6 PROGRAM PRIORITAS ...