김은지유은제김선미gledel
Published

Arduino campaign project for my adorable cat, "Fishing Cat"

It was the second day of our project. We tested if the servo motor operates or not when the switch is pressed.

IntermediateWork in progress594
Arduino campaign project for my adorable cat, "Fishing Cat"

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
×1
Arduino Nano R3
Arduino Nano R3
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Servos (Tower Pro MG996R)
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
Resistor 1k ohm
Resistor 1k ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Switch and servo motor

Code

Switch and servo motor

Arduino
The servo motor is operated when the switch is pressed.
int sw_pin1 = 2;

int sw1_value;

#include <Servo.h>

Servo servo1;

void setup() {

servo1. attach(13);

pinMode(sw_pin1, INPUT);



  Serial.begin(9600);

 

}

 

void loop() {

  sw1_value = digitalRead(sw_pin1);

  

  if(sw1_value == LOW){

    Serial.println(sw1_value);

    servo1.write(0);

    delay(500);

    servo1.write(45);

    delay(500);

    servo1.write(20);

    delay(500);

    servo1.write(50);

    delay(500);

    servo1.write(10);

    delay(500);

    servo1.write(90);

    delay(500);

    servo1.write(70);

    delay(500);

    servo1.write(30);

    delay(500);

    servo1.write(30);

    delay(500);

     

  }

  else{

  servo1.write(0);



  }

 

}

Credits

김은지
6 projects • 0 followers
I am a high school student in Korea.
유은제
15 projects • 13 followers
Hello :-) I'm a high school student in South Korea.
김선미
8 projects • 2 followers
gledel
100 projects • 116 followers
Looking back on my childhood, I was happy when I was making something and I was proud of myself. "Making is instinct!"

Comments