본문 바로가기

Arduino6

VSC 초기화 오류 보호되어 있는 글 입니다. 2022. 8. 7.
문자열 분리하기 const char DelimeterChar = ','; const char TerminatorChar = '\n'; String readString; String firstString; String secondString; String thirdString; int firstDelimeter = 0; int secondDelimeter = 0; void setup() { Serial.begin(9600); } void loop() { if (Serial.available() > 0) { readString = Serial.readStringUntil(TerminatorChar); } else { delay(1); return; } Serial.print("Read String : "); Serial.p.. 2022. 7. 31.
Class 만들어 사용하기 클래스 만들기 DoServo.h #include class DoServo { private: Servo servo; public: DoServo(int pin); ~DoServo(); void Attach(int pin); void Detach(); void Write(int angle); int Read(); }; DoServo.cpp #include "DoServo.h" DoServo::DoServo(int pin) { Attach(pin); } DoServo::~DoServo() { Detach(); } void DoServo::Attach(int pin) { servo.attach(pin); } void DoServo::Detach() { servo.detach(); } void DoServo::.. 2022. 7. 31.
VSC arduino include 오류 보호되어 있는 글 입니다. 2022. 7. 30.
서보모터 제어(MG995) Servo Motor MG955 회로도 소스 코드 #include int servoPin = 9; int delayTime = 20; Servo servo; int angle = 0; void setup() { servo.attach(servoPin); } void loop() { // 0 to 179 for(angle = 0; angle 0; angle--) { servo.write(angle); delay(delayTime); } } 2022. 7. 30.
VSCode 에서 아두이노 개발하기 1. VSCode 설치 https://code.visualstudio.com/ Visual Studio Code - Code Editing. Redefined Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows. code.visualstudio.com 2. Arduino 확장 설치 3. 프로젝트를 저장할 폴더 설정 파일 - 폴더 열기 4. 아두이노 프로젝트 생성 도움말 - .. 2022. 7. 30.