목록분류 전체보기 (20)
STUDY BLOG
명품 C++ programming Chapter 07 예제 예제 7-1 프랜드 함수 만들기 #include using namespace std; class Rect; bool equals(Rect r, Rect s); class Rect { int width, height; public: Rect(int width, int height) { this->width=width; this->height=height; } friend bool equals(Rect r, Rect s); }; bool equals(Rect r, Rect s) { if(r.width==s.width && r.height==s.height) return true; else return false; } int main() { Rect ..
명품 C++ programming Chapter 06 예제 예제 6-1 big() 함수 중복 연습 #include using namespace std; int big(int a, int b) { if(a>b) return a; else return b; } int big(int a[], int size){ int res = a[0]; for(int i=1; i
명품 C++ Programming Chapter 05 예제 예제 5-1 '값에 의한 호출' 시 매개 변수의 생성자 실행되지 않음 #uinclude using namespace std; class Circle { private: int radius; public: Circle(); Circle(int r); ~Circle(); double getArea() { return 3.14*radius*radius; } int getRadius() { return radius; } void setRadius(int radius) { this->radius = radius; } }; Circle::Circle() { radius = 1; cout

시리얼 모니터에 r 입력시 빨간불 on 한번 더 입력 시 off 시리얼 모니터에 g 입력시 초록불 on 한번 더 입력 시 off 시리얼 모니터에 b 입력시 파란불 on 한번 더 입력 시 off unsigned char c; const int pinLEDR=10; const int pinLEDG=11; const int pinLEDB=12; int red=0; int green=0; int blue=0; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(pinLEDR, OUTPUT); pinMode(pinLEDG, OUTPUT); pinMode(pinLEDB, OUTPUT); pinMode(Serial.r..

가만히 있으면 RGB LED 모듈 OFF 틸트센서 기울이면 REB LED 모듈 모든 색상 ON const int pinTilt = 2; const int pinLED_R = 10; const int pinLED_G = 9; const int pinLED_B = 8; int val = 0; void setup() { // put your setup code here, to run once: pinMode(pinLED_R, OUTPUT); pinMode(pinLED_G, OUTPUT); pinMode(pinLED_B, OUTPUT); Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: val = analogRea..

온도센서가 상온에 있을 때 : RGB 모듈이 파란색 ON 온도센서를 손으로 잡았을 때 : RGB 모듈이 빨간색 ON const int pinLM35 = 1; const int pinLED_R = 10; const int pinLED_G = 9; const int pinLED_B = 8; int val = 0; void setup() { // put your setup code here, to run once: pinMode(pinLED_R, OUTPUT); pinMode(pinLED_G, OUTPUT); pinMode(pinLED_B, OUTPUT); Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: val..
명품 C++ programming Chapter 04 예제 연습 예제 4-1 객체 포인터 선언 및 활용 #include using namespace std; class Circle { int radius; public: Circle() { radius = 1; } Circle(int r) { radius = r; } double getArea(); }; double Circle::getArea() { return 3.14*radius*radius; } int main() { Circle donut; Circle pizza(30); cout
명품 C++ programming Chapter 03 예제 연습 예제 3-1 Circle 클래스의 객체 생성 및 활용 #include using namespace std; class Circle{ piblic: int radius; double getArea(); }; double Circle::getArea(){ return 3.14*radius*radius; } int main(){ Circle donut; // 객체 donut 생성 donut.radius =1; // donut의 멤버 변수 접근 double area = donut.getArea(); // donut의 멤버 함수 호출 cout
명품 C++ programming Chapter 02 예제 연습 예제 2-1 기본적인 C++ 프로그램 // cout과
티스토리 블로그 시작합니다. 주로 전공관련 과제, 프로젝트 관련 자료 업로드 예정입니다. 잘부탁드립니다.